IntPtr in c#
Hi,
im new in c# and id like to work with winmm.dll from windows.
so i imported it this way:
[DllImport("winmm.dll")]
extern static int mciSendString(string command,
IntPtr responseBuffer, int bufferLength, int nothing);
which works fine for me. But now i want to read a string out of my responseBuffer and i dont know how to de-referncate. In good old "c" iwould have used the " * " operator, so plz tell me what to use/do in c#.
thx yas stefan
8 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Mike GoldRank #50 · 30.6K pointsPosted Mar 27, 2006, 4:45 AM EST
string theString = Marshal.PtrToStringAnsi(ResponseBuffer);
best,
Mike G.
hans6 pointsPosted Mar 27, 2006, 8:14 AM EST
Brandon Turner54 pointsPosted Mar 27, 2006, 3:56 PM EST
hans6 pointsPosted Mar 28, 2006, 10:05 AM EST
Brandon Turner54 pointsPosted Mar 28, 2006, 10:53 AM EST
Nate4 pointsPosted Mar 29, 2006, 8:23 AM EST
Brandon Turner54 pointsPosted Mar 29, 2006, 8:48 AM EST
Nate4 pointsPosted Mar 29, 2006, 9:03 AM EST
cannot convert from 'ref string[]' to 'System.IntPtr'
I had something like this in my code.
string[] myStringArray = { "one", "two", "three", "four" };
function(ref myStringArray);
Is that what you said to do? There has got to be more, but I am not sure what it is.