作者largesperm (reindeer)
看板Python
標題[問題] Call C# DLL
時間Wed Nov 13 17:42:21 2013
請教一下 我現在有個想法是這樣的
在 .NET 用 C# 寫個 Class library
然後在 Python 利用 ctype 去 call 這個 DLL 檔
C# 程式內容
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace PlusMinus
{
public class CheckPlusMinus
{
public CheckPlusMinus()
{
}
public String Check(int inputInteger)
{
if (inputInteger > 0)
{
return "Plus";
}
else if (inputInteger == 0)
{
return "0";
}
else
{
return "Minus";
}
}
}
}
Python 程式內容
import ctypes
dll = ctypes.CDLL("C:/Python 2.5/DLLs/PlusMinus.dll")
dll.Check(333)
執行的回應是
Traceback (most recent call last):
File "C:\Python 2.5\Lib\ctypes\__init__.py", line 353, in __getattr__
func = self.__getitem__(name)
File "C:\Python 2.5\Lib\ctypes\__init__.py", line 358, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'Check' not found
我確定 Python 有讀到 DLL 檔
可是不知道怎麼執行 function ...
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 219.69.42.170
推 cobrasgo:你要不要先用windows的tool打開那個dll檔,看看是不是真 11/15 22:03
→ cobrasgo:的有Check這個function 11/15 22:03
推 ghmsxtwo:看成 Call of Duty ... 11/16 11:37