MFC載入exe資源,程式呼叫exe功能

2021-07-05 15:40:12 字數 1565 閱讀 8312

1、工程b為基於mfc對話方塊程式,先插入已經存exe(或dll)檔案到vc資源檔案中,如下圖:

a、切換到資源檢視,在上面單機右鍵:

b、單擊"import...",找到剛剛工程a編譯生成的msgbox.exe檔案:

c、設定匯入的資源型別名,這個名稱將是該函式的第三個引數,我們取資源型別名為exe:

d、此時,資源檢視中多了乙個型別為:exe,資源id為:idr_exe1,如下圖:

2.輸入**:

hrsrc hres = findresource(null, makeintresource(idr_exe1), _t("exe")); 

dword dwsize = sizeofresource(null, hres);  

hglobal hglobal = loadresource(null, hres);  

lpvoid lp = lockresource(hglobal);  

按f7 built你的工程之後,fileview檢視就會出現msgbox.exe

這樣就把外部的exe程式引進入到mfc工程了,剩下的,你就可以使用呼叫exe的方法使用了。

eg:system("msgbox.exe");

之後按ctrl+f5,你生成的exe程式執行它就包含了msgbox.exe的功能,無需把msgbox.exe程式放到硬碟中,通過程式去呼叫它了,它是可以單獨存在的。

完整的**如下:

void cmfcrunexeresourcedlg::onok() 

; process_information pi = ;}}

catch (cexception* e)

// cdialog::onok();}//

// 1.click the right mouse button in dialog,select import

// 2.select ***.exe program,resource type input "exe",

// 3.build program,switch to fileview window,will see ***.exe in the tree structure.

//void cmfcrunexeresourcedlg::onbutton1()

; process_information pi = ;

}

c 呼叫外部exe程式

c 呼叫外部exe程式,首先要 using system.diagnostics 然後開啟乙個新process system.diagnostics.processstartinfo p null system.diagnostics.process proc p new processstarti...

Silverlight呼叫本機exe程式

要點 1.silverlight必須啟用oob模式,以及 require elevated trust when running in browser.參考下圖設定 注 oob模式,並不意味著必須脫離瀏覽器執行,仍然可以嵌入到網面中執行 2.必須新增microsoft.csharp.dll 引用,預...

C 程式呼叫外部exe程式

在編寫程式時經常會使用到呼叫可執行程式的情況,本文將簡單介紹c 呼叫exe的方法。在c 中,通過process類來進行程序操作。process類在system.diagnostics包中。using system.diagnostics process p process.start notepad...