Hi Mattias,
i get error code 87: // invalid parameter
int lasterror=Marshal.GetLastWin32Error();
Console.WriteLine( "lasterror:"+lasterror );
The hole thing should be:
BOOL WINAPI
ReadData(
LPVOID lpBuffer,
DWORD nNumberOfBytesToRead,
LPDWORD lpNumberOfBytesRead,
LPOVERLAPPED lpOverlapped
);
I do it so:
[DllImport("PCAImAPI", SetLastError=true)]
private static extern bool ReadData(
byte[] lpBuffer,
uint nNumberOfBytesToRead,
ref uint lpNumberOfBytesRead,
// [MarshalAs(UnmanagedType.LPStruct)]
OVERLAPPED lpOverlapped
);
[DllImport("kernel32.dll")]
private static extern IntPtr CreateEvent(
IntPtr lpEventAttributes,
bool bManualReset,
bool bInitialState,
string lpName);
[StructLayout(LayoutKind.Sequential)]
private struct OVERLAPPED
{
public UIntPtr Internal;
public UIntPtr InternalHigh;
public uint Offset;
public uint OffsetHigh;
public IntPtr EventHandle;
}
and:
OVERLAPPED Ovlp=new OVERLAPPED();
Ovlp.EventHandle=IntPtr.Zero;
Ovlp.Offset=0;
Ovlp.OffsetHigh=0;
Ovlp.EventHandle= CreateEvent(IntPtr.Zero, false, false,null);
reValue = ReadData(
PacketData,
(uint)PacketData.Length,
ref nBytesRead,
Ovlp
);
I think my ovlp struct is invalid, is'n it ?
"Mattias Sjögren" wrote:
but its'n work , what have i doing wrong ?
What exactly doesn't work? In what way is it failing?
Mattias
--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.