Any API call to find OS? Any API to find Subnet Mask?

MFC App. Need to find OS, such as NT, 95, or 98. Any API? Also need to find subnet mask.
amesAsked:
Who is Participating?
 
jkrCommented:
OSVERSIONINFO osviVerInfo;
osviVerInfo.dwOSVersionInfoSize = sizeof ( OSVERSIONINFO);
                  
GetVersionEx ( &osviVerInfo);

switch ( osviVerInfo.dwPlatformId)
{
 case VER_PLATFORM_WIN32_WINDOWS: // Win32 on Win95
      break;
 case VER_PLATFORM_WIN32_NT: // Win32 on WinNT
      break;
 case VER_PLATFORM_WIN32_WIN32sS: // Win32s on Win 3.x
      break;
}

as there's no 'official' API to obtain the netmask, i suggest running 'netstat -r' and analyzing its output
 
                  

0
 
kinkajouCommented:
To get the version information use GetVersionEx().
0
 
kinkajouCommented:
That will explain why I couldn't find an API function to get teh subnet mask.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
jkrCommented:
The 'inofficial' location of the subnet mask is HKLM\System\CurrentControlSet\Services\<Network Adapter Name>\Parameters\Tcpip
0
 
kinkajouCommented:
Cool, thanks. How does one go about getting the <Network Adapter Name>? Is there an API call or say a device look-up?
0
 
jkrCommented:
See 'HKLM\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Linkage\Route' (binary data). Only valid if 'LanmanWorkstation' is listed first in 'HKLM\SYSTEM\CurrentControlSet\Control\NetworkProvider\Order', alter it if not.
0
 
amesAuthor Commented:
There could be multiple network adapters and hence many subnet masks. I used ipconfig or winipcfg. Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.