|
-
May 25th, 2004, 08:32 AM
#1
Determine the type of Server
I need to determine the type of server that my software will be running on, I can determine if it is NT, 2000 or XP. But now I need to determine if it is a Domain Controller. Any help in how to determine this would be great.
Last edited by skippycal; May 25th, 2004 at 09:36 AM.
-
May 25th, 2004, 08:34 AM
#2
Check out the NetServerGetInfo() function, there should be flags in there that will give you the info you need.
From MSDN:
Code:
#ifndef UNICODE
#define UNICODE
#endif
#include <stdio.h>
#include <windows.h>
#include <lm.h>
int wmain(int argc, wchar_t *argv[])
{
DWORD dwLevel = 101;
LPSERVER_INFO_101 pBuf = NULL;
NET_API_STATUS nStatus;
LPTSTR pszServerName = NULL;
if (argc > 2)
{
fwprintf(stderr, L"Usage: %s [\\\\ServerName]\n", argv[0]);
exit(1);
}
// The server is not the default local computer.
//
if (argc == 2)
pszServerName = argv[1];
//
// Call the NetServerGetInfo function, specifying level 101.
//
nStatus = NetServerGetInfo(pszServerName,
dwLevel,
(LPBYTE *)&pBuf);
//
// If the call succeeds,
//
if (nStatus == NERR_Success)
{
//
// Check for the type of server.
//
if ((pBuf->sv101_type & SV_TYPE_DOMAIN_CTRL) ||
(pBuf->sv101_type & SV_TYPE_DOMAIN_BAKCTRL) ||
(pBuf->sv101_type & SV_TYPE_SERVER_NT))
printf("This is a server\n");
else
printf("This is a workstation\n");
}
//
// Otherwise, print the system error.
//
else
fprintf(stderr, "A system error has occurred: %d\n", nStatus);
//
// Free the allocated memory.
//
if (pBuf != NULL)
NetApiBufferFree(pBuf);
return 0;
}
-
May 25th, 2004, 08:56 AM
#3
thanks, I found a better way using OSVERSIONINFOEX. But thank you for your help
Last edited by skippycal; May 25th, 2004 at 10:32 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|