views:

187

answers:

3

Hi
I need to access functionality from win32 dll , for that I am using [dllimport] in C# code.


what exact method signature i need to create with [dllimport] for the following c++ methods

void GetGeneratedKey(char *code, int len, char *key)

pls help in this.

Thanks
nRk

+1  A: 

Just use string. Should just work.

leppie
+3  A: 

This depends highly on what is happening to the variables key and code in the native C function. Based on the signature I am guessing that code is being read from and key is being written to. If that is the case then try the following signature

[DllImport("SomeDll")]
public static extern void GetGeneratedKey(
  [In] string code,
  [In] int length,
  StringBuilder key);
JaredPar
A: 

Thanks everybody for the quick reply and support
I used method signature like the below

VC++ method signature
void GetGeneratedKey(char *code, int len, char *key)

C# signature
[DllImport("SomeDll")]
public static extern void GetGeneratedKey(byte[] code, int len, bute key);

Thanks
nRk

nRk