COM
-
Hallo,
ich habe einen COM-Server, der die Zugriffe auf eine Datenbank übernimmt, in mein VC++-Programm mit eingebunden. Allerdings auf ziemlich umständliche Art.
Ich habe die IDL-Datei meines Servers mit MIDL kompiliert und die .c und .h Dateien dann in mein Projekt mit aufgenommen.Jetzt habe ich folgendes Problem. Geschehen Änderungen am COM-Server muss dieser neu kompiliert werden un er erhält eine neue IID für das Interface (keine Änderungen am Interface). Die Folge ist, dass ich mein VC++-Programm ja auch wieder ändern muss.
COM-Server ist in VB implementiert.
Kann ich meinen COM-Server auch anders in meinem Projekt einbinden?
-
MSDN:
C++ Specific
The #import directive is used to incorporate information from a type library. The content of the type library is converted into C++ classes, mostly describing the COM interfaces.
#import "filename" [attributes]
#import <filename> [attributes]
attributes
One or more #import Attributes. Separate attributes with either a space or comma. For example:
#import "..\drawctl\drawctl.tlb" no_namespace, raw_interfaces_only
or#import "..\drawctl\drawctl.tlb" no_namespace raw_interfaces_only
filename
Allows you to specify which type library you want to import. filename can be one of the following:
A type library (.TLB or .ODL). file:, which indicates type library, can precede each filename.
The progid of a control in the type library. Note that progid: can precede each progid. For example:
#import "progid:my.prog.id.1.5"
For more on progids, see Specifying the Localization ID and Version Number.The library ID of the type library. Note that libid: can precede each library ID. For example:
#import "libid:12341234-1234-1234-1234-123412341234" version("4.0") lcid("9")
If you do not specify version or lcid, the rules that are applied to progid: are also applied to libid:.An executable (.EXE) file.
A library (.DLL) file containing a type library resource (such as .OCX).
A compound document holding a type library.
Any other file format that can be understood by the LoadTypeLib API.
-
Aber die .tlb-datei wir doch dann auch fest in das Programm mit eingebunden, oder?
Oder ist es möglich durch ersetzen der .tlb-Datei die neuste Version des COM-Servers zu verwenden, ohne das VC++-Programm neu kompilieren zu müssen?
-
Ein COM-Server sollte bei Neukompilierung keine neue IID/CLSID erhalten !!
Denn wozu, wenn doch das Interface gleich bleibt ??Sch... Visual Basic !
-
Falls Du aber folgenden Befehl verwendest:
#import "progid:my.prog.id.1.5"
wird ja die neue CLSID aus der Registry geladen und obiger String müsste ja selbst bei VB gleich bleiben !
-
Danke, werd ich gleich mal versuchen.