I need to check the type of OS running I tried this but it does not work. Please help. Radim.
Posted on 2001-04-22 15:47:00 by raguru

.data?
WinVersionInfo OSVERSIONINFO 
.code
mov    WinVersionInfo.dwOSVersionInfoSize, SIZEOF OSVERSIONINFO
invoke GetVersionEx, ADDR WinVersionInfo 
This fills in a OSVERSIONINFO structure. Look it up in your reference to find out the meaning of it's members:

typedef struct _OSVERSIONINFO{  
    DWORD dwOSVersionInfoSize; 
    DWORD dwMajorVersion; 
    DWORD dwMinorVersion; 
    DWORD dwBuildNumber; 
    DWORD dwPlatformId; 
    TCHAR szCSDVersion[ 128 ]; 
} OSVERSIONINFO; 
Thomas
Posted on 2001-04-22 16:05:00 by Thomas
OK. Now it works but I tried than to use mov WinVersionInfo.dwPlatformId,verNumber ;I declared verNumber before. but It won't work. But his works good. Why? push WinVersionInfo.dwPlatformId pop verNumber than I use .IF verNumber == VER_PLATFORM_WIN32_WINDOWS push url9X pop url .ELSEIF verNumber == VER_PLATFORM_WIN32_NT push urlNT pop url .ENDIF but It stops compiler on Push url9X WHY? ; of course in url9X an NT is some path declared,. Please help I would send whole file It has 3 kb in ASM.
Posted on 2001-04-23 14:47:00 by raguru
mov WinVersionInfo.dwPlatformId,verNumber ;I declared verNumber before. but It won't work. But his works good. Why? push WinVersionInfo.dwPlatformId pop verNumber
mov WinVersionInfo.dwPlatformId, verNumber is a memory copy from the verNumber variable to the dwPlatformID value. But the mov opcode just doesn't allow this. It can move a value from memory into a register etc., but not mem to mem. So you'll either have to use push/pop, or mov eax, mem1/mov mem2, eax.
It stops compiler on Push url9X WHY? ; of course in url9X an NT is some path declared,.
How is url defined? is it a string, a dword variable? You can't push a string as a string is not a 4-byte value. Push can only push 2 byte or 4 byte values. What you want to do is either put the memory location of url9X into a dword variable, url, this is done by: mov url, offset url9X Or, copy the string to another string (if url is defined as a string or buffer): invoke lstrcpy, ADDR url, ADDR url9X It depends on how you have defined your variables. Thomas
Posted on 2001-04-23 15:29:00 by Thomas
raguru, I think this should help you.

How to Determine Windows Version
by Dolphinz
--------------------------------------------------------------------------------

SUMMARY

This article will explain how to get Microsoftr Windows version installed
on the system, using win32 assembly languaje.
The complete source code and program for this tutorial can be downloaded
from here : WinVer

THEORY

The GetVersionEx( ) function supersedes the GetVersion( ) used on windows 16 bits,
so futher new programs should use the new function to get windows version information.
The Win32 GetVersionEx( ) function returns information that a program can use
to identify the operating system.
Among those values are the major and minor revision numbers and a platform identifier.
With the introduction of Windows 98, it now takes a more involved logical
evaluation to determine which version of Windows is in use.

THE CODE

The listing below provides the data needed to evaluate the OSVERSIONINFO structure
which is filled by GetVersionEx( ) function.

             OSVERSIONINFO STRUCT
               dwOSVersionInfoSize  DWORD      ?
               dwMajorVersion       DWORD      ?
               dwMinorVersion           DWORD      ?
               dwBuildNumber            DWORD      ?
               dwPlatformId         DWORD      ?
               szCSDVersion             BYTE 128 dup (?)
             OSVERSIONINFO ENDS

OSVERSIONINFO structure

Now let's look to the elements of this structure:

dwOSVersionInfoSize
This member carries the memory size of the structure.
You need to set this to SIZE OSVERSIONINFO before calling the function.
dwMajorVersion
Identifies the major version number of the operating system.
dwMinorVersion
Identifies the minor version number of the operating system.
dwBuildNumber
Windows NT Identifies the build number of the operating system.
Windows 95 Identifies the build number of the operating system in the low-order word.
The hi-order word contains the major and minor version numbers.
dwPlatformId
Identifies the operating system platform, and it can be:

