I have created an ActiveX server and client in LabWindows CVI 7.0 using the wizards. The server has two interfaces (one is dual the other is an event interface). The dual interface allows the client to talk to the server to perform an action this works fine. The other interface is an event interface which when a Toggle button is clicked on the UI panel of the server it calls the normal CVI call back which is also supposed to fire an event to my client to indicate the button was pressed and has a value change. The Dual interface works fine I am able to talk to the server. The difficulty I am having is with the event interface. The client is able to get a handle to the server and register for the event that is expected. See code below:
""
CAObjHandle MyActiveServer;
// Get the handle to the server
status = RayTryitServer_ActiveIRayExec (NULL, 1, LOCALE_NEUTRAL, 0,
&MyActiveServer);
status = RayTryitServer_IRayExecEventRegOnDebugFlag
(
MyActiveServer,
ExecServerCallback,
NULL,
1,
NULL
);
""
This all seems to run ok status = 0 indicating no errors.
However when the server tries to find out which
clients are registered to receive the events using the code fragment below:
""
CAServerObjHandle MyServer1;
CAObjHandle MyServer;
int Did_AddRef;
IID Interface_Ptr;
const IID *IID_Ptr;
void *This_Ptr;
..
..
..
status = CA_GetActiveObjectByProgIdEx ("RayTryitServer.RayServerObj", NULL, &IID_IRayExec, 1, LOCALE_NEUTRAL, 0, &MyServer);
status = CA_DisplayErrorInfo (MyServer, NULL, status, NULL);
IID_Ptr = &IID_IRayExec;
status = CA_GetInterfaceFromObjHandle (MyServer, IID_Ptr,
0, &Interface_Ptr, &Did_AddRef);
status = CA_DisplayErrorInfo (MyServer, NULL, status, NULL);
This_Ptr = (void *)&Interface_Ptr;
status = CA_ServerGetObjHandleFromIface (This_Ptr, &MyServer1);
status = CA_DisplayErrorInfo (MyServer, NULL, status, NULL);
..
...
..
if (SUCCEEDED (CA_ServerGetEventObjHandles (MyServer1, &IID_IRayExecEvent,
1, LOCALE_NEUTRAL, eventObjs, &numEventObjs)))
{
..
..
""
The first two calls seem to work status = 0 but I keep getting an invalid handle error when the "CA_ServerGetObjHandleFromIface " is called.
Therefore I never get a vaild CAServerObjHandle to call "CA_ServerGetEventObjHandles" with so the clients registered for the events can be called. What is the best way to obtain this "CAServerObjHandle". Do I need to pass it to the server somehow since the client actually started the server ? Must the client also use
a UI in order to be able to receive the events message from the server?