Python調用C++的DLL


import os
import sys
from ctypes import *

test = cdll.LoadLibrary('D:\Python27\py.dll')
print test.Add(1, 2)
test.Echo("hello dll")

mypath = sys.argv[1]
if not os.path.exists(mypath):
    print "The path %s does not exist!" % mypath
    sys.exit(2)

for f in [s for s in os.listdir(mypath) if os.path.splitext(s)[1] == ".csta"]:
    outputname = f + ".csv"
    test.Analyzer(os.path.join(mypath,f), os.path.join(mypath,outputname))
    print "%s >> %s" %(f, outputname)

程序思路:

  1. 調用cdll.LoadLibrary將dll導入進來;

  2. 32bit的dll在64bit的Python中無法使用;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM