Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dllimport PocketPC (compact framework) for Functions taking char*

Status
Not open for further replies.

fionn

Programmer
Nov 25, 2004
2
AT
Hello,

i got a problem - i have a function inside a DLL with this signature

char *function(char *buffer);

In buffer there would be stored some text after calling the function. With StringBuilder i have to problem that it returns the string as wchar_t on pocketpc (and in fact two chars (char) form one wchar_t char then which produces garbage output.

Currently i am using it like this:
[DllImport("CFReader.dll")]
public static extern IntPtr DetectSerialPort([MarshalAs(UnmanagedType.LPStr)]StringBuilder buf);

StringBuilder temp_buffer = new StringBuilder(11);
DetectSerialPort(temp_buffer);
return temp_buffer.ToString();
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top