LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating a Callback Function with a Window handle from an external DLL

Hi,
 
a DLL, delivered with a third party hardware, contains following function:

void GetReceiveEvent(int handle, HANDLE *hevent);

The first handle is the handle of the hardware. The second (returned) handle "*hevent" is a Window handle for a callback function, which I could receive when an event of the hardware occurs. How could I create a LabWindows/CVI (7.0) callback function using the window handle or how could I link a defined LW/CVI callback function to this handle?

Best regards

 

0 Kudos
Message 1 of 4
(3,728 Views)
If you could post the definition of HANDLE from the header file for the dll that would help.
0 Kudos
Message 2 of 4
(3,717 Views)

mvr,

I haven't understood, what you were meaning with "post the definition of HANDLE from the header file for the dll". HANDLE is define as "typedef void" and there is no function in the header file, which describes any callback function.

The only chance to solve the problem seems to be the Win SDK function "WaitForSingleObject" or "WaitForMultipleObjects" in a while loop (endless loop). I don't like endless loops.

I was expecting a CVI function, which creates a callback function like "InstallCallback" with a parameter corresponding to the Window handle.

rgds

0 Kudos
Message 3 of 4
(3,684 Views)
Your right, I was not very clear on what I was asking, and I am not sure I can answer your question. 
 
Assuming they are using the standard windows event structure you or they would have declared hEvent something like this:
  hEvent = CreateEvent(NULL,  // default security attributes
       FALSE,                  // no manual reset
       FALSE,                  // create as not signaled
       NULL);                  // no event name
Normally I would expect to have seen hEvent tied to a windows event with a statement similar to:
  NotifyChangeEventxxxx(hEventType, hEvent);
Where the specific function name is defined by the low level process that you need the event notification from.
You would then wait for an event notification from windows:
 dwWaitResult = WaitForSingleObject(hEvent, INFINITE);
which would wait forever for an event notification through windows from the process that is monitored for event changes.
 
If I had to guess I would assume GetReceiveEvent() allows you to poll for an event from the hardware without stalling the thread in a windows Wait().  Hopefully someone else here has more insight into what the DLL wants to see.


 

Message Edited by mvr on 10-09-2006 07:35 AM

0 Kudos
Message 4 of 4
(3,676 Views)