Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WinExec, ShellExecute, CreateProcess will not open iexplore

Status
Not open for further replies.

minifiredragon

Programmer
Jun 29, 2003
68
US
I am trying to open up an Internet Explorer Window from within a program I am writing.
I have tried using WinExec:

WinExec("iexplore", SW_NORMAL);
WinExec("iexplore.exe", SW_NORMAL);
WinExec("C:\Program Files\Internet Explorer\iexplore", SW_NORMAL);

ShellExecute(NULL, "open", "iexplore" , NULL, NULL, SW_SHOWNORMAL);

ShellExecute(NULL, "open", "iexplore.exe" , NULL, NULL, SW_SHOWNORMAL);

ShellExecute(NULL, "open", "C:\Program Files\Internet Explorer\iexplore" , NULL, NULL, SW_SHOWNORMAL);

And finally:

STARTUPINFO si;
PROCESS_INFORMATION pi;

GetStartupInfo(&si);


CreateProcess(NULL, "iexplore", // Name of app to launch
NULL, // Default process security attributes
NULL, // Default thread security attributes
FALSE, // Don't inherit handles from the parent
0, // Normal priority
NULL, // Use the same environment as the parent
NULL, // Launch in the current directory
&si, // Startup Information
&pi); // Process information stored upon return

The thing is it works fine with notepad so I do not know what is wrong with the whole thing. I should mention that I also used SW_SHOW instead of SW_NORMAL thinking it might work.

I finally settled with:
ShellExecute(NULL, "open", " , NULL, NULL, SW_SHOWNORMAL);

to open an IE brower window. Is IE not suppose to be called from within an AP?
 
oh, this is what I do and it works fine:
ShellExecute(hwnd, "open", "explorer.exe", "[address here]", "", SW_SHOW);//Open the URL in IE

so where it says [address here] type the URL (i.e
(-- yes there is a
--------------
"Getting to the top is an extra reward.Its the climb that makes the man."
Xerxes Dynatos
 
if you want it do just a blank URL (I saw NULL in there, most probably indicating that you just want a blank window), do "about:blank" for the URL.

--------------
"Getting to the top is an extra reward.Its the climb that makes the man."
Xerxes Dynatos
 
XerxesTheMighty: This works to


--->Snip
ShellExecute(NULL, "open", " , NULL, NULL, SW_SHOWNORMAL);
<---snip (exert from 1st post)

Thanks for the pointers though, will try the about:blank.
 
use
CreateProcess(&quot;fullPath\\iexplore.exe&quot;, NULL, ...

or

CreateProcess(NULL, &quot;iexplore ...

or

CreateProcess(NULL, &quot; ...


Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Interesting. I was looking at a few examples of the use of CreateProcess and no one pointed it out the way you have. I will try when I get a chance too. I guess I don't understand why it won't open using the command line.
 
There are two variants:
Code:
	SECURITY_ATTRIBUTES processAttributes;
	SECURITY_ATTRIBUTES threadAttributes;
	STARTUPINFO startupInfo;
	PROCESS_INFORMATION processInformation;
    ZeroMemory( &startupInfo, sizeof(startupInfo) );
	char xx[256];
	::GetWindowsDirectory(xx, 255);
	MessageBox(0, xx, &quot;&quot;, 0);
//first variant, 
//opens a program with some command line
//parameters:
	BOOL x = CreateProcess
		(
			(LPCTSTR) 0, 			(LPTSTR) &quot;notepad hello.txt&quot;,
			0, //&processAttributses,
			0, //&threadAttributes,
			FALSE,
			NORMAL_PRIORITY_CLASS,
			(LPVOID)0,
			(LPCTSTR)&quot;G:\\Documents and Settings\\Administrator\\Desktop&quot;, //current directory
			&startupInfo,
			&processInformation
		);
//second variant, opens exactly the needed program
//by path:
	x = CreateProcess
		(
			&quot;g:\\winnt\\notepad.exe&quot;,
 			LPCTSTR) 0,
			0, //&processAttributses,
			0, //&threadAttributes,
			FALSE,
			NORMAL_PRIORITY_CLASS,
			(LPVOID)0,
			(LPCTSTR)&quot;G:\\Documents and Settings\\Administrator\\Desktop&quot;, //current directory
			&startupInfo,
			&processInformation
		);

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
That is the thing, I know what u are saying. In your 1st variant where u used
CreateProcess(NULL, &quot;notepa....

If u just used &quot;notepad&quot; it opens a blank notepad up. Which is why I thought it would just launch &quot;iexplore&quot;, but it doesn't. I am just trying to find out why it worked for &quot;notepad&quot; and not &quot;iexplore&quot;.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top