Help to get/set workgroup in Win2K/NT
Can you help me? How to get workgroup name on the Windows2000/NT by VC++ system calls? Due to the security of 2000/NT operating system, the workgroup(not domain) name was saved inside local Sam database, I want to know how to extract the data from the System..
Any help will be great appreciated...
Re: Help to get/set workgroup in Win2K/NT
Hi Chris!
How to get my workgroup?
The following code get workgroup from local computer using the NetWkstaGetInfo() function.
1. Import file (Netapi32.lib).
2. include file (lm.h).
Code:
BOOL GetWorkgroup(LPTSTR pszName)
{
DWORD dwLevel = 102;
LPWKSTA_INFO_102 pBuf = NULL;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
BOOL bRes=FALSE;
nStatus = NetWkstaGetInfo(NULL, dwLevel, (LPBYTE *)&pBuf);
if (nStatus == NERR_Success)
{
TCHAR szTemp[MAX_PATH]={'\0',};
int BufSize=sizeof(szTemp)/sizeof(TCHAR);
#ifdef UNICODE
_tcscpy(szTemp, pBuf->wki102_langroup);
#else
::WideCharToMultiByte(CP_ACP, 0, pBuf->wki102_langroup, -1, szTemp, BufSize, 0, 0);
#endif
lstrcpy(pszName, szTemp);
bRes=TRUE;
}
if (pBuf != NULL)
NetApiBufferFree(pBuf);
return bRes;
}
Re: Help to get/set workgroup in Win2K/NT
Hi ezway. Welcome to the forums. One thing to note before posting is how old a thread is. You posted on a 5 year old thread.
Please remember to post on more recent and relevant topics.
Re: Help to get/set workgroup in Win2K/NT
Awesome thank you, solved my problem!
Re: Help to get/set workgroup in Win2K/NT
I think ezway did the right thing.
Re: Help to get/set workgroup in Win2K/NT
Quote:
Originally Posted by
BitNinja
I think ezway did the right thing.
Yeah, this is the landmark to move on :D