DLL 製作方法
1.用VC開一個DL專案,這裡假設開了一個  Test prj
2.在Test.c中建立一個函數,
for example -
int TEST_API fn1Test(){
    return 255;
}
3.在Test.h加入以下敘述
extern "C"{
TEST_API int fn1Test();
}

用extern"C"宣告的目的是讓所有外部程式都可存取fn1Test()

4.編譯,DLL製作結束

p.s  可以用VC建立一個新的程式去連結他,也可以使用python寫一小段code去驗證

以下是python code
-----------------
import ctypes    # 加入ctypes module,讓python code可使用C function 

ref = ctypes.CDLL("Test.dll")    # 匯入Test.dll
print ref.fn1Test()        # 執行Test.dll裡頭的fn1Test()

raw_input()            # 等待user按下按鍵


http://revolution-30.blogspot.tw/search/label/win32

文章標籤
全站熱搜
創作者介紹
創作者 cj6m3 的頭像
cj6m3

勇ㄅㄟㄅㄟ胡言亂語堂

cj6m3 發表在 痞客邦 留言(0) 人氣(459)