[問題] Call C# DLL
請教一下 我現在有個想法是這樣的
在 .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
推
11/15 22:03, , 1F
11/15 22:03, 1F
→
11/15 22:03, , 2F
11/15 22:03, 2F
推
11/16 11:37, , 3F
11/16 11:37, 3F
→
07/31 17:30, , 4F
07/31 17:30, 4F
Python 近期熱門文章
PTT數位生活區 即時熱門文章