Autor Beitrag
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: Sa 31.12.05 17:56 
Hallo,

ich habe ein Formular in eine DLL gepackt. Es funktioniert auch alles wunderbar. Nun wollte ich mit den ADO-Komponenten über MySQL ODBC 3.51 Driver auf eine MySQL-Datenbank zugreifen.
Wenn ich jetzt das Formular aufrufe mit :
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TMainControl.Address_AdministrationClick(Sender: TObject);
var
   hDLL : THandle;
   AddressWindow : TAddressWindow;
begin
   hDLL := LoadLibrary(PChar(ExtractFilePath(ParamStr(0))+'address.dll'));
   if hDLL <> 0 then begin
     try
       AddressWindow := GetProcAddress(hDLL, 'address_administration');
       AddressWindow(Application.Handle);
     finally
       FreeLibrary(hDLL);
     end;
   end;
end;


Bekomme ich den folgenden Fehler :

Zitat:
Project xxx.exe raised exception class EOleSysError with message 'CoInitialize wurde nicht aufgerufen'. Process stopped. Use Step or Run to continue.


Dieser Fehler tritt bei Zeile 20 auf im Projektcode von der DLL :

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
library address;

uses
  SysUtils,
  Classes,
  Windows,
  Forms,
  Controls,
  ExtCtrls,
  AddressAdministrationUnit in 'AddressAdministrationUnit.pas' {AddressAdministration},
  FunctionUnit in '..\Funktionsunits\FunctionUnit.pas';

{$R *.res}

procedure address_administration(appHandle: THandle); stdcall;
begin
  if appHandle = 0 then apphandle := GetActiveWindow;
  Application.Handle := appHandle;
  try
    with TAddressAdministration.Create(Application) Do
      try
        ShowModal
      finally
        Free;
      end
  except
    On E: Exception Do Application.HandleException(E);
  end;
  Application.Handle := 0;
end;

exports
  address_administration;

begin
end.


Kann mir da jemand weiterhelfen. Ich habe keine Ahnung, woran es liegt.
Bernhard Geyer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 721
Erhaltene Danke: 3



BeitragVerfasst: Di 03.01.06 11:28 
Titel: Was ist wohl der Fehler?
Goolge mal nach "CoInitialize wurde nicht aufgerufen" und du findest 1000fach die gleiche Lösung CoInitialize aufzurufen. In einer Exe wird das von Application.Initialize im "Hintergrund" schon automatisch erledigt.