|
-
Jan 8th, 2001, 10:52 AM
#1
Thread Starter
Member
How do you run a program from C++? I know how to do it in VB, but I don't know what to use to do it in C++, anything similar to Shell="c:\~~~~\*.exe", vbnormalfocus and such?
Wisdom is supreme, therefore get wisdom,
though it costs all you have, get understanding.
Proverbs 4:7
-
Jan 8th, 2001, 11:03 AM
#2
Frenzied Member
Use the ShellExecute API. You also need to include windows.h header.
Code:
HWND hWnd = FindWindow (NULL,"appname"); //if you don't know the HWND
ShellExecute(hWnd,"open" ,"c:\\windows\\notepad.exe",NULL,NULL,SW_SHOW );
-
Jan 8th, 2001, 12:52 PM
#3
Frenzied Member
I think the WinExec api is easier to understand for this task.
It's in kernel32 and think it's available in C++.
Here's an example.
Code:
WinExec("my.exe", 1);
// also accepts parameters like my.exe -a -x -s http://vbworld.com
Ps: Vlatko, I don't think the ShellExecute really needs the hWnd parameter, I used it in VB just by passing 0&, should work too (I'm at my work now so I can't test)
[Edited by Jop on 01-08-2001 at 12:56 PM]
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Jan 8th, 2001, 01:44 PM
#4
Frenzied Member
The hWnd parameter has its own value here. Receiving errors in a form of a message box.
MSDN:
Code:
hwnd
Window handle to a parent window. This window receives any message boxes that an application produces. For example, an application may report an error by producing a message box.
-
Jan 8th, 2001, 05:14 PM
#5
Frenzied Member
Thanks! didn't even know that
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|