Decentralized SHELLEXECUTE

zhaozj2021-02-08  250

In-depth shallow shellexecute translator: Xu Jingzhou (original: Nishant S) Q: How to open an application?

Shellexecute (this-> m_hwnd, "open", "cagc.exe", ",", ", sw_show);

or

Shellexecute (this-> m_hwnd, "open", "notepad.exe",

"C: //mylog.log", "", sw_show);

As you can see, I haven't passed the full path of the program.

Q: How do I open a document related to the system program?

Shellexecute (this-> m_hwnd, "open",

"C: //abc.txt", "", "", sw_show);

Q: How to open a web page?

Shellexecute (this-> m_hwnd, "open",

"http://www.google.com", "", ", sw_show);

Q: How to activate related procedures, send email?

Shellexecute (this-> m_hwnd, "open",

"Mailto: nishinapp@yahoo.com", "", ", sw_show);

Q: How to print a document with a system printer?

Shellexecute (this-> m_hwnd, "print",

"c: //abc.txt", "", "", sw_hide);

Q: How to find the specified file with the system lookup function?

Shellexecute (M_HWND, "Find", "D: // Nish",

NULL, NULL, SW_SHOW;

Q: How to start a program until it runs?

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

or:

PROCESS_INFORMATION Processinfo;

StartupInfo Startupinfo; // this is an [in] parameter

ZeromeMory (& StartupInfo, Sizeof (StartupInfo);

Startupinfo.cb = sizeof startupinfo; // Only compulsory fieldif (CreateProcess ("c: //winnt//notepad.exe", NULL,

NULL, NULL, FALSE, 0, NULL,

NULL, & Startupinfo, & ProcessInfo)

{

WaitforsingleObject (ProcessInfo.hprocess, Infinite);

CloseHandle (ProcessInfo.hthread);

CloseHandle (ProcessInfo.hprocess);

}

Else

{

MessageBox ("The Process Could Not Be Started ...");

}

Q: How to display the properties of a file or folder?

ShellexecuteInfo shexecinfo = {0};

Shexecinfo.cbsize = sizeof (shellexecuteInfo);

Shexecinfo.fmask = see_mask_invokeidlist;

Shexecinfo.hwnd = null;

Shexecinfo.lpverb = "proties";

Shexecinfo.lpfile = "c: //"; // can be a file as well

Shexecinfo.lpparameters = ""

ShexecInfo.lpdirectory = null;

Shexecinfo.nshow = sw_show;

Shexecinfo.hinstapp = null;

ShellexecuteEx (& shexecInfo);

转载请注明原文地址:https://www.9cbs.com/read-2109.html

New Post(0)