ShellExecute usage collection
Open the application
ShellExecute (m_hwnd, "open", "calc.exe", "", "", sw_show );
Or
ShellExecute (m_hwnd, "open", "notepad.exe", "C: // testlog. log", "", sw_show );
You can also choose not to use full path names.
Open a file related to the same system program
ShellExecute (m_hwnd, "open", "C: // abc.txt", "", "sw_show );
How to open a webpage
ShellExecute (m_hwnd, "open", "http://www.google.com", "", "", sw_show );
Activate related programs and send emails
ShellExecute (m_hwnd, "open", "mailto: liang5158270@hotmail.com", "", "", sw_show );
Print documents with a system printer
ShellExecute (m_hwnd, "print", "C: // test.txt", "", "sw_hide );
How to use the system search function to find a specified file
ShellExecute (m_hwnd, "find", "d: // destfile", null, null, sw_show );
Start a program until it finishes running.
Method 1:
Shellexecuteinfo shexecinfo = {0 };
Shexecinfo. cbsize = sizeof (shellexecuteinfo );
Shexecinfo. fmask = see_mask_nocloseprocess;
Shexecinfo. hwnd = NULL;
Shexecinfo. lpverb = NULL;
Shexecinfo. lpfile = "C: // myprogram.exe ";
Shexecinfo. lpparameters = "";
Shexecinfo. lpdirectory = NULL;
Shexecinfo. nshow = sw_show;
Shexecinfo. hinstapp = NULL;
Shellexecuteex (& shexecinfo );
Waitforsingleobject (shexecinfo. hprocess, infinite );
Method 2:
Process_information processinfo;
Startupinfo; // This is an [in] Parameter
Zeromemory (& startupinfo, sizeof (startupinfo ));
Startupinfo. cb = sizeof startupinfo; // only compulsory field
If (CreateProcess ("C: // winnt // notepad.exe", null, false, 0, null, null, & startupinfo, & processinfo ))
{
Waitforsingleobject (processinfo. hprocess, infinite );
Closehandle (processinfo. hthread );
Closehandle (processinfo. hprocess );
}
Else
{
MessageBox ("the process cocould not be started ...");
}
Display Properties of a file or folder
Shellexecuteinfo shexecinfo = {0 };
Shexecinfo. cbsize = sizeof (shellexecuteinfo );
Shexecinfo. fmask = see_mask_invokeidlist;
Shexecinfo. hwnd = NULL;
Shexecinfo. lpverb = "properties ";
Shexecinfo. lpfile = "C: //"; // can be a file as well
Shexecinfo. lpparameters = "";
Shexecinfo. lpdirectory = NULL;
Shexecinfo. nshow = sw_show;
Shexecinfo. hinstapp = NULL;
Shellexecuteex (& shexecinfo );