Gast
#201011
Hallo Forum,
Ich habe eine bereitgestellte DLL . Eine seine Funktion kann Ereignis
auslösen.
Aber ich weis nicht, wie das in VB deklariert und verwendet wird .
Ich habe bis jetzt wenig mit DLLs gearbeitet und nur Funktionen in DLLs
aufgerufen.
Aus der Beschreibung habe ich nur verstanden dass über PVOID pvArg ein
Pointer übergeben soll der auf meine ereignisverarbeitende Funktion
zeigt.
Ein paar Zeilen mit Implementierung dieser Funktion in VB würden mir
sehr helfen.
Hier ist Beschreibung der Funktion und Beispiel (wahrscheinlich in C)
FT_SetEventNotification
Sets conditions for event notification.
FT_STATUS FT_SetEventNotification ( FT_HANDLE ftHandle, DWORD
dwEventMask, PVOID pvArg )
Parameters:
ftHandle
Handle of the device.
dwEventMask
Conditions that cause the event to be set.
pvArg
Interpreted as a handle of an event
Return Value
FT_OK if successful, otherwise the return value is an FT error code.
Remarks
An application can use this function to setup conditions which allow a
thread to block until one of the conditions is met. Typically, an
application will create an event, call this function, then block on the
event. When the conditions are met, the event is set, and the
application thread unblocked.
dwEventMask is a bit-map that describes the events the application is
interested in. pvArg is interpreted as the handle of an event which has
been created by the application. If one of the event conditions is met,
the event is set.
If FT_EVENT_RXCHAR is set in dwEventMask, the event will be set when a
character has been received by the device. If FT_EVENT_MODEM_STATUS is
set in dwEventMask, the event will be set when a change in the modem
signals has been detected by the device.
This example shows how to wait for a character to be received or a
change in modem status.
First, create the event and call FT_SetEventNotification.
FT_HANDLE ftHandle; // handle of an open device
FT_STATUS ftStatus;
HANDLE hEvent;
DWORD EventMask;
hEvent = CreateEvent(
NULL,
false, // auto-reset event
false, // non-signalled state
“”
);
EventMask = FT_EVENT_RXCHAR | FT_EVENT_MODEM_STATUS;
ftStatus = FT_SetEventNotification(ftHandle,EventMask,hEvent);
Sometime later, block the application thread by waiting on the event,
then when the event has occurred, determine the condition that caused
the event, and process it accordingly.
WaitForSingleObject(hEvent,INFINITE);
DWORD EventDWord;
DWORD RxBytes;
DWORD TxBytes;
FT_GetStatus(ftHandle,&RxBytes,&TxBytes,&EventDWord);
if (EventDWord & FT_EVENT_MODEM_STATUS) {
// modem status event detected, so get current modem status
FT_GetModemStatus(ftHandle,&Status);
if (Status & 0x00000010) {
// CTS is high
}
else {
// CTS is low
}
if (Status & 0x00000020) {
// DSR is high
}
else {
// DSR is low
}
}
if (RxBytes > 0) {
// call FT_Read() to get received data from device
}
Ich hoffe sehr das ich hier eine Antwort auf meine Frage bekomme. Denn
im Google und VB-Hilfe habe ich nichts gefunden, was ich verstehen
könnte.
Grüß
Michael D.