AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Delphi COM / DLL-Einbindung für Anfänger
Thema durchsuchen
Ansicht
Themen-Optionen

COM / DLL-Einbindung für Anfänger

Ein Thema von wurzelsepp1 · begonnen am 17. Okt 2023 · letzter Beitrag vom 4. Nov 2023
Antwort Antwort
wurzelsepp1

Registriert seit: 9. Dez 2012
74 Beiträge
 
Delphi 3 Professional
 
#1

COM / DLL-Einbindung für Anfänger

  Alt 17. Okt 2023, 17:08
Moin Gemeinde,

wieder eine der fürchterlichen Anfängerfragen:

Ich möchte einige Funktionen aus einer externen Druck-DLL nutzen. Der Compiler stolpert aber über eine fehlerhafte Einbindung (forward-Deklaration):

Wrapper (Auszug):
Delphi-Quellcode:
const
IID_IDymoAddIn: TGUID = '{09DAFAE1-8EB0-11D2-8E5D-00A02415E90F}';

type
IDymoAddIn = interface;

IDymoAddIn = interface(IDispatch)
    ['{09DAFAE1-8EB0-11D2-8E5D-00A02415E90F}']
    function Open(const FileName: WideString): WordBool; safecall;
    function Save: WordBool; safecall;
    function SaveAs(const FileName: WideString): WordBool; safecall;
    function Print(Copies: Integer; bShowDialog: WordBool): WordBool; safecall;
    procedure Hide; safecall;
    procedure Show; safecall;
    procedure SysTray(State: WordBool); safecall;
    procedure Quit; safecall;
    function Get_FileName: WideString; safecall;
    function SelectPrinter(const Printer: WideString): WordBool; safecall;
    function GetDymoPrinters: WideString; safecall;
    property FileName: WideString read Get_FileName;
  end;
Und dann der Aufruf der externen Funktion aus der Delphi App:

Delphi-Quellcode:
pfad := 'mylabel.lwl';
opened := DymoAddIn.Open(pfad);
Da gibts dann den Fehler "E2018 Record, Objekt oder Klassentyp erforderlich".

Wie macht man das noch richtig?

Danke!
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.151 Beiträge
 
Delphi 12 Athens
 
#2

AW: COM / DLL-Einbindung für Anfänger

  Alt 17. Okt 2023, 17:16
Was ist DymoAddIn?

Und wenn ja, von wo kommt wie die Instanz her?
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat
wurzelsepp1

Registriert seit: 9. Dez 2012
74 Beiträge
 
Delphi 3 Professional
 
#3

AW: COM / DLL-Einbindung für Anfänger

  Alt 17. Okt 2023, 17:37
Was ist DymoAddIn?
Eine Funktion in einer DLL des Druckerherstellers.

Und wenn ja, von wo kommt wie die Instanz her?
Die ist in dem Wrapper definiert:

Delphi-Quellcode:
 LIBID_Dymo: TGUID = '{DC8A996F-111D-42E2-BACF-EEC86F53B454}';
 IID_IDymoAddIn: TGUID = '{09DAFAE1-8EB0-11D2-8E5D-00A02415E90F}';
Wenn da weitere Ausschnitte benötigt werden, schicke ich die gerne.
  Mit Zitat antworten Zitat
Kas Ob.

Registriert seit: 3. Sep 2023
213 Beiträge
 
#4

AW: COM / DLL-Einbindung für Anfänger

  Alt 17. Okt 2023, 18:31
E2018 is Delphi compiler error.
Please share a simple code showing how are you declaring DymoAddIn and its construction.
  Mit Zitat antworten Zitat
wurzelsepp1

Registriert seit: 9. Dez 2012
74 Beiträge
 
Delphi 3 Professional
 
#5

AW: COM / DLL-Einbindung für Anfänger

  Alt 17. Okt 2023, 19:59
E2018 is Delphi compiler error.
Please share a simple code showing how are you declaring DymoAddIn and its construction.
I think I did. Here is the wrapper (only the part with the function I need to use):

Delphi-Quellcode:
const

  LIBID_DymoSDK: TGUID = '{25D837F1-8D49-3354-A820-AE8ED312EC09}';

  IID_IDymoLabel: TGUID = '{5748221F-3D1E-35AE-8F26-4D01C9798FE9}';
  IID_IDymoPrinter: TGUID = '{2BED54B5-C7F6-3939-973A-AFB075AB9572}';

type

// *********************************************************************//
// Forward-Deklaration von in der Typbibliothek definierten Typen
// *********************************************************************//
  IDymoLabel = interface;
  IDymoPrinter = interface;

// *********************************************************************//
// Interface: IDymoLabel
// Flags: (4416) Dual OleAutomation Dispatchable
// GUID: {5748221F-3D1E-35AE-8F26-4D01C9798FE9}
// *********************************************************************//
  IDymoLabel = interface(IDispatch)
    ['{5748221F-3D1E-35AE-8F26-4D01C9798FE9}']
    function Get_XMLContent: WideString; safecall;
    procedure Set_XMLContent(const pRetVal: WideString); safecall;
    function Get_Preview: PSafeArray; safecall;
    procedure Set_Preview(pRetVal: PSafeArray); safecall;
    function GetPreviewLabel: PSafeArray; safecall;
    procedure LoadLabelFromFilePath(const filePath: WideString); safecall;
    procedure LoadLabelFromXML(const XMLContent: WideString); safecall;
    function UpdateLabelObject(const labelObject: ILabelObject; const objectValue: WideString): WordBool; safecall;
    function SetImageFromFilePath(const objectName: WideString; const imageFile: WideString): WordBool; safecall;
    function SetImageFromBase64(const objectName: WideString; const base64String: WideString): WordBool; safecall;
    function Save(const fileName: WideString): WordBool; safecall;
    function GetLabelObject(const objName: WideString): ILabelObject; safecall;
    procedure GhostMethod_IDymoLabel_72_1; safecall;
    property XMLContent: WideString read Get_XMLContent write Set_XMLContent;
    property Preview: PSafeArray read Get_Preview write Set_Preview;
  end;

HTH
  Mit Zitat antworten Zitat
Benutzerbild von Olli73
Olli73

Registriert seit: 25. Apr 2008
Ort: Neunkirchen
662 Beiträge
 
#6

AW: COM / DLL-Einbindung für Anfänger

  Alt 17. Okt 2023, 20:46
Delphi-Quellcode:
Var
  MyDymoAddIn: IDymoAddIn;

...

MyDymoAddIn := DymoAddIn;
MyDymoAddIn.open(...);
...
  Mit Zitat antworten Zitat
wurzelsepp1

Registriert seit: 9. Dez 2012
74 Beiträge
 
Delphi 3 Professional
 
#7

AW: COM / DLL-Einbindung für Anfänger

  Alt 4. Nov 2023, 12:46
Delphi-Quellcode:
Var
  MyDymoAddIn: IDymoAddIn;

...

MyDymoAddIn := DymoAddIn;
MyDymoAddIn.open(...);
...
Genau so funktioniert's. Vielen Dank!
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:28 Uhr.
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