HOWTO: Perform a Silent Installation of DirectX 8.1 (319469)
The information in this article applies to:
- Microsoft DirectX Software Development Kit 8.1
- Microsoft Windows XP Professional
This article was previously published under Q319469 SUMMARY
The DirectXSetup function is included in the Microsoft DirectX 8.1 Software Development Kit (SDK). When you call this function, it can install the DirectX components. You can call the DirectXSetupSetCallback function to set a pointer to a callback function that is periodically called by DirectXSetup. You can use the callback function for Setup progress notification and to implement a custom user interface for a program's Setup program. If this callback function returns zero, the DirectXSetup function performs the default action for upgrading the DirectX component or driver. If you want to perform a silent installation of DirectX, you can create a DirectX callback function that returns zero. If you do this, no user interaction is required.
MORE INFORMATION
When you call the DirectXSetup function, you must supply the address of a string that contains the root path for the DirectX component files. This string must specify a full path to the folder that contains the Dsetup.dll and Dsetup32.dll files, and the DirectX redistributable files. If this value is null, the current working folder is used. The DirectX redistributable files are located in the DirectX 8.1 SDK installation. For example, if you installed the DirectX 8.1 SDK, the files may be located in the following folder:
C:\Dxsdk\Redist\DirectX81
The following sample code is a complete Windows-based program that calls the DirectXSetup function. Users do not have to do anything to install DirectX 8.1 by using this method.
NOTE: Installing DirectX 8.1 by using the DirectXSetup function requires developers either to display the DirectX End User License Agreement (EULA) and to gain acceptance from the user before installing DirectX, or to gain acceptance from the user of a developer-supplied EULA that contains provisions as described in the DirectX SDK EULA. More information about these documents is available in the DXReadme.txt file that is included with the DirectX 8.1 SDK.
#include <windows.h>
#include <dsetup.h>
int DirectXInstall();
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR strCmdLine, int nCmdShow )
{
int iRet;
iRet = DirectXInstall();
// Check the return value from DirectXInstall for success.
// You may have to restart the computer.
// DSETUPERR_SUCCESS - Success
// DSETUPERR_SUCCESS_RESTART - Success, but the user must restart
// the computer for the changes to take
// effect.
return (int)0;
}
DWORD WINAPI DirectXSetupCallbackFunction( DWORD dwReason, DWORD dwMsgType,
LPSTR strMessage, LPSTR strName,
VOID* pInfo )
{
// This callback function is called once for each step in the Setup process.
// If this function returns zero, the DirectXSetup function performs the
// default action for upgrading the DirectX component or driver.
return 0; // Zero is returned, so no user interaction is required.
}
int DirectXInstall()
{
CHAR strSource[_MAX_PATH];
int iRet;
// The Dsetup DLLs should be in the current path, with the DirectX
// Redist folder so that it can be found and set up. Otherwise, change
// the following code to reflect the actual path.
GetCurrentDirectory( _MAX_PATH, strSource );
// Set up the callback function before calling DirectXSetup.
DirectXSetupSetCallback( (DSETUP_CALLBACK)DirectXSetupCallbackFunction );
iRet = DirectXSetup( 0, strSource, DSETUP_DIRECTX );
return iRet;
}
Microsoft provides programming examples for illustration only, without warranty either
expressed or implied, including, but not limited to, the implied warranties of
merchantability and/or fitness for a particular purpose. This article assumes
that you are familiar with the programming language being demonstrated and the
tools used to create and debug procedures. Microsoft support professionals can
help explain the functionality of a particular procedure, but they will not
modify these examples to provide added functionality or construct procedures to
meet your specific needs. If you have limited programming experience, you may
want to contact a Microsoft Certified Partner or the Microsoft fee-based
consulting line at (800) 936-5200. For more information about Microsoft Certified
Partners, please visit the following Microsoft Web site:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
REFERENCES
For additional information about DirectX, visit the following Microsoft DirectX Web site:
Modification Type: | Major | Last Reviewed: | 4/21/2006 |
---|
Keywords: | kbDSWGDI2003Swept kbGDI kbhowto KB319469 |
---|
|