what i wanna do is to enumerate all the processes on a WinXP OS machine, but to do this i think that i must use PSAPI, right?

but i wanna make the prog to check the version before it goes on the enumeration...

can anybody help me?

jean (coder7345)
Posted on 2001-12-29 17:07:31 by coder
check if this works on xp
Posted on 2001-12-29 17:27:14 by grv575
Try this code,

LOCAL os :OSVERSIONINFO

mov os.dwOSVersionInfoSize,SIZEOF OSVERSIONINFO
invoke GetVersionEx,ADDR os
xor eax,eax
mov eax,os.dwMinorVersion ;get minor version operating system
mov dwVersion,eax

I use this to find if os is 98 or ME. I only checking the minor version number cuz the major version is the same: Win98 = 4.10 and Windows ME = 4.90 don't bother with the build number.

btw, the minor version is decimal number so I compare dwVersion to 0ah and to 05ah. Just plug in minor version number for XP providing major number is '4'

best regards,

czDrillard
Posted on 2001-12-29 18:10:35 by czDrillard
I don't know about WinXP but to check if OS is Win9x or WinNT this works:

xor ecx,ecx
mov cx,cs
xor cl,cl
jecxz WinNT

; Do win9x stuff
WinNT:
; do WinNT stuff
Posted on 2001-12-29 21:43:38 by Eagle17
Win XP is like 5. something or other :)
Posted on 2001-12-29 22:18:39 by Torch
Eagle17, you should better rely on documented ways to detect
windows version.

Look up GetVersion(Ex), it's the right way to do this.

Also, if you're going to check for windows version, do it properly.
If you only check minor version, you might as well skip the checks
entirely, as you risk up misdetecting a future windows version as
something else.

As for toolhelp32 vs. psapi... if you want 9x compatibility (blah),
use toolhelp32 - otherwise use psapi.
Posted on 2001-12-30 02:49:59 by f0dder
I know it would be a lot smarter to rely on documented ways to detect Win9x or WinNT, I just like to use a lot of the undocumented features of windows. The GetVersionEx way is a lot cleaner and probably more supported, I was just sharing an alternate way ;)
Posted on 2001-12-30 13:59:29 by Eagle17
Here's a nice piece of code from PlatformSDK:


#include <windows.h>
#include <stdio.h>

BOOL DisplaySystemVersion()
{
OSVERSIONINFOEX osvi;
BOOL bOsVersionInfoEx;

// Try calling GetVersionEx using the OSVERSIONINFOEX structure.
//
// If that fails, try using the OSVERSIONINFO structure.

ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
{
// If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.

osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
return FALSE;
}

switch (osvi.dwPlatformId)
{
case VER_PLATFORM_WIN32_NT:

// Test for the product.

if ( osvi.dwMajorVersion <= 4 )
printf("Microsoft Windows NT ");

if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
printf ("Microsoft Windows 2000 ");

if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
printf ("Microsoft Windows XP ");

// Test for product type.

if( bOsVersionInfoEx )
{
if ( osvi.wProductType == VER_NT_WORKSTATION )
{
if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
printf ( "Personal " );
else
printf ( "Professional " );
}

else if ( osvi.wProductType == VER_NT_SERVER )
{
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
printf ( "DataCenter Server " );
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
printf ( "Advanced Server " );
else
printf ( "Server " );
}
}
else
{
HKEY hKey;
char szProductType[80];
DWORD dwBufLen;

RegOpenKeyEx( HKEY_LOCAL_MACHINE,
"SYSTEM\\CurrentControlSet\\Control\\ProductOptions",
0, KEY_QUERY_VALUE, &hKey );
RegQueryValueEx( hKey, "ProductType", NULL, NULL,
(LPBYTE) szProductType, &dwBufLen);
RegCloseKey( hKey );
if ( lstrcmpi( "WINNT", szProductType) == 0 )
printf( "Professional " );
if ( lstrcmpi( "LANMANNT", szProductType) == 0 )
printf( "Server " );
if ( lstrcmpi( "SERVERNT", szProductType) == 0 )
printf( "Advanced Server " );
}

// Display version, service pack (if any), and build number.

if ( osvi.dwMajorVersion <= 4 )
{
printf ("version %d.%d %s (Build %d)\n",
osvi.dwMajorVersion,
osvi.dwMinorVersion,
osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF);
}
else
{
printf ("%s (Build %d)\n",
osvi.szCSDVersion,
osvi.dwBuildNumber & 0xFFFF);
}
break;

case VER_PLATFORM_WIN32_WINDOWS:

if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
{
printf ("Microsoft Windows 95 ");
if ( osvi.szCSDVersion[1] == 'C' || osvi.szCSDVersion[1] == 'B' )
printf("OSR2 " );
}

if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
{
printf ("Microsoft Windows 98 ");
if ( osvi.szCSDVersion[1] == 'A' )
printf("SE " );
}

if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
{
printf ("Microsoft Windows Me ");
}
break;

case VER_PLATFORM_WIN32s:

printf ("Microsoft Win32s ");
break;
}
return TRUE;
}

Posted on 2001-12-30 14:09:05 by bazik