轉深入淺出ShellExecute

2021-06-20 02:06:41 字數 2925 閱讀 9320

轉深入淺出shellexecute

黑洞 shellexecute的功能是執行乙個外部程式(或者是開啟乙個已註冊的檔案、開啟乙個目錄、列印乙個檔案等等),並對外部程式有一定的控制。

原型及引數含義

shellexecute函式原型及引數含義如下:

shellexecute(

hwnd: hwnd;

operation: pchar;

filename: pchar;

parameters: pchar;

directory: pchar;

showcmd: integer

): hinst;

//返回值可能的錯誤有: = 0

error_file_not_found = 2;

error_path_not_found = 3;

error_bad_format = 11;

se_err_share = 26;

se_err_associncomplete = 27;

se_err_ddetimeout = 28;

se_err_ddefail = 29;

se_err_ddebusy = 30;

se_err_noassoc = 31;

//showcmd 引數可選值:sw_hide = 0;

sw_shownormal = 1;

sw_normal = 1;

sw_showminimized = 2;

sw_showmaximized = 3;

sw_maximize = 3;

sw_shownoactivate = 4;

sw_show = 5;

sw_minimize = 6;

sw_showminnoactive = 7;

sw_showna = 8;

sw_restore = 9;

sw_showdefault = 10;

sw_max = 10;

q: 如何開啟乙個應用程式?

shellexecute(this->m_hwnd,"open","calc.exe","","", sw_show );

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

"c:\mylog.log","",sw_show );

正如您所看到的,我並沒有傳遞程式的完整路徑。

shellexecute(this->m_hwnd,"open","c:\abc.txt","","",sw_show );
shellexecute(this->m_hwnd,"open","","","", sw_show );

shellexecute(this->m_hwnd,"print","c:\abc.txt","","", sw_hide);

shellexecute(m_hwnd,"find","d:\nish",null,null,sw_show);

shellexecuteinfo shexecinfo = ;
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;
shellexecuteex(&shexecinfo);
waitforsingleobject(shexecinfo.hprocess,infinite);
或:

process_information processinfo;
startupinfo startupinfo; //this is an [in] parameter
zeromemory(&startupinfo, sizeof(startupinfo));
startupinfo.cb = sizeof startupinfo ; //only compulsory field
if(createprocess("c:\winnt\notepad.exe", null, null,null,false,0,null,null,&startupinfo,&processinfo))
else

shellexecuteinfo shexecinfo =;
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;
shellexecuteex(&shexecinfo);

深入淺出sizeof

int佔 位元組,short佔 位元組 1.0 回答下列問題 答案在文章末尾 1.sizeof char 2.sizeof a 3.sizeof a 4.strlen a 如果你答對了全部四道題,那麼你可以不用細看下面關於sizeof的論述。如果你答錯了部分題目,那麼就跟著我來一起 關於sizeof...

深入淺出ShellExecute

ipconfig c log.txt應如何處理?二樓的朋友,開啟拔號網路這樣 shellexecute null,open c windows rundll32.exe shell32.dll,control rundll c windows system telephon.cpl null,sw ...

深入淺出ShellExecute

深入淺出shellexecute譯者 徐景周 原作 nishant s q 如何開啟乙個應用程式?shellexecute this m hwnd,open calc.exe sw show 或shellexecute this m hwnd,open notepad.exe c mylog.log...