Solved

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

Posted on 1998-09-24
7
396 Views
Last Modified: 2013-11-20
MFC App. Need to find OS, such as NT, 95, or 98. Any API? Also need to find subnet mask.
0
Comment
Question by:ames
  • 3
  • 3
7 Comments
 
LVL 2

Expert Comment

by:kinkajou
ID: 1322561
To get the version information use GetVersionEx().
0
 
LVL 86

Accepted Solution

by:
jkr earned 200 total points
ID: 1322562
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
 
LVL 2

Expert Comment

by:kinkajou
ID: 1322563
That will explain why I couldn't find an API function to get teh subnet mask.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:jkr
ID: 1322564
The 'inofficial' location of the subnet mask is HKLM\System\CurrentControlSet\Services\<Network Adapter Name>\Parameters\Tcpip
0
 
LVL 2

Expert Comment

by:kinkajou
ID: 1322565
Cool, thanks. How does one go about getting the <Network Adapter Name>? Is there an API call or say a device look-up?
0
 
LVL 86

Expert Comment

by:jkr
ID: 1322566
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
 

Author Comment

by:ames
ID: 1322567
There could be multiple network adapters and hence many subnet masks. I used ipconfig or winipcfg. Thanks.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question