Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi importierte COM TLB lässt sich nicht compilieren. (https://www.delphipraxis.net/99988-importierte-com-tlb-laesst-sich-nicht-compilieren.html)

stoxx 20. Sep 2007 16:20


importierte COM TLB lässt sich nicht compilieren.
 
komische Sache .... eine importierte erzeugte TLB Datei aus einem COM Object lässt sich nicht compilieren, mit der Meldung
"Inkompatible Typen: 'CQGCELConfiguration' und 'Variant'

in folgendem Code, in der Zeile: (Result := InterfaceVariant.Configuration) kommt diese Meldung

Delphi-Quellcode:
function TCQGCEL.Get_Configuration: CQGCELConfiguration;
var
  InterfaceVariant : OleVariant;
begin
  InterfaceVariant := DefaultInterface;
  Result := InterfaceVariant.Configuration;
end;
mit folgenden definierten Typen:

Delphi-Quellcode:
  CQGCELConfiguration = packed record
    TimeZoneCode: eTimeZone;
    MaxLogFileCount: Integer;
    MaxLogFileDuration: TDateTime;
    MaxLogFileSize: Integer;
    LogSeverity: eLogSeverity;
    ReadyStatusCheck: eReadyStatusCheck;
    DefaultInstrumentSubscriptionLevel: eDataSubscriptionLevel;
    MetaDataEnabled: WordBool;
    DOMUpdatesPeriod: Integer;
    DOMUpdatesMode: eDOMUpdatesMode;
  end;

DefaultInterface ist vom folgendem Typ:


Delphi-Quellcode:
property DefaultInterface: ICQGCEL read GetDefaultInterface;
Delphi-Quellcode:
// *********************************************************************//
// Interface: ICQGCEL
// Flags:    (4432) Hidden Dual OleAutomation Dispatchable
// GUID:     {394F6140-80BC-4C58-BA4D-4AE0DF4EFFF5}
// *********************************************************************//
  ICQGCEL = interface(IDispatch)
    ['{394F6140-80BC-4C58-BA4D-4AE0DF4EFFF5}']
    function Get_Configuration: CQGCELConfiguration; safecall;
    procedure Set_Configuration(var pVal: CQGCELConfiguration); safecall;
    function Get_Accounts: ICQGAccounts; safecall;
    function Get_Environment: ICQGEnvironment; safecall;
    function Get_Instruments: ICQGInstruments; safecall;
    function Get_Logger: ICQGLogger; safecall;
    function Get_IsStarted: WordBool; safecall;
    function Get_AccountSubscriptionLevel: eAccountSubscriptionLevel; safecall;
    procedure Set_AccountSubscriptionLevel(pVal: eAccountSubscriptionLevel); safecall;
    function Get_CurrencyRates: ICQGCurrencyRates; safecall;
    function Get_APIConfiguration: ICQGAPIConfig; safecall;
    function Get_Orders: ICQGOrders; safecall;
    function Get_InternalOrders: ICQGOrders; safecall;
    procedure Startup; safecall;
    procedure Shutdown; safecall;
    procedure NewInstrument(const symbol: WideString); safecall;
    procedure RemoveInstrument(const Instrument: ICQGInstrument); safecall;
    procedure RemoveAllInstruments; safecall;
    function IsValid(inVal: OleVariant): WordBool; safecall;
    procedure RequestCommodityInstruments(const commodityName: WideString;
                                          instrumentTypes: eInstrumentType; tradableOnly: WordBool); safecall;
    function CreateOrder(orderType: eOrderType; const Instrument: ICQGInstrument;
                         const Account: ICQGAccount; orderQuantity: Integer; orderSide: eOrderSide;
                         LimitPrice: Double; StopPrice: Double; const ueNamePart: WideString): ICQGOrder; safecall;
    procedure CancelAllOrders(const Account: ICQGAccount; const Instrument: ICQGInstrument;
                              fromAllTraders: WordBool; parked: WordBool; Side: eOrderSide); safecall;
    procedure ActivateAllOrders(const Account: ICQGAccount; const Instrument: ICQGInstrument;
                                fromAllTraders: WordBool; Side: eOrderSide); safecall;
    function QueryOrders(const Account: ICQGAccount; const Instrument: ICQGInstrument;
                         statusFilter: eOrderStatusFilter; date: TDateTime; Side: eOrderSide): ICQGOrdersQuery; safecall;
    function Get_ActiveTimeSeries: ICQGTimeSeriesCollection; safecall;
    function QueryBars(const barsRequest: ICQGBarsRequest; RangeStart: OleVariant;
                       RangeEnd: OleVariant; Period: Integer;
                       SubscriptionLevel: eTimeSeriesSubscriptionLevel; includeEnd: WordBool;
                       SessionFilter: OleVariant; continuation: eBarsContinuationType;
                       EqualizeCloses: WordBool; DaysBeforeExpiration: Integer): ICQGTimeSeries; safecall;
    function QueryTicks(const symbol: WideString; requestType: eTicksRequestType;
                        RangeStart: TDateTime; RangeEnd: TDateTime): ICQGTimeSeries; safecall;
    procedure RemoveTimeSeries(const timeSeries: ICQGTimeSeries); safecall;
    procedure RemoveAllTimeSeries; safecall;
    procedure RequestUserFormulas(formulaType: eUserFormulaType); safecall;
    procedure RequestDataSources; safecall;
    procedure RequestDataSourceSymbols(const dataSourceName: WideString); safecall;
    procedure RequestCustomSessions; safecall;
    function NewBarsRequest(const ExpressionString: WideString): ICQGBarsRequest; safecall;
    procedure RequestTradableCommodities(GWAccountID: Integer); safecall;
    property Accounts: ICQGAccounts read Get_Accounts;
    property Environment: ICQGEnvironment read Get_Environment;
    property Instruments: ICQGInstruments read Get_Instruments;
    property Logger: ICQGLogger read Get_Logger;
    property IsStarted: WordBool read Get_IsStarted;
    property AccountSubscriptionLevel: eAccountSubscriptionLevel read Get_AccountSubscriptionLevel write Set_AccountSubscriptionLevel;
    property CurrencyRates: ICQGCurrencyRates read Get_CurrencyRates;
    property APIConfiguration: ICQGAPIConfig read Get_APIConfiguration;
    property Orders: ICQGOrders read Get_Orders;
    property InternalOrders: ICQGOrders read Get_InternalOrders;
    property ActiveTimeSeries: ICQGTimeSeriesCollection read Get_ActiveTimeSeries;
  end;
hmmmm .....

Apollonius 20. Sep 2007 16:47

Re: importierte COM TLB lässt sich nicht compilieren.
 
Ich kenne mich mit der Materie zwar nicht gut aus, aber die Methoden von COM-Interfaces müssen meines Wissens Variants bzw. dazu kompatible Interfaces zurückgeben, und somit ist dein Record nicht kompatibel.

stoxx 20. Sep 2007 16:55

Re: importierte COM TLB lässt sich nicht compilieren.
 
das ist ja nicht mein Record, sondern die TLB wurde aus dem Com Object von Delphi alles selber erzeugt, ich hab nix daran gemacht ! :-)

