• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 186
  • Last Modified:

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
0
sunil_vee
Asked:
sunil_vee
1 Solution
 
pkknCommented:
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
}

0
 
ZoppoCommented:
Hi sunil_vee,

try this:


....
OSVERSIONINFO      os;
os.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
GetVersionEx(&os);
switch( os.dwPlatformId )
{
 case( VER_PLATFORM_WIN32s ):
  // do what you want when Win3.1 with Win32s is running...
  break;
 case( VER_PLATFORM_WIN32_WINDOWS ):
  // do what you want when Win95/98 is running...
  break;
 case( VER_PLATFORM_WIN32_NT ):
  // do what you want when WinNT/2000 is running...
  break;
}
....

hope that helps,

ZOPPO
0
 
ZoppoCommented:
hmm, too late      :(
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
RONSLOWCommented:
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.

>>>

0
 
sunil_veeAuthor Commented:
Answer not satisfactory. I want to consider Zoppo's comment as the answer
0
 
RONSLOWCommented:
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.
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Tackle projects and never again get stuck behind a technical roadblock.
Join Now