Gathering information about a workstation | CodeGuru

Gathering information about a workstation

. Some times you need information about a workstation, for example if you want to know if a workstation is not running WindowsNT and you try some NT-specific job without any chance. I think this pseudo-routine can be helpful. #include /*Usually: #include #include #include #include */ // Network API job – […]

Written By
CodeGuru Staff
CodeGuru Staff
Jun 8, 1999
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

.

Some times you need information about a workstation, for example if you want to know if
a workstation is not running WindowsNT and you try some NT-specific job without any
chance. I think this pseudo-routine can be helpful.

#include <what_you_need.h>
/*Usually:
#include <lmcons.h>
#include <lmwksta.h>
#include <lmserver.h>
#include <lmerr.h>*/
//	Network API job – obtain network info about selected machine.
BOOL
_GetWkstaInformation100()
{
	LPBYTE lpBuf;
	LPCSTR lpcstrWkstaName = (LPCSTR)m_strWkstaName;
	int iwLength = 2 * (MAX_COMPUTERNAME_LENGTH + 1);
	WCHAR lpwWkstaName[2 * (MAX_COMPUTERNAME_LENGTH + 1)];
	lpwWkstaName[0] = ‘’;
	MultiByteToWideChar(CP_ACP, 0, lpcstrWkstaName, -1, lpwWkstaName, iwLength);
	typedef NET_API_STATUS (NET_API_FUNCTION *NETWKPROC)(LPWSTR, DWORD, LPBYTE *);
	NETWKPROC _procNetWkstaGetInfo = (NETWKPROC)
		(GetProcAddress(theApp.m_hNetDLL, _T(“NetWkstaGetInfo”)));
	if(_procNetWkstaGetInfo)
	{
		NET_API_STATUS nasRetVal = (*_procNetWkstaGetInfo)(lpwWkstaName, 100, (LPBYTE*)&lpBuf);
		if(nasRetVal == NERR_Success)
		{
			WKSTA_INFO_100 *pWkstaInfo = (WKSTA_INFO_100 *)lpBuf;
			DWORD dwPlatformId = pWkstaInfo->wki100_platform_id;
			if(dwPlatformId != PLATFORM_ID_NT)
			{
				//[ERROR]Not a Windows NT Workstation – if useful.
				return FALSE;
			}
			else
			  return TRUE;
		}
		else
		{
			//[ERROR] System error. Call GetLastError, FormatMessage, etc.
			return FALSE;
		}
	}
	else
	{
		//[ERROR]Unable to find procedure NetWkstaGetInfo in netapi32.dll.
		return FALSE;
	}
}

History

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.