Wednesday, December 15, 2004

More on this project

Okay, the big issue I was having was that my functions would end an an unhandled exceptrion would occure. I figured out that the IntPtrs I was passing to the unmanaged code were getting GC'd when my function ended. But the unmanaged code was still trying to use it. So I made the IntPtrs global, an it worked.

Here's the new one. I posted on MSDN. I need to deal with events. I don't know what events the DLL raises, but it has a method where you can pass your function to the unmanaged code.

The function definition looks like this:
KPDCStatus KPDCSetCameraEventNotification ( KPDCCameraRef inCameraRef, KPDCCameraEventNotificationFunc inNotificationFunc, void *inUserData);

In the demo code, they provide a typedef that looks like this:
typedef void (KPDCCALLBACK *KPDCCameraEventNotificationFunc)(
KPDCUInt32 inEvent, // The event code, see KPDCCameraEvents
KPDCUInt32 inParam1, // Events may have an integer parameter
const char *inParam2, // Events may have a string parameter
KPDCUInt32 inParam2Length,
void *userData);

No comments: