2

我正在尝试在隐藏的桌面上启动一个应用程序,但没有取得太大进展,并且找不到关于桌面和窗口站到底是什么的详细文档。这是我删除了错误处理的代码(但相信我它在那里并且没有捕获任何错误):

HWINSTA winSta = CreateWindowStation(_T("hiddenWinSta"), 0, 0, NULL);
SetProcessWindowStation(winSta);
HDESK desktop = CreateDesktop(_T("hiddenDesktop"), NULL, NULL, 0, DESKTOP_CREATEWINDOW, NULL);
OpenDesktop(_T("hiddenDesktop"), 0, TRUE, GENERIC_ALL);
SetThreadDesktop(desktop)

HWINSTA r = GetProcessWindowStation();
printf("winsta: %x %x\n", r, winSta);
HDESK curdesk = GetThreadDesktop(GetCurrentThreadId());
printf("desktop: %x %x\n", curdesk, desktop);

STARTUPINFO si;
PROCESS_INFORMATION pi;

ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
//si.lpDesktop = _T("hiddenDesktop");
ZeroMemory( &pi, sizeof(pi) );
TCHAR szCommand[MAX_PATH];
_sntprintf_s(szCommand, MAX_PATH, _T("%s"), _T("c:\\windows\\system32\\calc.exe"));
DWORD res = CreateProcess(NULL, szCommand, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);

如果我取消注释 si.lpDesktop 行,则进程无法以可怕的错误 0x000142 开始。如果我评论 si.lpDesktop 进程在当前桌面上启动。我究竟做错了什么?是否有可能做我想做的事(即启动一个完全不可见的 Windows GUI 应用程序)?

4

1 回答 1

1

取消注释

si.lpDesktop = _T("hiddenDesktop");

评论

// HWINSTA winSta = CreateWindowStation(_T("hiddenWinSta"), 0, 0, NULL);
// SetProcessWindowStation(winSta);
于 2013-01-22T05:16:10.427 回答