So, first I rebuilt the FSUIPC_WDLL with the latest WAPI lib (that's not necessary now that John have done it for you 🙂). Then I have the DLL functions declared like this (the ones I'm using in my app):
[DllImport("FSUIPC_WAPID.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void fsuipcw_init(IntPtr hWnd);
[DllImport("FSUIPC_WAPID.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void fsuipcw_start();
[DllImport("FSUIPC_WAPID.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void fsuipcw_end();
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void lvarValueRecvFunc(string lvarName, double value);
[DllImport("FSUIPC_WAPID.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void fsuipcw_getLvarValues(lvarValueRecvFunc callback);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void lvarIDRecvFunc(string lvarName, int id);
[DllImport("FSUIPC_WAPID.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void fsuipcw_getLvarList(lvarIDRecvFunc callback);
[DllImport("FSUIPC_WAPID.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void fsuipcw_setLvarAsShort(int id, int value);
Calling the functions fsuipcw_init, fsuipcw_getLvarValues and fsuipcw_getLvarList with:
fsuipcw_init(this.Handle);
var result = new Dictionary<string, double>();
fsuipcw_getLvarValues(result.Add);
var lvars = new Dictionary<string, int>();
fsuipcw_getLvarList(lvars.Add);
NOTE:
I modified the code for fsuipcw_getLvarList so that it takes (const char*, int) instead of (int, const char*). Since there's no function to set an Lvar by name I use this function to get the Lvar ID for the fsuipcw_setLvarAs...(). Having a Dictionary/map with the name as key and id as value serves that purpose much better.
Hope this helps. It's my first C# application ever so I had to google it all up, but if it seems to work 🙂
I'm not part of the VIP cabal with access to that part of the forum 🙂, so it would be super appreciated if you could do that.