title image


Smiley Re: Ansteuerung der seriellen Schnittstelle ohne MSCOMM.DLL
Mit dem .NET Framework 2.0 sind die ComPorts direkt ansprechbar.



Unter 1.x tut es die kernel32.dll



[DllImport("kernel32.dll", SetLastError=true)]

internal static extern IntPtr CreateFile(String lpFileName, UInt32 dwDesiredAccess, UInt32 dwShareMode,

IntPtr lpSecurityAttributes, UInt32 dwCreationDisposition, UInt32 dwFlagsAndAttributes,

IntPtr hTemplateFile);

[DllImport("kernel32.dll")]

internal static extern Boolean GetCommState(IntPtr hFile, ref DCB lpDCB);

[DllImport("kernel32.dll")]

internal static extern Boolean SetCommState(IntPtr hFile, [In] ref DCB lpDCB);

[DllImport("kernel32.dll")]

internal static extern Boolean SetCommMask(IntPtr hFile, UInt32 dwEvtMask);

[DllImport("kernel32.dll", SetLastError=true)]

public static extern Boolean ReadFile(IntPtr hFile, [Out] Byte[] lpBuffer, UInt32 nNumberOfBytesToRead,

out UInt32 nNumberOfBytesRead, IntPtr lpOverlapped);

[DllImport("kernel32.dll", SetLastError=true)]

internal static extern Boolean WriteFile(IntPtr fFile, Byte[] lpBuffer, UInt32 nNumberOfBytesToWrite,

out UInt32 lpNumberOfBytesWritten, IntPtr lpOverlapped);

[DllImport("kernel32.dll")]

internal static extern Boolean CloseHandle(IntPtr hObject);

[DllImport("kernel32.dll", SetLastError=true)]

private static extern bool EscapeCommFunction(IntPtr hFile, uint dwFunc);

geschrieben von

Login

E-Mail:
  

Passwort:
  

Beitrag anfügen

Symbol:
 
 
 
 
 
 
 
 
 
 
 
 
 

Überschrift: