Hi,

how can I detect, if my windows system is Windows XP or higher ?

Greetings,
Nordwind64
Posted on 2003-08-31 23:47:27 by Nordwind64
OSSpecific PROC

LOCAL osvi :OSVERSIONINFO

mov osvi.dwOSVersionInfoSize,SIZEOF OSVERSIONINFO
invoke GetVersionEx,ADDR osvi
.IF osvi.dwPlatformId == VER_PLATFORM_WIN32_NT
.IF osvi.dwMajorVersion >= 5 ; >Win2K
.IF osvi.dwMinorVersion >= 1
; this is XP or better
.ENDIF
.endif
.ENDIF

ret
OSSpecific ENDP
Posted on 2003-09-01 00:09:08 by donkey
Hello,

thank you, donkey !!!
You're really the best !

Thanks,
Nordwind64
Posted on 2003-09-01 12:54:08 by Nordwind64
Hi again,

hmm, and how can I detect, if the programm has a Windows XP Manifest resource ?
My code is a dll function, and I wish to know it from the exe.

Greetings,
Nordwind64
Posted on 2003-09-02 14:44:16 by Nordwind64
This should work if you do not want to actually run the dll. You can examine the resource if you like but the only real manifest is the XP manifest.
mov ManifestFlag,FALSE

invoke LoadLibraryEx,ADDR FilePath,NULL,LOAD_LIBRARY_AS_DATAFILE
mov hModule,eax
.IF eax != NULL
invoke EnumResourceTypes,hModule,OFFSET ResTypeEnumFunction,ADDR ManifestFlag
.ENDIF
invoke FreeLibrary,hModule

ResTypeEnumFunction proc hModule:DWORD,lpszType:DWORD,lParam:DWORD

.IF lpszType == RT_MANIFEST
mov eax,lParam
mov DWORD PTR [eax],TRUE
mov eax,FALSE
.ELSE
mov eax,TRUE
.ENDIF

ret
ResTypeEnumFunction endp
Posted on 2003-09-02 15:21:32 by donkey
	.IF osvi.dwMajorVersion >= 5 ; >Win2K 

.IF osvi.dwMinorVersion >= 1
; this is XP or better
.ENDIF
.endif
So version 6.0 is no good?
Posted on 2003-09-02 17:34:01 by tenkey

So version 6.0 is no good?

What version of Windows reports 6 ? I don't know of any at all that do though I haven't tried 2003, that may return 6 as it's major version.
Posted on 2003-09-02 17:40:00 by donkey
Hi,

hmm.
Isn't it better to check the version of Comctl32.dll ? It seems, version 6.00 only exists, if program is in manifest status.
I will check this website if I came from work to get an answer...

Greetings,
Nordwind
Posted on 2003-09-02 23:54:17 by Nordwind64
If the program is not running then Comctl32 v6 will not be loaded. As I had said in my post it was to be able to verify the existence of a manifest without having to run the program. You did not say that you were testing for it in the current process.

The other thing is that I'm not sure what your program will return for another application if you are using version 6. At any rate I would prefer to look directly at the executable (or DLL) than to trust the value returned by Windows, it is sometimes a bit strange where Windows get's it's values.
Posted on 2003-09-03 02:09:16 by donkey
Returns TRUE if Common controls 6 is loaded:
CheckLibVersion proc

LOCAL LibVersion :DLLVERSIONINFO
LOCAL pComCtrllib :DWORD
LOCAL pGetVersion :DWORD

jmp @F
LibName BYTE "comctl32.dll",0
FuncName BYTE "DllGetVersion",0
@@:

mov LibVersion.cbSize,SIZEOF DLLVERSIONINFO
invoke LoadLibrary,ADDR LibName
mov pComCtrllib,eax
.IF eax != NULL
invoke GetProcAddress,pComCtrllib,ADDR FuncName
mov pGetVersion,eax
.IF eax != NULL
lea eax,LibVersion
push eax
call pGetVersion
.ENDIF
invoke FreeLibrary,pComCtrllib
.ENDIF

.IF LibVersion.dwMajorVersion == 6
mov eax,TRUE
.ELSE
mov eax,FALSE
.endif
ret
CheckLibVersion endp
Posted on 2003-09-03 02:14:30 by donkey
Hi,

yeeeees, it works !!!!!!!
Wow donkey, are really really the best !

...if the program is not running then Comctl32 v6 will not be loaded. As I had said in my post it was to be able to verify the existence of a manifest without having to run the program. You did not say that you were testing for it in the current process.


Yes, you are right, sorry...
My problem is, my English is very poor.
I want to give more details in my postings, but I can not find the right english words to do that...

Sorry again und have much thanks !!!

Greetings,
Nordwind64
Posted on 2003-09-03 09:53:46 by Nordwind64

What version of Windows reports 6 ? I don't know of any at all that do though I haven't tried 2003, that may return 6 as it's major version.
A lot of Win16 programs broke when Win95 was being developed, due to this kind of faulty logic. The 95 developers had to kludge the version number to get the old programs to run. Who knows when MS will up the Windows version to 6.0? If and when they do, the code will break. (It's probably a very big IF right now, but who knows?)

More robust code...
    ; Use 64-bit subtract to compare OS version number

mov eax,osvi.dwMinorVersion
mov ecx,osvi.dwMajorVersion
sub eax,1
sbb ecx,5
jb TooEarly
Posted on 2003-09-03 17:46:03 by tenkey
Windows Server 2003 >> NT 5.2

Windows Longhorn XP ( this is just the beta state codename at least ) >> NT 6.0

Bye! :D
Posted on 2003-10-02 08:37:43 by sheroc