M
Mario
Hi,
I am having problems passing a correct argument that was using enum.
Hopefully someone can she some light.
// C++ enum from header file for the driver
typedef enum{
Port_A,
Port_B,
Port_C,
Port_D,
} G_PORTS;
//driver method signature
INT8 GetPortState(PORTHANDLE phandle, G_PORTS port, UINT32 signal)
//C# translation of the enum
public enum G_PORTS
{
Port_A,
Port_B,
Port_C,
Port_D
}
//C# P/Invoke
[DllImport("mylib.dll")]
public static extern UInt16 GetPortState(IntPtr phandle, G_PORTS port,
UINT32 signal);
//first implementation of the method call in application
SignalRead = GetPortState(phandle, G_PORTS.Port_D, 0x10000000);
After making the method call...I was not getting what I expected and I
stepped through the code to the driver. I found out that that
arguments that I passed as G_PORTS.Port_D was passed to the driver as
G_PORTS.Port_A. Could someone explain why is so? Thanks.
-- mario
I am having problems passing a correct argument that was using enum.
Hopefully someone can she some light.
// C++ enum from header file for the driver
typedef enum{
Port_A,
Port_B,
Port_C,
Port_D,
} G_PORTS;
//driver method signature
INT8 GetPortState(PORTHANDLE phandle, G_PORTS port, UINT32 signal)
//C# translation of the enum
public enum G_PORTS
{
Port_A,
Port_B,
Port_C,
Port_D
}
//C# P/Invoke
[DllImport("mylib.dll")]
public static extern UInt16 GetPortState(IntPtr phandle, G_PORTS port,
UINT32 signal);
//first implementation of the method call in application
SignalRead = GetPortState(phandle, G_PORTS.Port_D, 0x10000000);
After making the method call...I was not getting what I expected and I
stepped through the code to the driver. I found out that that
arguments that I passed as G_PORTS.Port_D was passed to the driver as
G_PORTS.Port_A. Could someone explain why is so? Thanks.
-- mario