Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Delphi 7 Late binding aloaha ZUGFeRD (https://www.delphipraxis.net/215584-delphi-7-late-binding-aloaha-zugferd.html)

KlausV 31. Jul 2024 12:44

Delphi 7 Late binding aloaha ZUGFeRD
 
Hi,
mal eine Frage zu late binding.
Hier der link zum VB6 Beispiel, welches ich wie folgt umgesetzt habe.
uses Forms, Classes, Controls, StdCtrls, ComObj, OleServer, ActiveX, Variants;
alo: Variant;
alo := CreateOleObject('Aloaha_ZUGFeRD.XML'); Die dll wurde registriert und in der registry unter den Namen Aloaha_ZUGFeRD.XML registriert.

Das Projekt lässt sich kompilieren, aber wenn ich es aufrufe, dann wird keine XML Datei erzeugt, leider auch kein Abbruch, etc.

Hat jemand eine Idee?
Unter early binding läuft es, hat leider den negativen Scharm, dass bei jeder neuen Version die TLB neu importiert und das kompilierte Projekt verteilt werden muss.
Danke schon mal.

Gruß Klaus

KlausV 31. Jul 2024 14:40

AW: Delphi 7 Late binding aloaha ZUGFeRD
 
hat funktioniert, der Fehler saß mal wieder vor dem Monitor ;-).
Somit geht late und early binding, cool!

Kas Ob. 31. Jul 2024 15:27

AW: Delphi 7 Late binding aloaha ZUGFeRD
 
Hi,

I am sorry for the language again!

But i think you miss understand how OLE objects works, and this line
Code:
alo := CreateOleObject('Aloaha_ZUGFeRD.XML');
Is trouble waiting to cause you a headache later, either on your device or on your clients.

See, CreateOleObject can do way more than you think, it is so much generic that you should be very careful with it and with what you are creating by name, you can call on text file like 'mynotes.txt' and it might create an OLE machine form notepad or Visual Studio or ..... you can't be sure what are you calling or creating because it will use what the system has installed and registered, take this question and its answer from here, and please read it carefully
https://stackoverflow.com/questions/...ing-ole-delphi

On your device, XML files are registered types with/for the "aloaha ZUGFeRD" and that why it is working, yet on another devices there could be different OLE or application had registered XML type (or mime-type....) and hence the var alo will hold unknown and undefined OLE object.

the right and concise way to do it is same as the answer and example in link to StackOverflow, create the OLE by its name not by the registered type then call on open the file, this will not fail.

For Example .... (well i can't find now) but in earlier post i suggest that you must use the constants for the CLSID, these constants are included in the TLB file, so find you OLE by its constant and create it then open the file 'Aloaha_ZUGFeRD.XML', and alo (the var/variable) doesn't need to be variant, it could be the interface you are using, also the IDE autocomplete will works for you and will make your life easier.

Hope that was clear and good luck !

ps: if you search more, either the forum or the internet, you will also find you can call on use COM/DCOM without even registration, these registered your OLE, this will further remove the need to register aloaha and you can use it in very similar way to a DLL, hence remove any future conflict with the versions.

KlausV 31. Jul 2024 16:27

AW: Delphi 7 Late binding aloaha ZUGFeRD
 
Thanks for your open words and the link to update my knowledge.
It's only used in our company and will be installed on max. 3 clients.
Based on that, I think the risk is quite low to prepare some trouble in the OLE environment.


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:30 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