【发布时间】:2014-08-14 06:59:19
【问题描述】:
我需要从用 C# 编写的 dll 中使用 Python(32) 中的函数。 我使用 ctypes,但我收到错误消息:'找不到 z 函数'。我需要的函数名称是“z”,一个库名称是“ledscrcons.dll”。我已经从另一个应用程序(C#)检查了它,这个库运行良好,但 python 没有看到它。我不知道是什么问题?? 这是PScript的代码:
import sys
import string
from time import gmtime, strftime
from array import *
from ctypes import *
import ctypes
import clr
def SendStr(s, port):
mydll = clr.AddReference('ledscrcons.dll')
from ledscrcons import Class1
send = mydll.z
mydll.z.argtypes = [ctypes.c_char_p, ctypes.c_int]
mydll.z.restype = c_int
st = s.encode('cp1251')
i=2
count = 0
critcnt = 1
while i!=0 and count<critcnt:
i=send(c_char_p(st), c_int(port))
if i==2 :
print(str(i) + "dd")
if i==1 :
print(str(i) + 'dd')
if i==0 :
print('t')
count = count + 1
if count==critcnt:
if i==1:
print('kk')
if i==2:
print('uu')
return i
拜托,任何帮助都会很有用。
【问题讨论】:
-
您应该包含您尝试调用的 C# 函数声明