Archive: Game installation and DirectX


Game installation and DirectX
Hi All,

Im thinking of using NSIS for installation of our latest game for PC. Has anyone had any experience checking DirectX versions from NSIS? I am planning on creating a dll to do the job because of the need to call a couple of functions inside the dsetup.dll redist.

If anyone has done this before let me know, it would save me some time

Thanks

Stu


It's stored in a registry key:

HKLM, SOFTWARE\Microsoft\DirectX, Version


Thanks Joost,

Do you know from what version it was set in the Reg? I suppose if its not there I can run DX81 setup anyway, wont hurt
:)

Thanks


You can call DirectXSetupGetVersion using System.dll:

System::Alloc 4
Pop $0
System::Alloc 4
Pop $1
System::Call "dsetup::DirectXSetupGetVersion(i, i) i (r0, r1) .r2"
IntCmp $2 0 error

System::Call "*$0(&i4 .r2)"
System::Call "*$1(&i4 .r3)"

DetailPrint "$2.$3"
Goto done

error:
MessageBox MB_OK "can't get dx version"
done:
System::Free $0
System::Free $1


I have not tested this because I don't have DirectX SDK, nor DSetup.dll, but it should work if the documentation is right.

Just got DX9 redist and it works. You'll have to parse the numbers a bit with IntOp but that shouldn't be too hard.


hm, nice, how to get the direct setup to run with the DirectXSetup function and return a value?

DOCa Cola



!define DSETUPERR_SUCCESS 0
!define DSETUPERR_SUCCESS_RESTART 1
!define DSETUP_DDRAWDRV 0x00000008
!define DSETUP_DSOUNDDRV 0x00000010
!define DSETUP_DXCORE 0x00010000
!define DSETUP_DIRECTX 0x00010018

Section "Install DirectX"
System::Call 'DSetup::DirectXSetup(i, t, i) i \
($HWNDPARENT, "$TEMP\dxSetupFiles", ${DSETUP_DIRECTX}) .r0'
StrCmp $0 ${DSETUPERR_SUCCESS} done
StrCmp $0 ${DSETUPERR_SUCCESS_RESTART} 0 error
SetRebootFlag true
Goto done

error:
MessageBox MB_OK "error $0"
done:
SectionEnd

hm, i replaced the "$TEMP\dxSetupFiles" with "G:\Setup\DirectX" (for testing purposes) were the dxsetup.exe is located and put the dsetup.dll for testing in the folder with the output of my installer, but the $0 is always "error" after executing (messagebox gives out "error error")

DOCa Cola


All of the DirectX disribution files, including DSetup.dll should be in one folder. System.dll should be able to find DSetup.dll so you'll need to set the working directory to the directory where the setup files are using SetOutPath.


Hm, i did that, i took the folder from the redist and SetOutPath to it's directory (where the dxsetup.exe, dsetup.dll and so on is located). maybe u want to take a look at the script..but i didn't changed that much...

DOCa Cola


Are you sure DSetup.dll is in "G:\Setup\DirectX" and not "G:\Setup\DirectX\DirectX9"?


yep, version readout works with no problems...


This function has both Unicode and MBCS version it seems... Pretty obvious by the fact it accepts a string but the documentation said nothing about it, heh :)

Anyway, just add A (DirectXSetupA) after the function name - it works for me (reinstalled DX9.0a :))

Here's a list of return values:

#define DSETUPERR_SUCCESS_RESTART 1
#define DSETUPERR_SUCCESS 0
#define DSETUPERR_BADWINDOWSVERSION -1
#define DSETUPERR_SOURCEFILENOTFOUND -2
#define DSETUPERR_BADSOURCESIZE -3
#define DSETUPERR_BADSOURCETIME -4
#define DSETUPERR_NOCOPY -5
#define DSETUPERR_OUTOFDISKSPACE -6
#define DSETUPERR_CANTFINDINF -7
#define DSETUPERR_CANTFINDDIR -8
#define DSETUPERR_INTERNAL -9
#define DSETUPERR_NTWITHNO3D -10 /* REM: obsolete, you'll never see this */
#define DSETUPERR_UNKNOWNOS -11
#define DSETUPERR_USERHITCANCEL -12
#define DSETUPERR_NOTPREINSTALLEDONNT -13

ah! thx! that worked


If you get a finished script that's working well, can you please post it in The Archive so everyone can learn how to install DirectX games with NSIS?