使用ShellExecuteEx在已启动的实例中调用iexplore.exe

2vi*_*on2 4 c windows sdk winapi

我曾经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;

} 
Run Code Online (Sandbox Code Playgroud)

per*_*ain 7

它适用于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;
}
Run Code Online (Sandbox Code Playgroud)