Today I was trying to uninstall DirectX from my Windows XP box to install the latest DirectX version (DirectX 9C), for newbies DirectX is a collection of APIs used to handle multimedia applications in Windows platforms, its mainly designed for game programming to improve their performance using the DirectX video acceleration feature. The terms DirectDraw, Direct3D, DirectPlay, DirectSound, DirectMusic are often synonymous with DirectX and the DirectX runtime in general powers multimedia games in Windows.
Though there is no uninstaller available for DirectX, I tried to remove DirectX by removing the registry entry by Googling for DirectX uninstallation. For uninstalling DirectX, I removed the DirectX registry entry on Windows XP by running regedit and removing DirectX key (HKEY_LOCAL_MACHINE -> SOFTWARE -> Microsoft -> DirectX).
Now to install DirectX (DirectX 9c), I used the DirectX web setup procedure as can be found in Microsoft's DirectX End-User Runtime Web Installer page here.
But then, the installation failed throwing the below error message as shown in the screenshot below.
The partial installation error log is shown below (DXError.log in C:\Windows\Logs)
Current DirectX may be a older version which does not have directx key in the registry.
--------------------
[01/19/09 16:10:21] module: dxupdate(Oct 27 2008), file: dxupdate.cpp, line: 4515, function: DirectXUpdateDownloadPlugIn
GetDXVersion() failed.
--------------------
[01/19/09 16:10:22] module: DXWSetup(Oct 27 2008), file: dxupdate.cpp, line: 386, function: DownloadPlugIn
DirectXUpdateDownloadPlugIn() failed.
--------------------
[01/19/09 16:10:22] module: DXWSetup(Oct 27 2008), file: psheets.cpp, line: 498, function: PreinstDlgProc
DownloadPlugIn() failed.
--------------------
[01/19/09 16:11:33] module: dxupdate(Oct 27 2008), file: dxupdate.cpp, line: 175, function: GetDXVersion
Failed API: RegOpenKeyEx()
Error: (2) - The system cannot find the file specified.
The registry key removal caused the installation problem, therefore NEVER remove any DirectX registry entry to uninstall DirectX, unless you have a proper uninstallation procedure, which DirectX doesn't have currently, don't try to remove DirectX by other means, or if you do so, take a backup of your registry, then the dxdiag diagonostic tool also displayed a Version not found message as shown in the figure below.
The Solution: Now I need to make sure that the installation procedure succeeds, somehow I need to recreate the DirectX registry entry. Therefore I looked at another Windows XP box and found that DirectX entry and recreated the DirectX registry key with its value (HKEY_LOCAL_MACHINE -> SOFTWARE -> Microsoft -> DirectX) in my box as shown in the figure below.
Fig 4: DirectX Registry Entry
Creating the DirectX entry is very simple, all you need to do is
1. Open regedit
2. Go to HKEY_LOCAL_MACHINE -> SOFTWARE -> Microsoft
3. Right click, create a new Key DirectX
4. Goto DirectX, create a new binary Value InstalledVersion and assign the value shown above
5. Create another String named Version and assign the value shown above
Unfortunately, the version I entered is the latest DirectX release version (from the other Windows XP box), so the installer assumed that my system was installed with the latest version after checking the DirectX registry entry and therefore didn't install DirectX 9.
Then I did one more tweak, which is modifying the DirectX Version string to 0.00.00.0000 in the DirectX registry entry (Open regedit, Go to HKEY_LOCAL_MACHINE -> SOFTWARE -> Microsoft -> DirectX, right click the Version String, click modify and change its value to 0.00.00.0000), as shown in the below figure.
Fig 5: Changing Version String in DirectX
Upon invoking the installer, this time it worked fine, it downloaded and installed the latest DirectX version as was shown in the figure below.
The lesson: Never remove registry entry to uninstall anything.