String to char* in DLL
-
Dear All, I have a DLL with method signature like this : void printname (char* name) I tried using the following code to to make use of my method: ----------------------- string s="abc.xml"; char[] b = new char[100]; s.CopyTo(0,b,0,20); unsafe { fixed (char* p=b); printname(p); } ------------------------ but it seems not working.... can anyone give me some hints ?? Thanks, Leslie
-
Dear All, I have a DLL with method signature like this : void printname (char* name) I tried using the following code to to make use of my method: ----------------------- string s="abc.xml"; char[] b = new char[100]; s.CopyTo(0,b,0,20); unsafe { fixed (char* p=b); printname(p); } ------------------------ but it seems not working.... can anyone give me some hints ?? Thanks, Leslie
(char* name) Means it is a single char right ? or else it should be (char** name) if it is an array. May be it needs the first Position. try s[0] where s is a string in your case
Shyam.. My Blog dotnetscoups.blogspot.com
-
Dear All, I have a DLL with method signature like this : void printname (char* name) I tried using the following code to to make use of my method: ----------------------- string s="abc.xml"; char[] b = new char[100]; s.CopyTo(0,b,0,20); unsafe { fixed (char* p=b); printname(p); } ------------------------ but it seems not working.... can anyone give me some hints ?? Thanks, Leslie
-
Dear All, I have a DLL with method signature like this : void printname (char* name) I tried using the following code to to make use of my method: ----------------------- string s="abc.xml"; char[] b = new char[100]; s.CopyTo(0,b,0,20); unsafe { fixed (char* p=b); printname(p); } ------------------------ but it seems not working.... can anyone give me some hints ?? Thanks, Leslie
You don't need the char array. char* tends to be strings, you may be able to pass a .net string in directly. Otherwise, maybe
fixed (char* p=s)
Plus you shouldn't have the semi-colon after the fixed statement. -
You don't need the char array. char* tends to be strings, you may be able to pass a .net string in directly. Otherwise, maybe
fixed (char* p=s)
Plus you shouldn't have the semi-colon after the fixed statement.