我使用 ShellExecuteEx
调用 iexplore.exe
,每当我启动应用程序时,都会创建一个新的 Internet Explorer 实例,无论 Internet Explorer 是否已经打开。
我想改变这一点,如果已经有一个 Internet Explorer 实例,我需要在该实例中打开一个新选项卡,其中包含我传递给 ShExecInfo.lpParameters
的地址,因此无需创建新窗口。有没有办法做到这一点?请指教..
更新: 在下面的回答中我遇到了一个问题,当我将 lpFile 参数设置为“iexplore.exe”并将 lpParameters 设置为“www.google.com”时,会打开两个窗口。如果我忽略 lpfile 参数,那么下面的代码会在某些机器上打开默认浏览器。我只想打开 Internet Explorer。请帮助..
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) {
ShellExecute(0,L"open",L"iexplore.exe", L"http://www.google.com",0,SW_SHOWDEFAULT );
ShellExecute(0,L"open", L"iexplore.exe", L"http://www.yahoo.com",0,SW_SHOWDEFAULT );
return 0;
}
最佳答案
它与 ShellExecute
配合使用。
#include <stdio.h>
#include <tchar.h>
#include <Windows.h>
int _tmain(int argc, _TCHAR* argv[])
{
ShellExecute(0,L"open",L"http://www.google.com",0,0,SW_SHOWDEFAULT );
ShellExecute(0,L"open",L"http://www.yahoo.com",0,0,SW_SHOWDEFAULT );
return 0;
}
关于c - 使用 ShellExecuteEx 在已启动的实例中调用 iexplore.exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12000876/