Apollonius 20. Sep 2007 16:57

Re: importierte COM TLB lässt sich nicht compilieren.
 
Das gibt es durchaus, dass Programme ihren eigenen Kram nicht erkennen...

stoxx 20. Sep 2007 17:30

Re: importierte COM TLB lässt sich nicht compilieren.
 
Zitat:

Zitat von Apollonius
Das gibt es durchaus, dass Programme ihren eigenen Kram nicht erkennen...

wie, was programme? nix programm. Com Object ..OCX quasi ..
muss an Delphi liegen ... Unter Visual Studio ist es wohl getestet, (Beispiele liegen dabei)
nur für Delphi gibts wieder nix ...
Die beiligenden Excelbeispiele funktionieren auch einwandfrei (VBA) !!
Aber nur in Delphi lässt sich das mal wieder nicht importieren ..

Apollonius 20. Sep 2007 17:50

Re: importierte COM TLB lässt sich nicht compilieren.
 
Delphi ist auch ein Programm. :-D

negaH 20. Sep 2007 18:08

Re: importierte COM TLB lässt sich nicht compilieren.
 
Eine Variante kann in Delphi, wenn ich nicht falsch liege, keine Records aufnehmen.

Gruß Hagen

marabu 20. Sep 2007 20:19

Re: importierte COM TLB lässt sich nicht compilieren.
 
