我正在使用以下代码来运行 NetUserGetInfo功能:
bool MyGetComputerName(std::wstring &ComputerName) {
bool bReturn=false;
WCHAR ComputerNameBuffer[MAX_COMPUTERNAME_LENGTH+1]={0};
DWORD dwComputerNameLength=MAX_COMPUTERNAME_LENGTH+1;
DWORD dwReturn=GetComputerNameExW(ComputerNameNetBIOS,ComputerNameBuffer,&dwComputerNameLength);
if(dwReturn) {
ComputerName=std::wstring(ComputerNameBuffer);
bReturn=true;
}
return bReturn;
}
std::wstring ComputerName;
MyGetComputerName(ComputerName);
USER_INFO_1003* pUserInfo=0;
NetUserGetInfo(ComputerName.c_str(),L"Gast",1003,reinterpret_cast<LPBYTE*>(&pUserInfo));
函数 NetUserGeInfo 失败并返回错误 124。GetLastError 返回错误 997。 我做错了什么?
最佳答案
NetUserGetInfo
的第三个参数完全无效,这就是它返回错误 124 (ERROR_INVALID_LEVEL
) 的原因。
传递the documentation中指定范围内的数字对于 level
参数,如果您希望它起作用。在这种情况下,您应该传递值 1。
关于c++ - NetUserGetInfo 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44196549/