| Author |
Message |
chitrarasan
Joined: 20 Jul 2011 Posts: 1
|
Posted: Wed Jul 20, 2011 3:41 pm Post subject: Need c# represenmtation of method signature for C |
|
|
I have following method in c
BOOL Register(EnumPID,Enum AppID,const char *pServerID,const char *pDestSN,char *pUnlockCode,char Type,
long Level,long ExpireValue,long Len );
What is the C# method signature for the above c method? |
|
| Back to top |
|
 |
Brian Donahue
Joined: 23 Aug 2004 Posts: 6341 Location: Red Gate Software
|
Posted: Wed Jul 20, 2011 4:56 pm Post subject: |
|
|
PInvoke exists for a good reason, and that reason is that translating unmanaged calls to managed PInvoke calls is difficult and sometimes involves some trial and error. Microsoft have some very general guidelines here but the most important tip is to make sure the length of the datatypes is the same between PInvoke calls and the underlying unmanaged code. If you really have problems, it may be necessary to use the MarshalAs attribute to force the hand of Interop to use the right type.
But as a starting point I'd suggest
| Code: |
| bool Register(long PID, long AppID, [MarshalAs(UnmanagedType.LPWStr)] string pServerID, [MarshalAs(UnmanagedType.LPWStr)] string pDestSN, [MarshalAs(UnmanagedType.LPWStr)] string pUnlockCode, char Type, long Level, long ExpireValue, long Len) |
_________________ Brian Donahue
Technical Support
Red Gate Software Ltd.
44 (0)870 160 0037 ext 8521
US and CAN 1-866-RED GATE ext 8521 |
|
| Back to top |
|
 |
|
|
All times are GMT + 1 Hour
|
| Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group