Link to home
Start Free TrialLog in
Avatar of sunil_vee
sunil_vee

asked on

How to know Nt/win95-98 programatically?

Hello,
    For my application, i am creating two exes separately for win 95/98 and windowsNT since i need to execute some part of the code depending on the OS. Is there any macro to know whether the machine is running NT or windows 95/98., so that i can have single exe for both.
  I would be thankful if anybody can help me out in this case.

regards,
sunil
Avatar of pkkn
pkkn

Hai Sunil,

Try It.
define the following


#define  IS_NT (BOOL)(GetVersion() < 0x80000000)&& (LOBYTE(LOWORD
(GetVersion())) <= 4)

#define     IS_WIN95      (BOOL)(!(IS_NT) && ((DWORD)(HIBYTE(LOWORD(GetVersion())))==0)

#define     IS_WIN98      (BOOL)(!(IS_NT) && ((DWORD)(HIBYTE(LOWORD(GetVersion())))>0)

And check the value,

if(IS_NT)
{
//OS is Win NT
}

if(IS_WIN98)
{
//OS is WIN95
}


if(IS_WIN95)
{
//OS is WIN98
}

ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
hmm, too late      :(
PJ Naughter has the best solution I've seen. And it's free, handles Win2000 etc

get it from his web site.

http://www.naughter.com/dtwinver.html

From that page description:

>>>>
DtWinVer is a routine which provides a comprehensive method to determine which OS the program that calls it is running on. All methods it uses are fully documented on various articles on the MSDN CD. The routine provides the emulated OS aswell as the underlying OS. e.g. to a Dos program Windows 95 looks like MS-DOS 7.0. A full list of the OS’s it can detect are:

Dos
Windows 3.0
Windows 3.1
Windows 3.11
Windows for Workgroups
Win32s (if you can call this an OS <g>)
Windows CE 1.0  
Windows CE 2.0
Windows CE 2.1
Windows CE 2.11
Windows CE 3.0
Windows 95
Windows 95 Service Pack 1
Windows 95 OEM Service Release 2
Windows 98
Windows 98 Service Pack 1
Windows 98 Second Edition
NT Workstation, Server 3.1
NT Workstation, Server, PDC, BDC 3.5
NT Workstation, Server, PDC, BDC 3.51
NT Workstation, Server, PDC, BDC 4.0
Windows 2000 Professional
Windows 2000 Server / Advanced Server
Windows NT Terminal Server
Windows NT Enterprise Edition
Some of the possible scenarios it can report on are:

"You are running an emulated Dos v5.50 On NT"
"You are running an emulated Windows 3.95 on Windows 95 v4.0 Build 950"
"You are running Windows for Workgroups on Dos v6.22"
"You are running NT Server v3.51"
 

Have you ever wanted to determine if you are running under Windows 95 or NT from a 16 bit app. Here's the answer, this routine can return such information as:

"You are running an emulated Dos v5.50 On NT"
"You are running an emulated Windows 3.95 on Windows 95 v4.0 Build 950"
"You are running Windows for Workgroups on Dos v6.22"
"You are running NT Server v3.51"
"You are running an application on Windows NT Terminal Server.
This NT machine is acting as a stand alone server, primary domain controller or backup domain controller.

>>>

Avatar of sunil_vee

ASKER

Answer not satisfactory. I want to consider Zoppo's comment as the answer
What is not satifactory about it?  It gives you all the info about what OS you are running on.  And is quite easy to use.