遇到一个问题:通过一个C++应用使用WinExec接口打开另一个winform应用,发现winform内嵌的webBrowser控件JS通讯失效了,折腾了很久之后发现使用ShellExecute接口调用即可解决该问题,ShellExecute接口如下:
注意:lpDirectory必须设置为winform应用所在的目录!!!
SHSTDAPI_(HINSTANCE) ShellExecuteW(_In_opt_ HWND hwnd, _In_opt_ LPCWSTR lpOperation, _In_ LPCWSTR lpFile, _In_opt_ LPCWSTR lpParameters,
_In_opt_ LPCWSTR lpDirectory, _In_ INT nShowCmd);
if (isSpeacialChannel == false)
{
sprintf(buff, "%s %s %s", exePath.c_str(), installPath.c_str(), parm.c_str());
WinExec(buff, SW_SHOWNORMAL);
}
else
{
ShellExecute(nullptr, L"open", StringUtf8ToWideChar(exePath).c_str(), nullptr, StringUtf8ToWideChar(installPath).c_str(), SW_SHOW);
}