Using ShellExecute in VC++ 
Author Message
 Using ShellExecute in VC++

Quote:

>Hello,

>I'm having a problem with the ShellExecute statement in Visual C++ 5.0 Pro.  I
>was wandering if maybe someone could help me figure it out.

>My problem is that I cannot seem to get rid of the DOS box, when I launch my
>EXE file.  I'm trying to create a simple little EXE that will install an INF
>file under Windows, but I don't want the DOS box to appear.

>Here is my code, maybe someone can tell me what I'm doing wrong:

>#include <windows.h>
>#include <shellapi.h>

>void main(void)
>{
>     ShellExecute(NULL,"install","install.inf",NULL,NULL,SW_SHOWNORMAL);
>}

Just use WinMain() instead of main(). Programs using main() are built using
"subsystem:console" (by default, so you get a console). Programs using WinMain()
use "subsystem:windows" (by default). Just because you've used WinMain() doesn't
mean you must do any "windows" things. Just copy the "WinMain(...) {" from an
example and have the program return an integer; no other changes should be
necessary. WinMain() takes arguments that won't be used in your small example
but they must be in the definition (i.e., you can't use "void").

There's another, more complicated way to do it, namely, continue to use main()
but specify "subsystem:windows" (project settings\link) and also specify to the
linker that the program's "entry point" is main() (since "subsystem:windows"
tells the linker to expect to find WinMain()).

 - Vince



Fri, 02 Mar 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. PrintDlg when using ShellExecute

2. debugger detects memory leak after using shellexecute

3. ShellExecute fails when using SHGetSpecialFolderLocation?

4. PrintDlg when using ShellExecute

5. Using shellexecute to invoke Direct:Connect (Sterling Software)

6. Need help using ShellExecute()

7. Memory Leaks when using Shellexecute

8. Printng Power Point documents using ShellExecute

9. Opening multiple files using ShellExecute

10. Using ShellExecute

11. Using ShellExecute() go online

12. Using ShellExecute to print

 

 
Powered by phpBB® Forum Software