【发布时间】:2010-12-15 22:59:16
【问题描述】:
我正在开发 Win32 应用程序。所有绘图都在 WM_PAINT 中完成。它工作正常。我在其中添加了一项功能。当我单击按钮时,会执行命令提示符。这我可以使用 WinExec 完成。现在当我移动 Cmd.exe 比在后台绘图时没有完成。 我用 CreateProcess 更新代码,而不是发生同样的事情。谁能帮我看看这段代码有什么问题。是不是因为当我专注于这个窗口时,焦点会丢失并且绘图没有完成。
代码
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
TCHAR wchCmdPath[MAX_PATH];
memset(wchCmdPath,_T('\0'),MAX_PATH);
GetSystemDirectory(wchCmdPath,MAX_PATH);
wcscat(wchCmdPath,_T("\\cmd.exe"));
// Start the child process.
if( !CreateProcess( NULL, // No module name (use command line)
wchCmdPath, // Command line
NULL, // Process handle not inheritable
NULL, // Thread handle not inheritable
FALSE, // Set handle inheritance to FALSE
0, // No creation flags
NULL, // Use parent's environment block
NULL, // Use parent's starting directory
&si, // Pointer to STARTUPINFO structure
&pi ) // Pointer to PROCESS_INFORMATION structure
)
{
printf( "CreateProcess failed (%d).\n", GetLastError() );
return;
}
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
InvalidateRect(hwnd,NULL,TRUE);
UpdateWindow(hwnd);
提前致谢
【问题讨论】: