Http://hi.baidu.com/magicfuzzx/item/284b1dd7c3087c0a20e2500e
Shellapi is characteristic of defining a struct and then calling a function. The parameter of this function is usually the pointer of this struct, such as the shellexecuteinfo struct in this example.
Void cprocessdlg: onbnclickedbuttonshell ()
{
// Todo: add the control notification handler code here
Shellexecuteinfoshexecinfo = {0 };
Shexecinfo. cbsize = sizeof (shellexecuteinfo );
Shexecinfo. fmask = see_mask_nocloseprocess;
Shexecinfo. hwnd = NULL;
Shexecinfo. lpverb = NULL;
Shexecinfo. lpfile = _ T ("C: \ ProgramFiles \ Internet Explorer \ ipolice.exe ");
Shexecinfo. lpparameters = _ T ("www.google.com.hk ");
Shexecinfo. lpdirectory = NULL;
Shexecinfo. nshow = sw_show;
Shexecinfo. hinstapp = NULL;
Shellexecuteex (& shexecinfo );
}
Beginners may think that the createprocee function will be a little complicated. It is actually a path, a startup parameter, and two struct structures.
Void cprocessdlg: onbnclickedbuttoncreate ()
{
// Todo: add the control notification handler code here
Startupinfosi;
Zeromemory (& Si, sizeof (SI ));
Si. cb = sizeof (SI );
Process_informationpi;
Zeromemory (& Pi, sizeof (PI ));
Lpctstrlppath = _ T ("C: \ ProgramFiles \ Internet Explorer \ ipolice.exe ");
Lptstrlpcmdline = _ T ("http://www.google.com.hk"); // Add a space before the URL
CreateProcess (lppath, lpcmdline, null, null, false, 0, null, null, & Si, & PI );
}
The winexec function should only support multiple bytes, so there will be problems in Unicode.
Void cprocessdlg: onbnclickedbuttonwinexec ()
{
// Todo: add the control notification handler code here
Tcharszpath [max_path] = _ T ("C: \ Program Files \ internetexplorer \ ipolice.exe ");
Tcharszcmdline [] = _ T ("http://www.google.com.hk ");
_ Tcscat_s (szpath, max_path, szcmdline );
Winexec (szpath, sw_normal );
}
Better reading performance: http://blog.csdn.net/MagicFuzzX/archive/2011/06/09/6533045.aspx