ShellExecuteEx(&ShExecInfo)让它启动,再发消息给它的问题.
HWND m_Hwnd;
bool bRet;
m_Hwnd = ::FindWindow(NULL, _T("Message"));
if (m_Hwnd == NULL) //INVALID_HANDLE_VALUE
{
SHELLEXECUTEINFO ShExecInfo = {0};
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = _T("\\Storage Card\\message.exe");
ShExecInfo.lpParameters = _T("");
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
bRet = ShellExecuteEx(&ShExecInfo);
}
//if (bRet == true)
{
Sleep(0);
::BringWindowToTop(m_Hwnd);
Sleep(0);
::SendMessage(m_Hwnd, WM_COMMON_MESSAGE, (WPARAM)8888, (LPARAM)6666);
}
我想启动message.exe后,发消息给message.exe, 让它做另一件事情(或到另一个状态).
如果message.exe已经启动,发消息给message.exe,可以。
如果message.exe没有启动,ShellExecuteEx(&ShExecInfo)让它启动,再发消息给message.exe,则不可以。
为什么会这样?