윈도우즈의 작업 그룹명을 얻어옵니다...
#include <lm.h>
#pragma comment (lib,"netapi32.lib")
typedef NET_API_STATUS (WINAPI *FNetWkstaGetInfo)(LPWSTR, DWORD, LPBYTE *);
typedef NET_API_STATUS (WINAPI *FNetApiBufferFree)(LPVOID);
BOOL GetWorkGroupName(LPTSTR lpszGroupName, UINT iLen)
{
BOOL bRet = FALSE; memset(lpszGroupName, 0, iLen);
//NT
if (GetVersion() < 0x80000000)
{
HINSTANCE hDll = NULL;
BOOL bLoad = FALSE;
FNetWkstaGetInfo fnNetWkstaGetInfo = NULL;
FNetApiBufferFree fnNetApiBufferFree = NULL;
bLoad = GetProcAddresses( &hDll
, "netapi32.dll"
, 2
, &fnNetWkstaGetInfo
, "NetWkstaGetInfo"
, &fnNetApiBufferFree
, "NetApiBufferFree");
if (bLoad == TRUE)
{
WKSTA_INFO_102 *pBuf = NULL;
NET_API_STATUS nStatus;
nStatus = fnNetWkstaGetInfo(NULL, 102, (LPBYTE *) & pBuf);
if (nStatus == NERR_Success)
{
wcstombs(lpszGroupName, (PCWSTR)pBuf->wki102_langroup, iLen);
bRet = TRUE;
}
if (pBuf != NULL)
fnNetApiBufferFree(pBuf);
FreeLibrary(hDll);
}
}
// 9X
else
{
HKEY hKey;
DWORD dwType = REG_SZ;
DWORD dwSize = iLen;
LONG lRet;
lRet = RegOpenKeyEx( HKEY_LOCAL_MACHINE
, "System\\CurrentControlSet\\Services\\VxD\\VNETSUP"
, 0
, KEY_READ
, &hKey);
if (lRet == ERROR_SUCCESS)
{
lRet = RegQueryValueEx( hKey
, "Workgroup"
, 0
, &dwType
, (LPBYTE) lpszGroupName
, &dwSize);
bRet = (lRet == ERROR_SUCCESS);
RegCloseKey(hKey);
}
}
return bRet;
}