E
evadell
Hi all. I have a c# windows forms app that uses a unmanaged dll. I need
to call a function in the dll that registers a callback function. When
the dll generates an event it calls my callback function. The problem
is that when my callback function is called a LPVARIANT value is
returned. Depending on another param, it can be a string or a int. If
all I receive was int, there were no problems, but I don't know how to
handle when i receive a string.
Here is the dll function definition:
DWORD MFPSB_API MFPSB_RegisterCallback(MFPSB_HCTX hCtx,
MFPSB_PFNCALLBACK pfnCallback, DWORD dwEvents, HWND hwnd);
typedef VOID (MFPSB_API *MFPSB_PFNCALLBACK)(MFPSB_HCTX hCtx, LONG lpId,
LPVARIANT lpInfo);
And here my c# app code:
delegate void DMFPSB_PfnCallback(int hCtx,uint lpId,ref int lpInfo);
[DllImport("mfpsb.dll")]
private static extern int MFPSB_RegisterCallback(int hCtx,
DMFPSB_PfnCallback pfnCallback, uint dwEvents, int hwnd);
result = MFPSB_RegisterCallback(sc.Handler,new
DMFPSB_PfnCallback(this.Callback),MFPSB_CB_ALLEVENTS,0);
public void Callback(int hCtx, uint lpId, ref int lpInfo) {
switch (lpId) {
case MFPSB_CB_NEWFILE:
//Here lpInfo has to be a String
Console.WriteLine("Callback " + hCtx + " MFPSB_CB_NEWFILE " +
lpInfo);
break;
case MFPSB_CB_ERROR:
//Here lpInfo has to be a int
Console.WriteLine("Callback " + hCtx + " MFPSB_CB_ERROR" + lpInfo);
break;
}
return;
}
Thnx.
to call a function in the dll that registers a callback function. When
the dll generates an event it calls my callback function. The problem
is that when my callback function is called a LPVARIANT value is
returned. Depending on another param, it can be a string or a int. If
all I receive was int, there were no problems, but I don't know how to
handle when i receive a string.
Here is the dll function definition:
DWORD MFPSB_API MFPSB_RegisterCallback(MFPSB_HCTX hCtx,
MFPSB_PFNCALLBACK pfnCallback, DWORD dwEvents, HWND hwnd);
typedef VOID (MFPSB_API *MFPSB_PFNCALLBACK)(MFPSB_HCTX hCtx, LONG lpId,
LPVARIANT lpInfo);
And here my c# app code:
delegate void DMFPSB_PfnCallback(int hCtx,uint lpId,ref int lpInfo);
[DllImport("mfpsb.dll")]
private static extern int MFPSB_RegisterCallback(int hCtx,
DMFPSB_PfnCallback pfnCallback, uint dwEvents, int hwnd);
result = MFPSB_RegisterCallback(sc.Handler,new
DMFPSB_PfnCallback(this.Callback),MFPSB_CB_ALLEVENTS,0);
public void Callback(int hCtx, uint lpId, ref int lpInfo) {
switch (lpId) {
case MFPSB_CB_NEWFILE:
//Here lpInfo has to be a String
Console.WriteLine("Callback " + hCtx + " MFPSB_CB_NEWFILE " +
lpInfo);
break;
case MFPSB_CB_ERROR:
//Here lpInfo has to be a int
Console.WriteLine("Callback " + hCtx + " MFPSB_CB_ERROR" + lpInfo);
break;
}
return;
}
Thnx.