[ Pobierz całość w formacie PDF ]
.The DSETUP_TESTINSTALL flag is special, in that it s usedonly during the installation program s development (that s you).If this flag is set, theinstallation proceeds as if it were a true installation without actually installing anything.Note that you won t receive some installation errors, such as when the user s diskbecomes too full to continue.If successful, DirectXSetup() will return one of two values:DSETUPERR_SUCCESSDSETUPERR_SUCCESS_RESTARTIf you are returned DSETUPERR_SUCCESS, you re done.If you seeDSETUPERR_SUCCESS_RESTART, restart the system.If you receive any other value, it san error value, and you ll need to take some appropriate action (crashing is not anappropriate response!).If you intend to customize the installation by providing a callback function, you mustregister it with DirectSetup prior to calling DirectXSetup().There is no requirementthat you implement a callback function, and if you elect not to, simply don t register anycallback function with DirectX.However, if you do want to tailor the installation, you doso through a callback function you register using the DirectXSetupSetCallback()APIcall:INT WINAPI DirectXSetupSetCallback(DSETUP_CALLBACK Callback);Remember that you must register your callback function before you makethe DirectXSetup() call.The callback function, known to DirectSetup as DirectXSetupCallbackFunction(),has this signature:DWORD DirectXSetupCallbackFunction(DWORD Reason,DWORD MsgType,char *szMessage,char *szName,void *pInfo);The Reason parameter will be an item from this list:DSETUP_CB_MSG_BEGIN_INSTALLDSETUP_CB_MSG_BEGIN_INSTALL_DRIVERSDSETUP_CB_MSG_BEGIN_INSTALL_RUNTIME36 1634xAppB 11/13/99 11:20 AM Page 539Prepare Your Application for Distribution with DirectSetup 539DSETUP_CB_MSG_BEGIN_RESTORE_DRIVERSDSETUP_CB_MSG_CANTINSTALL_BETADSETUP_CB_MSG_CANTINSTALL_NOTWIN32DSETUP_CB_MSG_CANTINSTALL_NTDSETUP_CB_MSG_CANTINSTALL_UNKNOWNOSDSETUP_CB_MSG_CANTINSTALL_WRONGLANGUAGEDSETUP_CB_MSG_CANTINSTALL_WRONGPLATFORMDSETUP_CB_MSG_CHECK_DRIVER_UPGRADEDSETUP_CB_MSG_INTERNAL_ERRORDSETUP_CB_MSG_NOMESSAGEDSETUP_CB_MSG_NOTPREINSTALLEDONNTDSETUP_CB_MSG_PREINSTALL_NTDSETUP_CB_MSG_SETUP_INIT_FAILEDI won t belabor each item here because you ll find the meaning behind each listed inthe online documentation.From this list, though, you can see many are errors, whereassome are status.Check the result in your callback and manage the situation as required.MsgType will contain bits appropriate for the MessageBox()API call (an exception iswhen MsgType is zero, in which case no action is required from the user, and status canmerely be displayed).For example, if DirectX wanted to ask the user if it was okay tooverwrite a given file, the callback would be executed, and MsgType would be set toMB_YESNO | MB_DEFBUTTON2.BszMessage is simply a localized status string you can use to display information to theuser regarding the installation or error condition.If DirectX is installing or upgrading a driver, szName contains a string representationof the driver.Note this parameter will usually be NULL.The exception is if Reason isDSETUP_CB_MSG_CHECK_DRIVER_UPGRADE.In this case, the pointer will indicate a validstring.pInfo is a pointer to a DSETUP_CB_UPGRADEINFO structure and is only valid if Reason isSETUP_CB_MSG_CHECK_DRIVER_UPGRADE.The DSETUP_CB_UPGRADEINFO structure is quitesimple:typedef struct _DSETUP_CB_UPGRADEINFO {DWORD UpgradeFlags;} DSETUP_CB_UPGRADEINFO;36 1634xAppB 11/13/99 11:20 AM Page 540540 Appendix BUpgradeFlags tells DirectSetup how to proceed with the upgrade of a given driver:DSETUP_CB_UPGRADE_CANTBACKUPDSETUP_CB_UPGRADE_DEVICE_ACTIVEDSETUP_CB_UPGRADE_DEVICE_DISPLAYDSETUP_CB_UPGRADE_DEVICE_MEDIADSETUP_CB_UPGRADE_FORCEDSETUP_CB_UPGRADE_HASWARNINGSDSETUP_CB_UPGRADE_KEEPDSETUP_CB_UPGRADE_SAFEDSETUP_CB_UPGRADE_UNKNOWNThe flags are fairly self-explanatory, but for additional details, again refer to the onlinedocumentation.If you re using a callback to customize the installation, you can expect the callback tobe executed many times during the execution.Simply examine the Reason parameter andtake some action based upon its contents.If you re being asked to request informationfrom the user, you might find the MsgType parameter useful.If there is something todisplay to the user, use the szMessage information.And if DirectX is installing a driver,you might need to manage the szName and pInfo data.Be sure to take a look at the sample DirectSetup installation program supplied with theSDK, DInstall.exe.Not only should that help address any questions you might haveregarding using the DirectSetup API, but it should also provide you with a hefty amountof source code you can easily swipe and make your own.That s always an added benefit!37 1634x index 11/13/99 11:10 AM Page 541INDEX3D effects, 81-82 detection, 324-328SYMBOLSmultiple layers, 82-87 Newton s Law ofcalculating layer posi- Restitution for#import directive, 494tions, 89 Instantaneous#pragma directive, 497image surfaces, 84-85 Collision With No
[ Pobierz całość w formacie PDF ]