Autor Beitrag
magnitudo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 31

WIN 8.1

BeitragVerfasst: So 18.02.07 21:40 
Hallo zusammen,

wer kann mir bei meinem Interface-Problem weiterhelfen ? Leider habe ich noch keine Erfahrung mit Typelibrarys *.TLB und stecke deshalb momentan so richtig fest.

Es geht um folgendes:

Ich möchte mit Delphi auf das ASCOM-Interface zugreifen.

ASCOM ist ein standardisiertes Interface für Astronomische Produkte wie z.B. Teleskopmontierungen, Fokussiersysteme, motorisierte Beobachtungskuppeln usw.
All diese Komponenten kommunizieren z.B. per ASCOM mit ihren dazugehörigen Steuerungsprogrammen.

Nun gibt es von der ASCOM-Initiative ein kleines Beispielprogramm, (dieses steht auf der ASCOM-Seite zum Download bereit) welches erklärt, wie man mit Delphi auf das Interface zugreifen kann.

Es besteht aus einer .DLL und aus einer kleinen Formularanwendung, welche auf die DLL zugreift. Die .DLL selbst beinhaltet 4 Module:

- library TestFocuser;
- unit fSetupForm;
- unit TestFocuserUnit;
- unit TestFocuser_TLB;

Nach fehlerfreiem compilieren lässt sich die Formularanwendung starten und demonstriert die Funktionsweise.

Nun habe ich kleine Veränderungen in den Units fSetupForm und TestFocuserUnit vorgenommen, um die DLL an meine Bedürfnisse anzupassen und dann alle Projekte neu compiliert. Fehlerfrei ! Doch treten jetzt nach Start der Formularanwendung Fehler auf, welche auf ein nicht funktionierendes Interface hindeuten. Möchte ich z.B. dass in der DLL enthaltene SetupFormular aufrufen, tritt folgender Fehler auf:

Failed to load driver: Objekterstellung durch ActiveX-Komponente nicht möglich

Ich vermute, der Fehler tritt deshalb auf, weil ich die unveränderte Typelibrary mit dem Namen TestFocuser.TLB wieder mitcompiliert habe. Nun weis ich leider nicht, wofür diese Datei gut ist. Im Modul library TestFocuser wird sie, so wie ich das verstehe, mit dem Befehl {$R *.TLB} eingebunden.
Andererseits befindet sich in der DLL auch das Modul unit TestFocuser_TLB welches in einem mir noch nicht verständlichen Zusammenhang mit der Datei TestFocuser.TLB steht.

Compiliere ich alle Projekte der DLL neu, wird die Datei TestFocuser.TLB jedenfalls nicht auch neu erzeugt sondern bleibt unverändert.

Jetzt stellt sich mir die Frage, wie und wann wird diese *.TLB Datei überhaupt erzeugt ?
Müssen Veränderungen in den Units der DLL nicht auch in der *.TLB statt finden, damit beim compilieren ein funktionsfähiges Ergebnis erzielt wird ?


Und wie wird die DLL-Unit TestFocuser_TLB erzeugt. Ist die händisch programmiert oder wird diese womöglich von der externen TestFocuser.TLB automatisch generiert ? Wenn ja, wie und durch was wird dann die *.TLB generiert. Alles sehr verworren im Moment !

Wenn mir hier jemand weiterhelfen könnte wäre ich überaus dankbar.

Vielen Dank
Thomas
Heinle.Thomas@T-Online.de


Anbei der Sourcecode der TestFocuser_TLB

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:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
unit TestFocuser_TLB;

// ************************************************************************ //
// WARNING                                                                  //
// -------                                                                  //
// The types declared in this file were generated from data read from a     //
// Type Library. If this type library is explicitly or indirectly (via      //
// another type library referring to this type library) re-imported, or the //
// 'Refresh' command of the Type Library Editor activated while editing the //
// Type Library, the contents of this file will be regenerated and all      //
// manual modifications will be lost.                                       //
// ************************************************************************ //

// PASTLWTR : $Revision:   1.11.1.75  $
// File generated on 11/13/02 11:41:07 PM from Type Library described below.

// ************************************************************************ //
// Type Lib: C:\Delphi\SOURCE\ASCOM Test\TestFocuser.tlb
// IID\LCID: {7B97C308-647A-451C-B030-EB15DD2740D4}\0
// Helpfile: 
// HelpString: ASCOM TestFocuser Template Using Delphi
// Version:    1.0
// ************************************************************************ //

interface

uses Windows, ActiveX, Classes, Graphics, OleCtrls, StdVCL;

// *********************************************************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:      //
//   Type Libraries     : LIBID_xxxx                                    //
//   CoClasses          : CLASS_xxxx                                    //
//   DISPInterfaces     : DIID_xxxx                                     //
//   Non-DISP interfaces: IID_xxxx                                      //
// *********************************************************************//
const
  LIBID_TestFocuser: TGUID = '{7B97C308-647A-451C-B030-EB15DD2740D4}';
  IID_IFocuser: TGUID = '{FE0891EF-8754-47D7-B236-4F299FCE9B09}';
  CLASS_Focuser: TGUID = '{CD378386-EDAE-4544-9150-8AB67C0EF6AC}';
type

// *********************************************************************//
// Forward declaration of interfaces defined in Type Library            //
// *********************************************************************//
  IFocuser = interface;
  IFocuserDisp = dispinterface;

// *********************************************************************//
// Declaration of CoClasses defined in Type Library                     //
// (NOTE: Here we map each CoClass to its Default Interface)            //
// *********************************************************************//
  Focuser = IFocuser;


// *********************************************************************//
// Interface: IFocuser
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {FE0891EF-8754-47D7-B236-4F299FCE9B09}
// *********************************************************************//
  IFocuser = interface(IDispatch)
    ['{FE0891EF-8754-47D7-B236-4F299FCE9B09}']
    procedure SetupDialog; safecall;
    function Get_Absolute: WordBool; safecall;
    function Get_MaxStep: Integer; safecall;
    procedure Set_MaxStep(Value: Integer); safecall;
    function Get_TempCompAvailable: WordBool; safecall;
    property Absolute: WordBool read Get_Absolute;
    property MaxStep: Integer read Get_MaxStep write Set_MaxStep;
    property TempCompAvailable: WordBool read Get_TempCompAvailable;
  end;

// *********************************************************************//
// DispIntf:  IFocuserDisp
// Flags:     (4416) Dual OleAutomation Dispatchable
// GUID:      {FE0891EF-8754-47D7-B236-4F299FCE9B09}
// *********************************************************************//
  IFocuserDisp = dispinterface
    ['{FE0891EF-8754-47D7-B236-4F299FCE9B09}']
    procedure SetupDialog; dispid 1;
    property Absolute: WordBool readonly dispid 6;
    property MaxStep: Integer dispid 7;
    property TempCompAvailable: WordBool readonly dispid 8;
  end;

  CoFocuser = class
    class function Create: IFocuser;
    class function CreateRemote(const MachineName: string): IFocuser;
  end;

implementation

uses ComObj;

class function CoFocuser.Create: IFocuser;
begin
  Result := CreateComObject(CLASS_Focuser) as IFocuser;
end;

class function CoFocuser.CreateRemote(const MachineName: string): IFocuser;
begin
  Result := CreateRemoteComObject(MachineName, CLASS_Focuser) as IFocuser;
end;

end.