Three methods for creating a process

Source: Internet
Author: User


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 (" ");

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


Zeromemory (& Si, sizeof (SI ));

Si. cb = sizeof (SI );


Zeromemory (& Pi, sizeof (PI ));

Lpctstrlppath = _ T ("C: \ ProgramFiles \ Internet Explorer \ ipolice.exe ");

Lptstrlpcmdline = _ T (""); // 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 (" ");

_ Tcscat_s (szpath, max_path, szcmdline );

Winexec (szpath, sw_normal );



Better reading performance:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.