Run IE from a C ++ program

I have a program written in C ++ that does some computer diagnostics. Before exiting the program, I need to start Internet Explorer and go to a specific URL. How to do this with C ++? Thanks.

+4
source share
7 answers

Here you are ... I assume you are talking about MSVC ++ here ...

// I do not recommend this... but will work for you system("\"%ProgramFiles%\\Internet Explorer\\iexplore.exe\""); // I would use this instead... give users what they want #include <windows.h> void main() { ShellExecute(NULL, "open", "http://stackoverflow.com/questions/982266/launch-ie-from-ac-program", NULL, NULL, SW_SHOWNORMAL); } 
+8
source

If you really need to start Internet Explorer, you should also learn to use CoCreateInstance (CLSID_InternetExplorer, ...) and then do the navigation. depending on what else you want to do, this may be the best option.

+3
source

Using only standard C ++, if iexplore is in the way, then

 #include <stdlib.h> ... string foo ("iexplore.exe http://example.com"); system(foo.c_str()); 

If this is not the way, you need to work out the way somehow and pass it all on to the system call.

 string foo ("path\\to\\iexplore.exe http://example.com"); system(foo.c_str()); 
+2
source

I am with Glen and John, except that instead I prefer to use CreateProcess . So you have a process handle with which you can do something. Examples are Kill IE when you are done with this, or ask for a thread watching IE shut down ( WaitForSingleObject with a process handle) so that it can do something like restart or shut down your program.

+2
source

Do you really need to run IE or just some content in a browser? The ShellExecute function will launch any browser configured to the default value. Call it that:

 ShellExecute(NULL, "open", szURL, NULL, NULL, SW_SHOW); 
+2
source
 include <windows.h> int main() { ShellExecute(0, "open", "C:\\progra~1\\intern~1\\iexplore.exe", "http://www.foo.com", "", SW_MAXIMIZE); return 0; } 
+2
source

Try this system ("\" C: \ Program Files \ Internet Explorer \ iexplore \ " http://www.shail.com "); It works great.

0
source

Source: https://habr.com/ru/post/1286084/


All Articles