我努力創造VB DLL這將是蟒蛇可見,VB DLL不工作與ctypes的(功能*未找到)
沒有一個VB功能是可見的,當我輸入DLL到蟒蛇
這是我做的:
- 有史以來最簡單的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中生成)我試試,如果它的工作原理是將它導入到othoer 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
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。還有類似的未解決的問題:calling vb dll in python
PS。當我註冊DLL作爲COM它工作很好 – 2013-03-11 18:58:17
也許這些文章將有所幫助:[如何自動導出.NET功能到非託管程序](http://www.codeproject.com/Articles/16310/How-to-Automate -Exporting-NET-Function-to-Unmanage)和[非託管代碼可以包裝託管方法](http://www.codeproject.com/Articles/8124/Unmanaged-code-can-wrap-managed-methods)。 – eryksun 2013-03-12 04:52:29