COM Events
-
Hallo,
weiß jemand wie COM Events mit Borland abgefangen und/oder erzeugt werden können?
Sprich wie COM implimentiert werden kann?
Bin für jeden Hinweis dankbar!
-
Hallo,
verrate uns doch bitte ob du für COM-Anwendungen oder für die seriellen COM etwas Unterstützung haben möchtest.evi48
-
nun gut

ich dachte mehr an COM-Anwendungen.....
-
Guten Morgen Clip,
tut mir leid da kann ich dir nicht weiter helfen habe bisher noch nichts mit COM-Anwendungen zu tun gehabt.
Viel Erfolg
evi48
-
Ich habe folgendes im Netz gefunden:
http://64.233.183.104/search?q=cache:i_RAdvAiYQ0J:bdn.borland.com/article/0,1410,26734,00.html+sink+COM+Event+Borland&hl=de
Impl.cppSTDMETHODIMP TTestEventsImpl::Trigger() { //fire off our event Fire_Event1(WideString("Mesage message message message!")); return S_OK; }unit.h
//--------------------------------------------------------------------------- #ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- class TForm1; //forward ref to TForm1 //here we derive from TEventDispatcher specialized on our class //and the dispatch ID of the event interface class EventHandler: public TEventDispatcher<EventHandler,&DIID_ITestEventsEvents> { private: bool connected; TForm1 *theform; ITestEventsPtr server; protected: //overloaded from TEventDispatcher. HRESULT InvokeEvent(DISPID id, TVariant *params); public: EventHandler(); ~EventHandler(); void Connect(TForm1 *form, ITestEventsPtr srv); void Disconnect(); void __fastcall HandleEvent1(BSTR Message); }; #endifunit.cpp
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) EventHandler::EventHandler() { connected = false; //not connected; theform = false; //backptr to form is null } EventHandler::~EventHandler() { if (connected) Disconnect(); } /* Here we do a switch on the DISPID (can be gotten from the type library). params is an array of TVariant's. These we delegate to our event handlers. */ HRESULT EventHandler::InvokeEvent(DISPID id, TVariant *params) { switch(id) { case 1: HandleEvent1(WideString(*params)); break; default: ShowMessage("we shouldn't be here!"); } } /* This function attaches our event handler to a running instance of the server. This is the method that actually sinks our events. */ void EventHandler::Connect(TForm1 *form, ITestEventsPtr srv) { server = srv; theform = form; //back pointer to form to do stuff with it. server->AddRef(); //addref the server ConnectEvents(server); //helper function to connect us //to the events interface } void EventHandler::Disconnect() { DisconnectEvents(server); //disconnect the events server->Release(); //release our referece } /* here we actually handle the event in any way we want */ void __fastcall EventHandler::HandleEvent1(BSTR Message) { theform->Label1->Caption = WideString(Message); }Mir ist jedoch völlig unklar, wie ich das Event identifizieren soll.
Mit Fire_Event1 kann man ein Event feuern, aber welchen? und wie höre ich auf das Event?

-
Hi, ich verwende für das ganze COM Zeugs das Tool COMMX von Greanleaf, war bei BCB5 als Freeware dabei.
mfg
Tom
-
@Tom7: Greanleaf, ist das nicht eine Lib zur Nutzung der seriellen COM Schnittstelle?
Ich habe jetzt im Builder folgende Klassen gefunden:
Unit: CmAdmCtlTCOMAdminCatalog TCOMAdminCatalogCollection TCOMAdminCatalogObjectLeider kann ich damit nix anfangen

Die Methode TCOMAdminCatalog::GetCollection() findet keine registrierten Typenbibliotheken (Exception: "Falscher Parameter" ....
TCOMAdminCatalogCollection::PopulateByKey() benötigt als Parameter ein "PSafeArray"
Dieses muss (anscheindend ?) nach Instantierung mit "SafeArrayCreate()" beschrieben werden. Dazu gibt es in der MS Hilfe folgendes:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/automat/htm/chap7_1rvp.aspSafeArrayCreate
Creates a new array descriptor, allocates and initializes the data for the array, and returns a pointer to the new array descriptor.
SAFEARRAY* SafeArrayCreate(
VARTYPE vt,
unsigned int cDims,
SAFEARRAYBOUND * rgsabound
);Parameters
vt
The base type of the array (the VARTYPE of each element of the array). The VARTYPE is restricted to a subset of the variant types. Neither the VT_ARRAY nor the VT_BYREF flag can be set. VT_EMPTY and VT_NULL are not valid base types for the array. All other types are legal.
cDims
Number of dimensions in the array. The number cannot be changed after the array is created.
rgsabound
Pointer to a vector of bounds (one for each dimension) to allocate for the array.Return Value
Points to the array descriptor, or Null if the array could not be created.
ExampleThe following example demonstrates calling the SafeArrayCreate function.
SAFEARRAY * psa; SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 0; rgsabound[0].cElements = 5; psa = SafeArrayCreate(VT_VARIANT, 1, rgsabound); if(psa == NULL) return E_OUTOFMEMORY; // Use the array return NOERROR;Requirements
Diese Beschreibung verstehe ich leider nicht. Genauer, was Hilft mir das?
Wo gebe ich z.B. an, dass ich alle Exents der registrierten Typenbibliothek "AcroPDF" haben möchte? Schießlich weißt mich der Parameter der Funktion TCOMAdminCatalogCollection::PopulateByKey(PSafeArray aKeys) doch darauf hin, dass ich die Events anhand eines Keys beziehen kann.Ich weiß nicht weiter?
hat denn niemand einen Tip?
-
@ Clip, stimmt ist vom Prinzip her sehr einfach und funkt super