Hallo,
es funktioniert!!!
Hab hier nochmal die wichtigsten Zeilen für die Umsetzung in C# angeführt!!
Code
- public class AIN
- {
- protected IntPtr hPort;
- public void AINPort(string Port)
- {
- hPort = CreateFile(Port, 3221225472, 0, IntPtr.Zero, 3, 0, IntPtr.Zero);
- }
- public Byte[] ReadValue()
- {
- Byte[] Data = new Byte[2];
- ReadFile(hPort,Data,2,0,IntPtr.Zero);
- return Data;
- }
- public void Close()
- {
- CloseHandle(hPort);
- }
- [DllImport("coredll.dll", EntryPoint = "CreateFileW", SetLastError = true)]
- public extern static IntPtr CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr pSecurityAttributes,
- uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
- [DllImport("coredll.dll", EntryPoint = "CloseHandle", SetLastError = true)]
- public extern static int CloseHandle(IntPtr hObject);
- [DllImport("coredll.dll", EntryPoint = "ReadFile", SetLastError = true)]
- public extern static uint ReadFile(IntPtr hObject,Byte[] lpBuffer, uint NumberOfBytesToRead,uint NumberOfBytes,
- IntPtr lpOverLapped);
- }
An dieser Stelle nochmal ein großes Dankeschön an Hr. Zutter u. Hr. Keller!!
Grüße, Mike