Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Determining OS

53 views
Skip to first unread message

Dave Roscoe

unread,
Nov 21, 1997, 3:00:00 AM11/21/97
to

How can I determine which operting system I am running on (Win 95 or NT4.0)
Also, how can I check to see if Service Pack 3 is installed?

Please e-mail only..

Dave
dro...@inet911.com


Justin Rogers

unread,
Nov 21, 1997, 3:00:00 AM11/21/97
to

I would use the GetVersionEx function...

And here is some sample code I found in the MSDN. To test for SP3 you may
have to check build numbers

#include <windows.h>
void main()
{
DWORD dwVersion;
char szVersion[80];
dwVersion = GetVersion();
if (dwVersion < 0x80000000) {
// Windows NT
wsprintf (szVersion, "Microsoft Windows NT %u.%u (Build: %u)",
(DWORD)(LOBYTE(LOWORD(dwVersion))),
(DWORD)(HIBYTE(LOWORD(dwVersion))),
(DWORD)(HIWORD(dwVersion)));
}
else if (LOBYTE(LOWORD(dwVersion))<4) {
// Win32s
wsprintf (szVersion, "Microsoft Win32s %u.%u (Build: %u)",
(DWORD)(LOBYTE(LOWORD(dwVersion))),
(DWORD)(HIBYTE(LOWORD(dwVersion))),
(DWORD)(HIWORD(dwVersion) & ~0x8000));
} else {
// Windows 95
wsprintf (szVersion, "Microsoft Windows 95 %u.%u (Build: %u)",
(DWORD)(LOBYTE(LOWORD(dwVersion))),
(DWORD)(HIBYTE(LOWORD(dwVersion))),
(DWORD)(HIWORD(dwVersion) & ~0x8000));
}
MessageBox( NULL, szVersion, "Version Check", MB_OK );
}

Dave Roscoe wrote in message <655cg6$g7q$1...@newsfep4.sprintmail.com>...

end


Justin Rogers.vcf

Felix Kasza [MVP]

unread,
Nov 22, 1997, 3:00:00 AM11/22/97
to

Dave,

> How can I determine which operting system I am running on (Win 95 or NT4.0)
> Also, how can I check to see if Service Pack 3 is installed?

Call GetVersionEx(). To check for service packs, you'll have to parse
the szCSDVersion string -- it looks like "Service Pack %d", if an SP
is installed.

Cheers,
Felix.

--
If you post a reply, kindly refrain from emailing it, too.

Bill Potvin, II

unread,
Nov 22, 1997, 3:00:00 AM11/22/97
to

This is a multi-part message in MIME format.

------=_NextPart_000_0048_01BCF720.881D5890
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Dave Roscoe wrote in message <655cg6$g7q$1...@newsfep4.sprintmail.com>...
>

>How can I determine which operting system I am running on (Win 95 or =


NT4.0)
>Also, how can I check to see if Service Pack 3 is installed?
>

[clip]

Try the following:
-------------------------------------------------------------------------=
-------#define WIN32_LEAN_AND_MEAN#include <windows.h>
#include <stdio.h>
BOOL __x_getversionstring ( LPSTR Buffer, ULONG BufferSize ) { =
OSVERSIONINFO osv; CHAR SystemName[64];
osv.dwOSVersionInfoSize =3D sizeof(OSVERSIONINFO); if( =
!GetVersionEx(&osv)) { return FALSE; }
switch(osv.dwPlatformId) { case VER_PLATFORM_WIN32s: =
strcpy(SystemName,"Win32s"); break;
case VER_PLATFORM_WIN32_WINDOWS: =
strcpy(SystemName,"Windows"); break;
case VER_PLATFORM_WIN32_NT: =
strcpy(SystemName,"Windows NT"); break;
default: =
sprintf(SystemName,"[Unknown:%x]",osv.dwPlatformId); break; =
}
/** * For some reason, Win95 has everything encoded in the * =
dwBuildNumber field. So, for Win95 ONLY: * * =
HIBYTE(HIWORD(osv.dwBuildNumber) -> Major Version * =
LOBYTE(HIWORD(osv.dwBuildNumber) -> Minor Version * *** =
LOWORD(osv.dwBuildNumber) -> Build Number * * The =
dwMajorVersion and dwMinorVersion fields in the structure * are =
correct for Win95, so the only reason for the contortions * is to =
get the correct Build Number. * * The szCSDVersion field =
contains miscellaneous information * such as Service Pack =
applications. * */ _snprintf( Buffer, BufferSize, "%s Version =
%u.%u (Build: %u)", SystemName, osv.dwMajorVersion, =
osv.dwMinorVersion, (osv.dwPlatformId =3D=3D =
VER_PLATFORM_WIN32_WINDOWS)? =
LOWORD(osv.dwBuildNumber):osv.dwBuildNumber );
if( strlen(osv.szCSDVersion) > 0 ) { =
_snprintf(Buffer,BufferSize,"%s %s",Buffer,osv.szCSDVersion); }
return TRUE; }
int main ( int argc, char *argv[] ) { CHAR Buffer[MAX_PATH];
if( __x_getversionstring(Buffer,sizeof(Buffer))) { =
printf("Version: %s\n",Buffer); } else { =
printf("Error:%x\n",GetLastError()); }
return ERROR_SUCCESS; =
}------------------------------------------------------------------------=
--------
regards,
bill.
Bill Potvin, II
bpo...@merxsoft.com
http://www.merxsoft.com