Hallo stoxx,

seit CQG API V3.0 ist doch die Structure Configuration durch das Interface ApiConfig ersetzt worden. Du scheinst ja die aktuelle V4.0 importiert zu haben. Kannst du den Delphi-untauglichen Teil nicht einfach eliminieren sprich zwangsweise kompatibel machen? Benutzen sollst du Configuration (deprecated) ja eh nicht mehr.

Grüße vom marabu

stoxx 23. Sep 2007 23:52

Re: importierte COM TLB lässt sich nicht compilieren.
 
Zitat:

Zitat von marabu
Hallo stoxx,

seit CQG API V3.0 ist doch die Structure Configuration durch das Interface ApiConfig ersetzt worden. Du scheinst ja die aktuelle V4.0 importiert zu haben. Kannst du den Delphi-untauglichen Teil nicht einfach eliminieren sprich zwangsweise kompatibel machen? Benutzen sollst du Configuration (deprecated) ja eh nicht mehr.

Grüße vom marabu

ups, hier kennt sich echt jemand mit CQG aus? ... also ich hab dann die Teile wirklich einfach entfernt. Dann ging es zu compilieren. Dass dieser Teil deprecated ist wusste ich ja nicht.

Ich hab hier aber schon das nächste sehr komische Problem, ich kann nicht auf die Interfaces in den Events zugreifen. Da bekomm ich zugriffsverletzungen. Ich kann das Interface Account nicht verwenden.
Komischerweise steht in der Variablen der richtige Account. Bei verwendung von try except ist die Variable ganz leer.
Geht das bei Dir?

Delphi-Quellcode:
//==============================================================================
procedure TForm1.CQGCELAccountChanged(ASender: TObject; change: TOleEnum;
  const Account: ICQGAccount; const position: ICQGPosition);

var
strAccount : String;

begin


    strAccount := Account.GWAccountName; // stürzt zwar mit einer Exception ab
    Showmessage(strAccount);             // zeigt aber trotzdem den korrekten Account an

marabu 24. Sep 2007 05:45

Re: importierte COM TLB lässt sich nicht compilieren.
 
Moin

Zitat:

Zitat von stoxx
... hier kennt sich echt jemand mit CQG aus? ...

Nicht wirklich, ich habe lediglich Zugriff auf die öffentlichen Infos - CQG ist bei mir nicht installiert.

Das vollständige Entfernen ist ja eine sehr brutale Methode. Unter Eliminieren hatte ich mir eigentlich eine etwas listigere Methode vorgestellt.

Delphi-Quellcode:
function TCQGCEL.Get_Configuration: CQGCELConfiguration;
var
  InterfaceVariant : OleVariant;
begin
  InterfaceVariant := DefaultInterface;
  Result := InterfaceVariant.Configuration;
end;
Wenn du Getter und Setter für Configuration später nie aufrufst, dann würde ich zwei Wege ausprobieren: Entweder die angemeckerte Zuweisung an Result entfernen oder den Typ des Funktionswertes zwangsweise anpassen. Wenn du Getter und Setter einfach entfernst, dann könnte das Probleme mit den internen Zeiger-Tabellen verursachen, die durchaus für die späteren Zugriffsfehler verantwortlich sein könnten.

Freundliche Grüße


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:23 Uhr.
Seite 1 von 2  1 2      

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