LoginSignup
12
9

More than 5 years have passed since last update.

Pythonで簡単にC++で作成したDLLをテストしてみる

Last updated at Posted at 2018-01-19

やりたかったこと

Unity C#でDLLを使用したかったが動作しなかったので、Pythonを使ってDLLに問題がないか簡単にテストしてみる

前提

実行するPythonスクリプトファイルはDLLと同じディレクトリにある必要がある。
今回のDLLのファイル名は「DLLForDebug.dll」、DLLには二つのint型の変数を足して返す関数「add」が存在する。

コード

from ctypes import *

# DLLの読み込み
dll = cdll.LoadLibrary("./DllForDebug.dll")

# DLL内の関数を呼び出して出力する
print(dll.add(1, 2))

結果


3
12
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
9