Reputation: 5023
I used ShellExecuteEx
to call iexplore.exe
, Whenever I start the application a new instance of internet explorer is created irrespective of, internet explorer already opened or not.
I want to change this, if already an instance of the Internet explorer is there, I need to open a new tab in that instance with the address I am passing to the ShExecInfo.lpParameters
, thus without creating a new window. Is there a way to do this? Please advice..
UPADATE: In the below answer I have a problem, when I set the lpFile parameter as "iexplore.exe" and lpParameters as "www.google.com", two windows get opened. If I ignore lpfile parameter, then the below code opens default browsers in some machine. I want only internet explorer to get opened. please help..
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;
}
Upvotes: 4
Views: 768
Reputation: 8197
It works with 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;
}
Upvotes: 7