Valor  Plataforma

VER_PLATFORM_WIN32s         Win32s on Windows 3.1.
VER_PLATFORM_WIN32_WINDOWS      Win32  on Windows 95.
VER_PLATFORM_WIN32_NT       Win32  on Windows NT.

szCSDVersion

Windows NT Contains a null terminated string, such as "Service Pack 3".
If no Service Pack has been installed, the string is empty.
Windows 95 Contains a null terminated string, that provides arbitrary
information about the operating system.

ANALIZING THE CODE

Now let's look at this piece of code which shows the usage of of the
GetVersionEx( ) function in assembly languaje:

            .DATA
            ; Structures
            osver   OSVERSIONINFO

            .CODE
            mov     osver. dwVersionInfoSize, SIZE OSVERSIONINFO
            call    GetVersionExA, offset osver
            .if     eax==0
                    ; Error. Not able to get OS information
                    ret
            .endif

At this point, if the call to GetVersionEx() was successful, that's the return
value is different than NULL, then we have at OSVERSIONINFO data structure,
the information required, so we can check the returned information.

When using the GetVersionEx( ) function to determine whether your application
is running on a particular version of the operating system,
check for version numbers that are greater than or equal to
the desired version numbers.

This ensures that the test succeeds for later versions of the operating system.
For example, if your application requires Windows 98, use the following test:

            ; Set the size of OSVERSIONINFO
        ; and call the function
            mov     osver.dwOSVersionInfoSize, SIZE OSVERSIONINFO
            call    GetVersionExA, offset osver

            .if     (osver.dwPlatformId==VER_PLATFORM_WIN32_WINDOWS) &&
                    ((osver.dwMajorVersion>4) || ((osver.dwMajorVersion==4) &&
                    (osver.dwM
Posted on 2001-04-24 02:42:00 by forge
I wrote this code for a similar program a while back. I just happened to have the source on this computer. You may have to change a few things here and there as i pulled this out of a larger source. But it should help a little :)

.data
ninefive     db '95', 0
nineeight    db '98', 0
twothousand  db '2K', 0
milleniumed  db 'ME', 0
whist        db 'Whistler', 0
nt           db 'NT%i(%lu)', 0

.data?
vinfo        OSVERSIONINFO<>

;Get OS Version
    mov vinfo.dwOSVersionInfoSize, sizeof OSVERSIONINFO
    invoke GetVersionEx, offset vinfo
    cmp vinfo.dwPlatformId, VER_PLATFORM_WIN32_NT
    jne win95
    invoke wsprintf, addr osverbuff, offset nt, vinfo.dwMajorVersion, vinfo.dwBuildNumber
    jmp continue

win95:
    cmp vinfo.dwMinorVersion, 0
    jne win98
    invoke lstrcpy, addr osverbuff, offset ninefive
    jmp continue

win98:
    cmp vinfo.dwMinorVersion, 10
    jne win2K
    invoke lstrcpy, addr osverbuff, offset nineeight
    jmp continue

win2K:
    cmp vinfo.dwMajorVersion, 5
    jne winME
    invoke lstrcpy, addr osverbuff, offset twothousand
    jmp continue

winME:
    cmp vinfo.dwMinorVersion, 90
    jne whistler
    invoke lstrcpy, addr osverbuff, offset milleniumed
    jmp continue

whistler:
    invoke lstrcpy, addr osverbuff, offset whist
    jmp continue

continue:
;Do whatever you wish here. The version of windows running is
;now waiting in the 'osverbuff'. 
;Try something like this to test it:

invoke MessageBox,NULL,addr osverbuff,NULL,MB_OK+MB_ICONINFORMATION
Hope I wasn't to late to help. Nokturnal... This message was edited by Nokturnal, on 4/25/2001 3:42:21 PM
Posted on 2001-04-25 15:38:00 by Nokturnal
OK It has helped. thanx
Posted on 2001-04-25 16:08:00 by raguru