我正在使用当前在vb6中运行正常的旧dll文件函数,声明如下:
Public Declare Function DecOutb Lib "DecLib.dll" Alias "_outportb@8" _
(ByVal PortAddress As Long, ByVal state As Byte) As Long
Public Declare Function DecOutLong Lib "DecLib.dll" Alias "_outport@8" _
(ByVal PortAddress As Long, ByVal state As Long) As Long
功能的实现是这样的:
k = DecOutLong(ad_addr, Data)
成功时返回k = 1,它是。
然而,当我把它放在我的.net C#上时,即使我没有收到任何警告或错误,但该功能不起作用,返回k = 0。我所做的宣言是这样的:
[DllImport("DecLib.dll", EntryPoint = "_outport@8", CallingConvention = CallingConvention.StdCall)]
public static extern int DecOutLong(int PortAddress, int State);
实施是这样的:
k = DecOutLong(ad_addr, DATA);
答案 0 :(得分:0)
固定,我遵循了tcarvin的建议并将其设置为编译为x86而不是"任何PC"。我怀疑在这种情况下还有更多要澄清,但至少它有效。