15,978
社区成员




HDESK hDesktopMy=NULL;
hDesktopMy = OpenDesktop(L"MyDesktop",
DF_ALLOWOTHERACCOUNTHOOK,
FALSE,
GENERIC_ALL);
if (hDesktopMy == NULL)//如果打不开,说明没有创建
{
m_SecurityAt.bInheritHandle = TRUE;
m_SecurityAt.nLength = sizeof(SECURITY_ATTRIBUTES);
m_SecurityAt.lpSecurityDescriptor = NULL;
//创建MyDesktop
hDesktopMy = CreateDesktop(L"MyDesktop",
NULL,
NULL,
0,
MAXIMUM_ALLOWED,
&m_SecurityAt);
if (hDesktopMy == NULL)
{
return;
}
}
if (!SetThreadDesktop(hDesktopMy))
{
DWORD dwErr;
dwErr = GetLastError();
CString str;
str.Empty();
str.Format(L"SetThreadDesktop failed err: %d", dwErr);//这里打印出来的错误ID是170
AfxMessageBox(str);
return;
}
WCHAR wCommond[16]=L"explorer";
bRet = CreateProcess(NULL, // image name
wCommond, // command line
NULL, // process security attributes
NULL, // thread security attributes
TRUE, // inherit handles
CREATE_DEFAULT_ERROR_MODE | CREATE_SEPARATE_WOW_VDM | CREATE_UNICODE_ENVIRONMENT,//dwCreationFlags
NULL, // environment block
NULL, // current directory
&m_StartInfo, // STARTUPINFO
&m_ProcessInfo);// PROCESS_INFORMATION
STARTUPINFO m_StartInfo;
ZeroMemory((PVOID)&m_StartInfo, sizeof(m_StartInfo));
m_StartInfo.cb = sizeof(m_StartInfo);
m_StartInfo.lpReserved = NULL;
m_StartInfo.lpDesktop = L"X431_3G";
m_StartInfo.dwX = this->m_miSecondly.rcMonitor.left;//2号屏坐标
m_StartInfo.dwY = this->m_miSecondly.rcMonitor.top;;//2号屏坐标
m_StartInfo.dwXSize = this->m_miSecondly.rcMonitor.right - this->m_miSecondly.rcMonitor.left;//2号屏长
m_StartInfo.dwYSize = this->m_miSecondly.rcMonitor.bottom - this->m_miSecondly.rcMonitor.top;;//2号屏高
m_StartInfo.cbReserved2 = 0;
m_StartInfo.lpReserved2 = NULL;
m_StartInfo.dwFlags = STARTF_USESIZE | STARTF_USEPOSITION | STARTF_RUNFULLSCREEN | STARTF_USESHOWWINDOW/* | STARTF_USEFILLATTRIBUTE*/;
bRet = CreateProcess(NULL, // image name
L"explorer", // command line
NULL, // process security attributes
NULL, // thread security attributes
TRUE, // inherit handles
CREATE_DEFAULT_ERROR_MODE | CREATE_SEPARATE_WOW_VDM,
NULL, // environment block
NULL, // current directory
&m_StartInfo, // STARTUPINFO
&m_ProcessInfo);// PROCESS_INFORMATION
if (FALSE == bRet)
{
return 1;
}