I'm using an old dll file function that is currently working ok in vb6, declared like this:
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
The implementation of the funcion is this:
k = DecOutLong(ad_addr, Data)
It returns k=1 when it is successful, and it is.
However when I put this on my .net C#, even if I don't get any warning or error, but the function does not work, returning k=0. The declaration I'm making is like this:
[DllImport("DecLib.dll", EntryPoint = "_outport@8", CallingConvention = CallingConvention.StdCall)]
public static extern int DecOutLong(int PortAddress, int State);
And the implementation is this:
k = DecOutLong(ad_addr, DATA);
FIXED, I followed tcarvin's advice and set it to compile to x86 instead of "Any PC". I'm suspecting there is more to clarify in this situation, but at least it works.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.