Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Datenmodul Zugriffsproblem (https://www.delphipraxis.net/14087-datenmodul-zugriffsproblem.html)

Steffen 1. Jan 2004 23:32


Datenmodul Zugriffsproblem
 
Hallo!

Ich habe folgenden Code:

Delphi-Quellcode:
unit uMailConnectionDataModule;

interface

uses
  SysUtils, Classes, IdSMTPServer, IdSMTP, IdTCPServer, IdPOP3Server,
  IdComponent, IdTCPConnection, IdTCPClient, IdMessageClient, IdPOP3,
  IdBaseComponent, IdMessage, Sockets, IdThreadMgr, IdThreadMgrDefault;

type
  TMailConnectionDataModule = class(TDataModule)
    POP3Client: TIdTCPClient;
    POP3Server: TIdTCPServer;

  private
    { Private-Deklarationen }
    ...
  public
    { Public-Deklarationen }

    function POP3ServerIsRunning : Boolean;
    ...
    procedure POP3ServerStop;
     ...
  end;

var
  MailConnectionDataModule: TMailConnectionDataModule;

implementation

function TMailConnectionDataModule.POP3ServerIsRunning : Boolean;
begin
  Result := POP3Server.Active
end;

procedure TMailConnectionDataModule.POP3ServerStop;
begin
  POP3Server.Active := False
end;

end.
Beim Aufruf von "POP3ServerStop" oder von "POP3ServerIsRunning" bekomme ich eine Speicherzugriffsverletzung...
Aber das hier funktioniert:

Delphi-Quellcode:
...
function TMailConnectionDataModule.POP3ServerIsRunning : Boolean;
begin
  Result := MailConnectionDataModule.POP3Server.Active
end;

procedure TMailConnectionDataModule.POP3ServerStop;
begin
  MailConnectionDataModule.POP3Server.Active := False
end;
...
Wenn ich nicht die Variable voranstelle (wie im 1ten Code-Ausschnitt) bekomme ich eine Speicherzugriffsverletzung beim Aufrufen einer der Methoden... was mache ich falsch? Normalerweise sollte der Code aus dem 1ten Beispiel doch auch funktionieren, oder!?

Gruß,
Steffen

sakura 1. Jan 2004 23:37

Re: Datenmodul Zugriffsproblem
 
Eigentlich sollte es gehen. Versuche mal Self. anstatt der Form-Variable voranzustellen.

...:cat:...

Steffen 1. Jan 2004 23:44

Re: Datenmodul Zugriffsproblem
 
Self geht nicht, das ist ja das komische...

Steffen 3. Jan 2004 23:50

Hilfe!
 
Kann mir hier bei keiner weiterhelfen? :?


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:44 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz