M
Mike
I have been banging my head againt my desk for a couple days now and nothing
I try seems to work. I know I am missing something small and it's killing
me.
This is the error I am getting with this code:
A call to PInvoke function
'SmartworksTest!SmartworksTest::MTGetEventCodeDescription' has unbalanced
the stack. This is likely because the managed PInvoke signature does not
match the unmanaged target signature. Check that the calling convention and
parameters of the PInvoke signature match the target unmanaged signature.
I have also tried to use char arrays and IntPtr instead of the string. The
char array give me a memory error and I can't get any useful information
from the IntPtr.
Thanks in advance for you help.
Here is the C++ definition I need to call
void MTGetEventCodeDescription(
const ULONG EventCode,
const PCHAR pDescription,
const int nLength
);
Here is my C# code:
[DllImport("NtiDrv.dll", EntryPoint = "MTGetEventCodeDescription", CharSet =
CharSet.Auto)]
public static extern void MTGetEventCodeDescription(uint returnCode, out
string pDescription,out short nLength);
public static string GetEventCodeDescription(uint eventCode)
{
uint ret;
string desc;
short size = 0;
MTGetEventCodeDescription(eventCode, out desc, out size);
return (desc.ToString());
}
I try seems to work. I know I am missing something small and it's killing
me.
This is the error I am getting with this code:
A call to PInvoke function
'SmartworksTest!SmartworksTest::MTGetEventCodeDescription' has unbalanced
the stack. This is likely because the managed PInvoke signature does not
match the unmanaged target signature. Check that the calling convention and
parameters of the PInvoke signature match the target unmanaged signature.
I have also tried to use char arrays and IntPtr instead of the string. The
char array give me a memory error and I can't get any useful information
from the IntPtr.
Thanks in advance for you help.
Here is the C++ definition I need to call
void MTGetEventCodeDescription(
const ULONG EventCode,
const PCHAR pDescription,
const int nLength
);
Here is my C# code:
[DllImport("NtiDrv.dll", EntryPoint = "MTGetEventCodeDescription", CharSet =
CharSet.Auto)]
public static extern void MTGetEventCodeDescription(uint returnCode, out
string pDescription,out short nLength);
public static string GetEventCodeDescription(uint eventCode)
{
uint ret;
string desc;
short size = 0;
MTGetEventCodeDescription(eventCode, out desc, out size);
return (desc.ToString());
}