G
Guest
Any body knows how to convert this DLL function to C# ?
DWORD WINAPI
importfunction(LPSTR lpBuffer, LPDWORD nSize);
DWORD WINAPI
importfunction(LPSTR lpBuffer, LPDWORD nSize);
centrino said:Any body knows how to convert this DLL function to C# ?
DWORD WINAPI
importfunction(LPSTR lpBuffer, LPDWORD nSize);
centrino said:Any body knows how to convert this DLL function to C# ?
DWORD WINAPI
importfunction(LPSTR lpBuffer, LPDWORD nSize);
Willy Denoyette said:centrino said:Any body knows how to convert this DLL function to C# ?
DWORD WINAPI
importfunction(LPSTR lpBuffer, LPDWORD nSize);
[DllImport("your.dll", CallingConvention = CallingConvention.StdCall)]
static extern importfunction
(
[MarshalAs(UnmanagedType.LPTStr)]
string lpBuffer,
ref int nSize
);
Willy.
centrino said: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 said:centrino said: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
);
:
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.
centrino said:Hi Willy,
Thanks for your post !
I get the the size of the buffer returned nSize, but i "see" notthing in
StringBuffer lpBuffer.
StringBuilder lpBuffer = new StringBuilder(256);
The function return ERROR_SUCCESS=0 and NDIS_ERROR_SUCCESS=0. It seems
correct !?
i dont know why ! I tryed to get buffer with byte[], but i get notthing.
regards
Willy Denoyette said:centrino said: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
);
:
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.
centrino said:Hi Willy,
Thanks for your post !
I get the the size of the buffer returned nSize, but i "see" notthing in
StringBuffer lpBuffer.
StringBuilder lpBuffer = new StringBuilder(256);
The function return ERROR_SUCCESS=0 and NDIS_ERROR_SUCCESS=0. It seems
correct !?
i dont know why ! I tryed to get buffer with byte[], but i get notthing.
regards