gpt4 book ai didi

c++ - 应用程序无法使用 CreateWindowStation 创建 Windows 站

转载 作者:可可西里 更新时间:2023-11-01 14:50:49 38 4
gpt4 key购买 nike

我无法创建新的 Window Station 来运行我的应用程序

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
wprintf(L"SetProcessWindowStation() before: %x\n", GetProcessWindowStation());
HWINSTA winSta = CreateWindowStation(_T("hiddenWinSta"), 0, 0, NULL);
if (winSta == NULL)
{
wprintf(L"CreateWindowStation() failed, error %d!\n", GetLastError());
}else
wprintf(L"CreateWindowStation() is OK!\n");
SetProcessWindowStation(winSta);
OpenDesktop(L"default", 0, FALSE, READ_CONTROL | WRITE_DAC | DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS);
wprintf(L"SetProcessWindowStation() after: %x\n", GetProcessWindowStation());
system("pause");
return 0;
}

我可以为新的 windows station 截屏吗?winsta0 和 desktop default 不是吗?请帮助我:(


输出

SetProcessWindowStation() before: 30
CreateWindowStation() failed, error 5!
SetProcessWindowStation() after: 30
Press any key to continue . . .

最佳答案

错误 5 是 ERROR_ACCESS_DENIED

来自 CreateWindowStation

lpwinsta [in, optional]

The name of the window station to be created. Window station names are case-insensitive and cannot contain backslash characters \. Only members of the Administrators group are allowed to specify a name. If lpwinsta is NULL or an empty string, the system forms a window station name using the logon session identifier for the calling process. To get this name, call the GetUserObjectInformation function.

因此,要么以管理员身份启动程序,要么不指定名称。

关于c++ - 应用程序无法使用 CreateWindowStation 创建 Windows 站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16386710/

38 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com