(Gast)
n/a Beiträge
|
Re: USB Port abfragen mit Delphi?
18. Jan 2006, 12:35
Zitat von HorstBS:
Jetzt habe ich ein Problem mit der Kommunitkation. Laut anleitung muss ich ein Hex-Code schicken der ungefaehr so aufgebaut ist:
02 //Rahmen Begin
35 //Port 5 wird angesprochen
03 //Rahmen Ende
Na das sagt doch klar das man 3 Bytes schreiben soll.
Delphi-Quellcode:
var
count: longword;
command, inDummy: array [0..2] of Char;
USBWRITE:Boolean;
DeviceHandle :THandle;
begin
commmand[0] := #$02;
commmand[1] := #$35;
commmand[2] := #$03;
inDummy[0] := #0;
inDummy[1] := #0;
inDummy[2] := #0;
DeviceHandle := CreateFile(device, Generic_write, File_share_write, nil, open_existing, 0, 0);
USBWRITE := DeviceIoControl(DeviceHandle, $04,
@command[0], sizeof(command),
@inDummy[0], sizeof(inDummy),
count, NIL);
if usbwrite then begin Form1.Label2.Caption:='geht'; end else
begin Form1.Label2.Caption:='geht nicht'; end; //Das bekomme ich in dem Fall als Antwort.
CloseHandle (DeviceHandle);
end;
|
|
Zitat
|