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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
jkrConnect With a Mentor Commented:
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
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
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
All Courses

From novice to tech pro — start learning today.