Pythonで表示されるVBでdllを作成するのに苦労していますが、
dll を Python にインポートすると、どの VB 関数も表示されません
これが私がすることです:
- これまでで最も単純な VB クラス
Public Class MyFunctions Public Function AddMyValues(ByVal Value1 As Double, ByVal Value2 As Double) Dim Result As Double Result = Value1 + Value2 Return Result End Function End Class`
dllとして保存します(Visual Studio 2010からビルド)
他のVBプロジェクトにインポートして動作するかどうか試します(正常に動作します):
Imports ClassLibrary1 Module Module1 Sub Main() Dim Nowa As New ClassLibrary1.MyFunctions Dim Result As String Result = Nowa.AddMyValues(123, 456.78).ToString Console.WriteLine(Result) Console.ReadLine() End Sub End Module
- 私はそれをpythonにロードして使用しようとします:
from ctypes import * MojaDLL = cdll.LoadLibrary("E:\\ClassLibrary1.dll") MojaDLL.MyFunctions Traceback (most recent call last): File "<console>", line 1, in <module> File "C:\Python25\lib\ctypes\__init__.py", line 361, in __getattr__ func = self.__getitem__(name) File "C:\Python25\lib\ctypes\__init__.py", line 366, in __getitem__ func = self._FuncPtr((name_or_ordinal, self)) AttributeError: function 'MyFunctions' not found
MyDll.MyFunctions の代わりに私も試しました: MyDll.MyFunctions() , MyDll.MyFunctions.AddMyValues(1,2) , MyDll.MyFunctions.AddMyValues
.
ここで何が問題なのですか?わかりません。
PS。同様の未解決の問題があります: Python で vb dll を呼び出す