MHumm / ComPortDriver

Win32/64 COM-Port component for Delphi
Apache License 2.0
49 stars 18 forks source link

64bit windows, Exception 'Range check error' #3

Closed dslutej closed 1 year ago

dslutej commented 1 year ago

Range check error on FHandle assignment (, see below:

constructor TCommPortDriver.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  // Not connected
  FHandle                    := INVALID_HANDLE_VALUE;  <<< BOOM

FHandle is defined as HFILE, which is defined as LongWord. Change to THandle.

  TCommPortDriver = class(TComponent)
  protected
    /// <summary>
    ///   Device Handle (File Handle)
    /// </summary>
    FHandle                    : THandle; <<< Here and elsewhere. 
MHumm commented 1 year ago

I just implemented your fix in development branch and I added another one: I added a flag which prevents "nested"/"reetrant" calls of the timer event which polls the port. I had a case lately where calling MessageDlg (which in the background polls Windows messages and thus processes the WM_TIMER message again because it's not yet removed while we're in the OnTimer event :-( ) led to an endless loop of some sort displaying countless MessageDlgs.

That said: can you test my modifications and tell me whether that still works? I don't have a serial device for testing at hand right now. If they work, I'd release this as V3.1 in GetIt as well.

dslutej commented 1 year ago

@MHumm sorry for the delay, just tested it and it works.

MHumm commented 1 year ago

Thanks for testing, so I can close this one now.

MHumm commented 1 year ago

With that feedback I created a V3.1 release now.