Меня попросили интегрировать веб-камеру ZoneTrigger в мой проект. SDK, представленный на сайте, - это C ++, также образец. Мне удалось получить несколько функций для работы. место, где я застрял, - это функция, где выполняется обратный вызов.
Код в образце c ++ функции обратного вызова
ZT_SetCallbackProc(ZoneTriggerCallbackProc);
// в заголовочном файле
typedef int (WINAPI *f_ZT_SetCallbackProc) (void *proc);
/*
Sets up the callback function for your application.
The proc should be declared like this:
int WINAPI ZoneTriggerCallbackProc(int MessageType, ZT_TRIG_STRUCT *trigInfo);
MessageType may be one of the following:
0: Zone Trigger sends a trig. The trigInfo contains data about the hot spots that generated the trig.
1: Zone Trigger has started and is notifying us that it is ready. This only occurs when Zone Trigger starts after the interface DLL is loaded.
2: Zone Trigger is shutting down. You application may need to know this. If Zone Trigger is started again, your application will get message 1.
3: Zone Trigger's Hot spot scheme has changed (a Hot Spot was added or deleted)
*/
мой код C #:
[DllImport("ZTcom.dll")]
private static extern IntPtr ZT_SetCallbackProc(int ZoneTriggerCallbackProc);
private unsafe int ZoneTriggerCallbackProc(int MessageType, ref ZT_TRIG_STRUCT trigInfo)
{
switch (MessageType)
{
case 0: //Trig from a Zone Trigger hot spot
// string s1 = new string(trigInfo.SpotName);
MessageBox.Show("Got a trig from spot" + trigInfo.SpotIndex.ToString()+ s1 );
break;
case 1: //Zone Trigger has started and is notifying us that it is ready
MessageBox.Show("Zone Trigger issued a ready notification.\r\n");
break;
case 2: //Zone Trigger is shutting down
MessageBox.Show("Zone Trigger has left the building.\r\n");
break;
case 3: //Hot spot scheme updated, you might want yo re-enumerate the hot spots
MessageBox.Show("Zone Trigger's hot spots have been updated.\r\n");
break;
}
return 0;
}
Я дошел до этого ... но я не понимаю, как вызвать функцию ZT_SetCallbackProc?
IntPtr tg = IntPtr.Zero;
tg = ZT_SetCallbackProc(ZoneTriggerCallbackProc);
это дает ошибку, что ZoneTriggerCallbackProc является группой методов. Пожалуйста, помогите ... заранее.