Dave's Brain

Browse - programming tips - how to winexec example

Date: 2010mar19
Language: C/C++
OS: Windows

Q.  How do I use WinExec() ?

A.  The documentation says its "obsolete" but its an easy way to launch another
program from your.  Some examples...

	Launch Notepad (its in your PATH so you don't need specify it its full file name):

		WinExec("notepad", SW_SHOWNORMAL);

	Launch Windows Calendar:

		WinExec("c:\\Program Files\\Windows Calendar\\wincal.exe", SW_SHOWNORMAL);

	Check if it failed:

		if (WinExec(szFile, SW_SHOWNORMAL) <= 31)
		{
			MessageBox(... "failed"...);
		}
		
	Check if it worked:

		if (WinExec(szFile, SW_SHOWNORMAL) > 31)
		{
			// Worked
		}
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2010, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.