Right now I am writing a C # wrapper for the Dallmeier Common API light (Camera and Surviellance systems), and I have never written a wrapper before, but I used the Canon EDSDK C # chip. Therefore, I use the Canon shell as a guide for writing a Dallmeier wrapper.
I'm having problems completing the callback. In the API manual, it has the following:
dlm_connect
int(unsigned long uLWindowHandle, const char * strIP, const char* strUser1, const char* strPwd1, const char* strUser2, const char* strPwd2, void (*callback)(void *pParameters, void *pResult, void *pInput), void * pInput)
Arguments
- ulWindowhandle - a handle to the window that is passed to the ViewerSDK to display videos and messages there
- strUser1 / 2 - usernames for login. If only one user input is used, strUser2 is NULL
- strPwd1 / 2 - passwords of both users. If strUser2 is NULL, strPwd2 is ignored.
Return
This function creates a SessionHandle to be passed
Callback
pParameters will be structured:
- unsigned long ulFunctionID
- unsigned long ulSocketHandle, // access to the socket of the established connection
- unsigned long ulWindowHandle,
- int SessionHandle, // handle to the session created by the session
- const char * strIP,
- const char * strUser1,
- const char * strPwd1,
- const char * strUser2,
- const char * strPWD2
pResult is a pointer to an integer representing the result of the operation. Zero success. Negative values ββare error codes.
So, from what I read on Net and Stack Overflow - C # uses delegates for callbacks. So I create my callback function:
public delegate uint DallmeierCallback(DallPparameters pParameters, IntPtr pResult, IntPtr pInput);
I create a join function
[DllImport("davidapidis.dll")] public extern static int dlm_connect(int ulWindowHandle, string strIP, string strUser1, string strPwd1, string strUser2, string strPwd2, DallmeierCallback inDallmeierFunc
And (I think) DallPParameters as a struct:
[StructLayout(LayoutKind.Sequential)] public struct DallPParameters { public int ulfunctionID; public int ulsocketHandle; public int ulWindowHandle; ... }
All this in my wrapper class.
Am I heading in the right direction or is this completely wrong?
Then in my Dallmeier class I have the following:
private DallmeierAPI dallmeierAPI; private DallmeierSDK.DallmeierCallback dallCallbackHandler; private GCHandle handle; private IntPtr pResult; private IntPtr pInput; internal Dallmeier() { this.dallmeierAPI = DallmeierAPI.Instance; registerEvents(); } private void registerEvents() {
So, when I register the callback, does it say that the method name is expected?
and pParameters expects return value?