------=_NextPart_000_0048_01BCF720.881D5890
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3Dtext/html;charset=3Diso-8859-1 =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.71.1712.3"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>Dave Roscoe<DRO...@INET911.COM> wrote in message &lt;<A=20
href=3D"mailto:655cg6$g7q$1...@newsfep4.sprintmail.com">655cg6$g7q$1@newsfep=
4.sprintmail.com</A>&gt;...</DIV>
<DIV>&gt;&nbsp;</DIV>
<DIV>&gt;How can I determine which operting system I am running on (Win =
95 or=20
NT4.0)<BR>&gt;Also, how can I check to see if Service Pack 3 is=20
installed?<BR>&gt;<BR>[clip]&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Try the following:</DIV><PRE><FONT color=3D#0000ff face=3D"" =
size=3D2><HR>#define WIN32_LEAN_AND_MEAN<BR>#include =
&lt;windows.h&gt;</FONT>&nbsp;</PRE><PRE><FONT color=3D#0000ff face=3D"" =
size=3D2>#include &lt;stdio.h&gt;</FONT></PRE><PRE><FONT color=3D#0000ff =
face=3D"" size=3D2><BR>BOOL __x_getversionstring (<BR> LPSTR Buffer,<BR> =
ULONG BufferSize )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; =
OSVERSIONINFO osv;<BR>&nbsp;&nbsp;&nbsp; CHAR =
SystemName[64];</FONT>&nbsp;</PRE><PRE><FONT color=3D#0000ff face=3D"" =
size=3D2>&nbsp;&nbsp;&nbsp; osv.dwOSVersionInfoSize =3D =
sizeof(OSVERSIONINFO);<BR>&nbsp;&nbsp;&nbsp; if( =
!GetVersionEx(&amp;osv))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return =
FALSE;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}</FONT>&nbsp;</PRE><PRE><FONT color=3D#0000ff face=3D"" =
size=3D2>&nbsp;&nbsp;&nbsp; =
switch(osv.dwPlatformId)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case =
VER_PLATFORM_WIN32s:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp; =
strcpy(SystemName,&quot;Win32s&quot;);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;</FONT>&nbsp;</PRE><PRE><FONT =
color=3D#0000ff face=3D"" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case =
VER_PLATFORM_WIN32_WINDOWS:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp; =
strcpy(SystemName,&quot;Windows&quot;);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;</FONT>&nbsp;</PRE><PRE><FONT =
color=3D#0000ff face=3D"" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case =
VER_PLATFORM_WIN32_NT:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp; strcpy(SystemName,&quot;Windows =
NT&quot;);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp; break;</FONT>&nbsp;</PRE><PRE><FONT color=3D#0000ff face=3D"" =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
default:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp; =
sprintf(SystemName,&quot;[Unknown:%x]&quot;,osv.dwPlatformId);<BR>&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
break;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}</FONT>&nbsp;</PRE><PRE><FONT color=3D#0000ff face=3D"" =
size=3D2>&nbsp;&nbsp;&nbsp; /**<BR>&nbsp;&nbsp;&nbsp;&nbsp; * For some =
reason, Win95 has everything encoded in the<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
* dwBuildNumber field.&nbsp; So, for Win95 =
ONLY:<BR>&nbsp;&nbsp;&nbsp;&nbsp; *<BR>&nbsp;&nbsp;&nbsp;&nbsp; * =
HIBYTE(HIWORD(osv.dwBuildNumber) -&gt; Major =
Version<BR>&nbsp;&nbsp;&nbsp;&nbsp; * LOBYTE(HIWORD(osv.dwBuildNumber) =
-&gt; Minor Version<BR>&nbsp;&nbsp;&nbsp;&nbsp; * *** =
LOWORD(osv.dwBuildNumber)&nbsp;&nbsp;&nbsp; -&gt; Build =
Number<BR>&nbsp;&nbsp;&nbsp;&nbsp; *<BR>&nbsp;&nbsp;&nbsp;&nbsp; * The =
dwMajorVersion and dwMinorVersion fields in the =
structure<BR>&nbsp;&nbsp;&nbsp;&nbsp; * are correct for Win95, so the =
only reason for the contortions<BR>&nbsp;&nbsp;&nbsp;&nbsp; * is to get =
the correct Build Number.<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
*<BR>&nbsp;&nbsp;&nbsp;&nbsp; * The szCSDVersion field contains =
miscellaneous information<BR>&nbsp;&nbsp;&nbsp;&nbsp; * such as Service =
Pack applications.<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
*<BR>&nbsp;&nbsp;&nbsp;&nbsp; */<BR>&nbsp;&nbsp;&nbsp; _snprintf( =
Buffer, BufferSize, &quot;%s Version %u.%u (Build: =
%u)&quot;,<BR>&nbsp;&nbsp;&nbsp;&nbsp; SystemName, osv.dwMajorVersion, =
osv.dwMinorVersion,<BR>&nbsp;&nbsp;&nbsp;&nbsp; (osv.dwPlatformId =3D=3D =
VER_PLATFORM_WIN32_WINDOWS)?<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
LOWORD(osv.dwBuildNumber):osv.dwBuildNumber =
);</FONT>&nbsp;</PRE><PRE><FONT color=3D#0000ff face=3D"" =
size=3D2>&nbsp;&nbsp;&nbsp; if( strlen(osv.szCSDVersion) &gt; 0 =
)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
_snprintf(Buffer,BufferSize,&quot;%s =
%s&quot;,Buffer,osv.szCSDVersion);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp; }</FONT>&nbsp;</PRE><PRE><FONT color=3D#0000ff face=3D"" =
size=3D2>&nbsp;&nbsp;&nbsp; return TRUE;<BR>&nbsp;&nbsp;&nbsp; =
}</FONT>&nbsp;</PRE><PRE><FONT color=3D#0000ff face=3D"" =
size=3D2><BR>int main (<BR> int argc,<BR> char *argv[] =
)<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; CHAR =
Buffer[MAX_PATH];</FONT>&nbsp;</PRE><PRE><FONT color=3D#0000ff face=3D"" =
size=3D2>&nbsp;&nbsp;&nbsp; if( =
__x_getversionstring(Buffer,sizeof(Buffer)))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
printf(&quot;Version: =
%s\n&quot;,Buffer);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}<BR>&nbsp;&nbsp;&nbsp; =
else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
printf(&quot;Error:%x\n&quot;,GetLastError());<BR>&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp; }</FONT>&nbsp;</PRE><PRE><FONT color=3D#0000ff =
face=3D"Lucida Console" size=3D2>&nbsp;&nbsp;&nbsp; return =
ERROR_SUCCESS;<BR>&nbsp;&nbsp;&nbsp; }</FONT><BR><HR></PRE>
<DIV><FONT color=3D#000000>regards,</FONT></DIV>
<DIV><FONT color=3D#000000>bill.</FONT></DIV>
<DIV><FONT color=3D#000000>Bill Potvin, II<BR><A=20
href=3D"mailto:bpo...@merxsoft.com">bpo...@merxsoft.com</A><BR><A=20
href=3D"http://www.merxsoft.com">http://www.merxsoft.com</A><BR></FONT>&n=
bsp;</DIV></BODY></HTML>

------=_NextPart_000_0048_01BCF720.881D5890--


Nico Cuppen

unread,
Nov 22, 1997, 3:00:00 AM11/22/97
to

Try GetVersionEx(..)

Nico Cuppen
ncu...@pi.net


Dave Roscoe heeft geschreven in bericht
<655cg6$g7q$1...@newsfep4.sprintmail.com>...
>How can I determine which operting system I am running on (Win 95 or NT4.0)


>Also, how can I check to see if Service Pack 3 is installed?
>

Dave Roscoe

unread,
Nov 24, 1997, 3:00:00 AM11/24/97
to

Thanx for your responses.. I am sure they will do the trick..

-Dave


0 new messages