星期二, 10月 26, 2010

將 source code 的原始編排放入 blog 中

使用下列網站:
http://codeformatter.blogspot.com/2009/06/about-code-formatter.html

只要將 source code 貼上, 就會產生對應的 html, 再貼入 blog 中就可以了.

使用 python 呼叫 DLL

使用 BCB 來撰寫 DLL

 extern "C" __declspec(dllexport) int __stdcall ReturnAplusB(int a,int b)  
{
return a+b+1;
}

/* 注意 __stdcall 這個宣告很重要,不然 python 會找不到而出現錯誤訊息 */

使用 python 呼叫 DLL


 from ctypes import *  
def main():
dll = windll.LoadLibrary("DllTest.dll")
c = c_short(1)
d = c_short(3)
a = dll.ReturnAplusB(c,d)
print 'the return value : %d'%a
a = dll.ReturnAplusB(4,6)
print 'the return value : %d'%a
a = dll._Print1()
print 'the return value : %d'%a
if __name__ == '__main__':
main()


## 使用 ctypes module
## 使用 windll, 這個是用來呼叫 windows 中的 DLL.

參考:
http://hi.baidu.com/fangss007/blog/item/461d00f3dc317bc50b46e078.html