| Autor |
Beitrag |
Marco D.
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Fr 08.12.06 14:40
Ich möchte mit dem COM-Port arbeiten. Dazu habe ich das gefunden. Allerdings mag Delphi das "ComFile" nicht. Was muss ich da noch einbinden?
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Zuletzt bearbeitet von Marco D. am Fr 08.12.06 21:59, insgesamt 3-mal bearbeitet
|
|
GTA-Place
      

Beiträge: 5248
Erhaltene Danke: 2
WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
|
Verfasst: Fr 08.12.06 21:15
Dein Link verweißt ins Leere, ich denk mal du meinst:
www.swissdelphicente.../showcode.php?id=841
ComFile ist vom Typ THandle, siehe obere Funktion.
_________________ "Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
|
|
Marco D. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Fr 08.12.06 21:58
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
| function Read: string; var d: array[1..80] of Char; s: string; BytesRead, i: Integer; ComFile: THandle; begin Result := ''; if not ReadFile(ComFile, d, SizeOf(d), BytesRead, nil) then begin end; s := ''; for i := 1 to BytesRead do s := s + d[I]; Result := s; end; |
Fehler: [Fehler] ComPort.pas(7  : Die Typen der tatsächlichen und formalen Var-Parameter müssen übereinstimmen
Was tun?
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
aim65
      
Beiträge: 312
Win 9x, Win XP
Delphi 3pro, 7PE
|
Verfasst: Fr 08.12.06 23:26
Habe das mal in der Windows.pas gefunden:
| Zitat: | function ReadFile(hFile: THandle; var Buffer; nNumberOfBytesToRead: DWORD;
var lpNumberOfBytesRead: DWORD; lpOverlapped: POverlapped): BOOL; stdcall; |
Könnte es sein, daß der Fehler darin liegt, daß BytesRead als Integer deklariert wird, aber die Windows-DLL ein DWORD erwartet? Nur mal geraten.
Probier auch mal "PortHandle" statt "ComFile"
Auch evtl. "d[1]" statt "d".
Edit: Habe eben mal Deine Funktion kopiert und einfach in einen ButtonClick eingebaut. Bei mir compiliert's ohne Fehlermeldung. Auch zur Laufzeit gibt's nix (krieg halt einen leeren String zurück, da ich ja nix einlese)
Der o.g. Kram wird wahrscheinlich dann auch nicht helfen.. 
|
|
Marco D. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Sa 09.12.06 16:06
Habe das jetzt so:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
| function TComPort.Read: string; var d: array[1..80] of Char; s: string; BytesRead, i: Integer; begin Result := ''; if not ReadFile(FComFile, d, SizeOf(d), dword(BytesRead), nil) then begin end; s := ''; for i := 1 to BytesRead do s := s + d[I]; Result := s; end; |
Und es compiliert schon mal ...
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
JDKDelphi
      
Beiträge: 115
Erhaltene Danke: 22
WIN2000, XP, WIN 7 , UNIX, LINUX
Assembler für (Z8x, 68xxx,R6000,Intel), DELPHI 6 Enterprise, MAGIC eDeveloper V9+V10, C++, C#,VB, .NET, zertifizierter iBOLT-Programmierer
|
Verfasst: Sa 09.12.06 18:07
Titel: serieller Port
hallo,
ich nutze das OCX von Windows problemlos wie in VB6.
gruss
jdkdelphi
|
|
Marco D. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: Sa 09.12.06 18:11
Titel: Re: serieller Port
JDKDelphi hat folgendes geschrieben: | hallo,
ich nutze das OCX von Windows problemlos wie in VB6.
gruss
jdkdelphi |
Aha, und wo ist der Bezug zur Frage? 
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
Marco D. 
      
Beiträge: 2750
Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
|
Verfasst: So 10.12.06 17:25
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7:
| FComFile := CreateFile(DeviceName, GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); |
Warum bekomme ich hier immer eine Zugriffsverletzung? FComFile ist vom Typ THandle.
_________________ Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
|
|
alzaimar
      
Beiträge: 2889
Erhaltene Danke: 13
W2000, XP
D6E, BDS2006A, DevExpress
|
Verfasst: So 10.12.06 18:37
Hier, alt aber gut:
Einloggen, um Attachments anzusehen!
_________________ Na denn, dann. Bis dann, denn.
|
|
|