I can't create a new Window Station to run my application
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;
}
and can I make a screenshot of new windows station not is winsta0 and desktop default? please help me :(
output
SetProcessWindowStation() before: 30
CreateWindowStation() failed, error 5!
SetProcessWindowStation() after: 30
Press any key to continue . . .
Error 5 is ERROR_ACCESS_DENIED
From 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. IflpwinstaisNULLor an empty string, the system forms a window station name using the logon session identifier for the calling process. To get this name, call theGetUserObjectInformationfunction.
So either start your program as administator or don't specify a name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With