"centrino" <ce******@discussions.microsoft.com> wrote in message
news:04**********************************@microsof t.com...
I don't know why i still get a empty buffer :
there is a other similar function:
DWORD WINAPI importfunction(
LPWSTR lpBuffer,
LPDWORD nSize
);
[DllImport("mydll", SetLastError=true)]
private static extern uint importfunction(
[MarshalAs(UnmanagedType.LPWStr)]
StringBuilder pBuffer,
ref uint pBufferSize
);
"Willy Denoyette [MVP]" wrote:
Sorry but this is not the signature I've posted, WINAPI means stdcall
calling convention, why did you change it.
Also changed is the string argument, now it is a LPWSTR, why the change?
Did you allocate a StringBuilder big enough to hold the returned string?
What is there returned as nSize?
The problem with PInvoke is that you really need the description of the
function, else you have to guess things like:
- LPWSTR is what a fixed size buffer or not, who allocates the buffer?
- nSize is what the size of the buffer returned or the size requested?
Willy.