Red Gate forums :: View topic - Need c# represenmtation of method signature for C
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
PInvoke.Net
PInvoke.Net forum

Need c# represenmtation of method signature for C

Search in PInvoke.Net forum
Post new topic   Reply to topic
Jump to:  
Author Message
chitrarasan



Joined: 20 Jul 2011
Posts: 1

PostPosted: Wed Jul 20, 2011 3:41 pm    Post subject: Need c# represenmtation of method signature for C Reply with quote

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
View user's profile Send private message
Brian Donahue



Joined: 23 Aug 2004
Posts: 6581

PostPosted: Wed Jul 20, 2011 4:56 pm    Post subject: Reply with quote

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)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic 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