=.=
sunorr
全部博文(50)
2010年(7)
2009年(43)
zhoujin8
haoyunkk
woyotest
lcltmac
分类: WINDOWS
2009-09-27 23:52:59
LSA_HANDLE GetPolicyHandle() { LSA_OBJECT_ATTRIBUTES ObjectAttributes; WCHAR SystemName[] = TEXT(""); USHORT SystemNameLength; LSA_UNICODE_STRING lusSystemName; NTSTATUS ntsResult; LSA_HANDLE lsahPolicyHandle; // Object attributes are reserved, so initialize to zeroes. ZeroMemory(&ObjectAttributes, sizeof(ObjectAttributes)); // Get a handle to the Policy object. ntsResult = LsaOpenPolicy( NULL, &ObjectAttributes, //Object attributes. POLICY_ALL_ACCESS, //Desired access permissions. &lsahPolicyHandle //Receives the policy handle. ); if (ntsResult != 0) // sth. wrong in here { // An error occurred. Display it as a win32 error code. wprintf(L"OpenPolicy returned %lu\n", LsaNtStatusToWinError(ntsResult)); return NULL; } return lsahPolicyHandle; } int main( void ) { LSA_HANDLE hPolicyHandle = GetPolicyHandle(); NTSTATUS status; PPOLICY_PRIMARY_DOMAIN_INFO ppdiDomainInfo; if ( hPolicyHandle ) { status = LsaQueryInformationPolicy( hPolicyHandle, PolicyPrimaryDomainInformation, (PVOID *)&ppdiDomainInfo); if ( status ) { printf("LsaQueryInformationPolicy error, %d\n", GetLastError() ); } else { if ( ppdiDomainInfo->Sid ) { DebugBox( TEXT("In Domain Controler!") ); } else { DebugBox( TEXT("StandAlone Computer!") ); } } } LsaFreeMemory((LPVOID)ppdiDomainInfo); }
上一篇:Windows下也很强悍的VIM(函数自动补全功能)
下一篇:rundll32.exe 用途
登录 注册