Archive: Help me With Windows Detection


Help me With Windows Detection
Got a question

I want that my installer detects wich Windows is running

if it is Win.95/98/ME then he must install this file
File /a "D:\MPC9598ME"

and if it is Win.XP then he must install this file
File /a "D:\MPCXP"

Could somebody help me ??????

Thanks :) :) :) :) :) :) :) :) :) :) :) :) :) :)


u didn't read the documentation.
look at Appendix B: Usefull Functions -> Get Windows Version


I Found this. But where should I set the
File /a "D:\MPC.exe" ??????

Between wich commands???

Function GetWindowsVersion

Push $R0
Push $R1

ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion

IfErrors 0 lbl_winnt

; we are not NT
ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\Windows\CurrentVersion" VersionNumber

StrCpy $R1 $R0 1
StrCmp $R1 '4' 0 lbl_error

StrCpy $R1 $R0 3

StrCmp $R1 '4.0' lbl_win32_95
StrCmp $R1 '4.9' lbl_win32_ME lbl_win32_98

lbl_win32_95:
StrCpy $R0 '95'
Goto lbl_done

lbl_win32_98:
StrCpy $R0 '98'
Goto lbl_done

lbl_win32_ME:
StrCpy $R0 'ME'
Goto lbl_done

lbl_winnt:

StrCpy $R1 $R0 1

StrCmp $R1 '3' lbl_winnt_x
StrCmp $R1 '4' lbl_winnt_x

StrCpy $R1 $R0 3

StrCmp $R1 '5.0' lbl_winnt_2000
StrCmp $R1 '5.1' lbl_winnt_XP
StrCmp $R1 '5.2' lbl_winnt_2003 lbl_error

lbl_winnt_x:
StrCpy $R0 "NT $R0" 6
Goto lbl_done

lbl_winnt_2000:
Strcpy $R0 '2000'
Goto lbl_done

lbl_winnt_XP:
Strcpy $R0 'XP'
Goto lbl_done

lbl_winnt_2003:
Strcpy $R0 '2003'
Goto lbl_done

lbl_error:
Strcpy $R0 ''
lbl_done:

Pop $R1
Exch $R0

FunctionEnd


you should call this function in your section, here's your code:

Section "your_section" your_section_id
Call GetWindowsVersion
Exch $0
StrCmp $0 "noNT" 0 NT
File /a "D:\MPC9598ME"
Goto done
NT:
File /a "D:\MPCXP"
done:
Pop $0
SectionEnd

Function GetWindowsVersion
Push $0
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
IfErrors 0 NT
StrCpy $0 "noNT"
Goto done
NT:
StrCpy $0 "NT"
done:
Exch $0
FunctionEnd

that's all you need, to difference between winnt-systems (windows nt/xp/2003) and win98-systems (windows 95/98/se/me).


Functions are to be called in a Section. So in a Section, use the command Call and use StrCmp and File commands to choose what file each one do. Example (Get the code behind "Section" commands and put inside your section if you already have one):

Section

Call GetWindowsVersion
Pop $0

StrCmp $0 "95" +3
StrCmp $0 "98" +2
StrCmp $0 "ME" 0 XPFile

File /a "D:\MPC9598ME"
Goto End

XPFile:

StrCmp $0 "XP" 0 NotAvailable

File /a "D:\MPCXP"
Goto End

NotAvailable:

; Put a message if you want to warn
; who is not using Win 95, 98, ME or XP.

End:

; Other codes

SectionEnd


You can use the Comm@nder21's code if you know your program works for all 64-bits Operation Systems.