VC呼叫其他程式以及用其他程式開啟相應檔案

2021-06-18 16:27:17 字數 2248 閱讀 6999

深入淺出shellexecute

譯者:徐景周(原作:nishant s)

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

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

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

"c:","",sw_show );

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

q: 如何開啟乙個同系統程式相關連的文件?

shellexecute(this->m_hwnd,"open",

"c:","","",sw_show );

q: 如何開啟乙個網頁?

shellexecute(this->m_hwnd,"open",

"","","", sw_show );

q: 如何啟用相關程式,傳送email?

shellexecute(this->m_hwnd,"open",

q: 如何用系統印表機列印文件?

shellexecute(this->m_hwnd,"print",

"c:","","", sw_hide);

q: 如何用系統查詢功能來查詢指定檔案?

shellexecute(m_hwnd,"find","d://nish",

null,null,sw_show);

q: 如何啟動乙個程式,直到它執行結束?

shellexecuteinfo shexecinfo = ;

shexecinfo.cbsize = sizeof(shellexecuteinfo);

shexecinfo.fmask = see_mask_nocloseprocess;

shexecinfo.hwnd = null;

shexecinfo.lpverb = null;

shexecinfo.lpfile = "c:";

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", null,

null,null,false,0,null,

null,&startupinfo,&processinfo))

else

q: 如何顯示檔案或資料夾的屬性?

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

下面是我自己的**,呼叫word開啟doc或docx檔案
[c-sharp]view plain

copy

void

copenfiledlgdlg::onbnclickedbutton1()  

}  }  }  

VC呼叫其他程式以及用其他程式開啟相應檔案

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

呼叫其他程式

1含有事務碼 1.1不注入引數,直接呼叫 call transaction suim and skip first screen.1.2注入引數,setparameter id 螢幕字段 field 填充的字段值,螢幕字段 field 填充的字段值.call transaction demo tra...

android 呼叫其他程式

第一種 packagemanager pm this.getpackagemanager private void getintent packagemanager packagemanager,string path catch namenotfoundexception e 第二種 知道其他程式...