How to call the function in cellcore.dll?
-
Can you post your function and struct declarations?
Dave
Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)public bool OpenLine() { UInt32 dwDevNum = 0;//count the devices UInt32 dwApiVerSion = TAPI\_CURRENT\_VERSION; LINEINITIALIZEEXPARAMS dtParams = new LINEINITIALIZEEXPARAMS(); dtParams.dwTotalSize = (UInt32)Marshal.SizeOf(dtParams); dtParams.dwOptions = 1; IntPtr handles = new IntPtr(0); IntPtr hInstance = IntPtr.Zero;//new IntPtr(GetModuleHandle(new IntPtr(0)).ToInt32()); unsafe { fixed(IntPtr \*hLineApp = &m\_hLineApp) { long lResult = lineInitializeEx(hLineApp, hInstance, new IntPtr(0), new IntPtr(0), new IntPtr(&dwDevNum), new IntPtr(&dwApiVerSion), new IntPtr(&dtParams)); if (lResult == 0) { return true; } } return false; } } \[StructLayout(LayoutKind.Sequential)\] private struct LINEINITIALIZEEXPARAMS { public uint dwTotalSize; public uint dwNeededSize; public uint dwUsedSize; public uint dwOptions; public IntPtr hMultiUse; public uint dwCompletionKey; } \[DllImport("coredll.dll", SetLastError = true)\] unsafe private static extern uint lineInitializeEx( IntPtr \*lphLineApp, IntPtr hInstance, IntPtr pfnCallback,//lineCallbackFunc lpfnCallback, IntPtr FriendAppName,//StringBuilder lpszFriendlyAppName, IntPtr pNumDevs,//out uint lpdwNumDevs, IntPtr pAPIVersion,//out uint lpdwAPIVersion, IntPtr pLineInitializeExParams);//ref LINEINITIALIZEEXPARAMS lpLineInitializeExParams);
There is some white cloud floating on the blue sky. That's the landscape I like.
-
public bool OpenLine() { UInt32 dwDevNum = 0;//count the devices UInt32 dwApiVerSion = TAPI\_CURRENT\_VERSION; LINEINITIALIZEEXPARAMS dtParams = new LINEINITIALIZEEXPARAMS(); dtParams.dwTotalSize = (UInt32)Marshal.SizeOf(dtParams); dtParams.dwOptions = 1; IntPtr handles = new IntPtr(0); IntPtr hInstance = IntPtr.Zero;//new IntPtr(GetModuleHandle(new IntPtr(0)).ToInt32()); unsafe { fixed(IntPtr \*hLineApp = &m\_hLineApp) { long lResult = lineInitializeEx(hLineApp, hInstance, new IntPtr(0), new IntPtr(0), new IntPtr(&dwDevNum), new IntPtr(&dwApiVerSion), new IntPtr(&dtParams)); if (lResult == 0) { return true; } } return false; } } \[StructLayout(LayoutKind.Sequential)\] private struct LINEINITIALIZEEXPARAMS { public uint dwTotalSize; public uint dwNeededSize; public uint dwUsedSize; public uint dwOptions; public IntPtr hMultiUse; public uint dwCompletionKey; } \[DllImport("coredll.dll", SetLastError = true)\] unsafe private static extern uint lineInitializeEx( IntPtr \*lphLineApp, IntPtr hInstance, IntPtr pfnCallback,//lineCallbackFunc lpfnCallback, IntPtr FriendAppName,//StringBuilder lpszFriendlyAppName, IntPtr pNumDevs,//out uint lpdwNumDevs, IntPtr pAPIVersion,//out uint lpdwAPIVersion, IntPtr pLineInitializeExParams);//ref LINEINITIALIZEEXPARAMS lpLineInitializeExParams);
There is some white cloud floating on the blue sky. That's the landscape I like.
Not too sure where the problem is. The first thing I'd do is get rid of the *, &, unsafe and fixed pointer stuff. It's rarely needed as the built in marshaller can handle this stuff way better. I doubt it's the cause of your problems but declaring
dwDevNum
and creating a pointer from it's address is not going to work. There are two keywords for passing value types by reference (thier pointer),ref
andout
. If a value needs to be passed into a function then useref
. If the function doesn't need a value but there will be one there after the function returns then useout
. In the case ofdwDevNum
this should beout
butlpdwAPIVersion
anddtParams
should beref
. AsIntPtr
is a value type the pointer to a pointer forlphLineApp
can be done usingref
/out
as well. To the solution... have a look at this[^]. The guy says his C# code works.Dave
Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) -
Not too sure where the problem is. The first thing I'd do is get rid of the *, &, unsafe and fixed pointer stuff. It's rarely needed as the built in marshaller can handle this stuff way better. I doubt it's the cause of your problems but declaring
dwDevNum
and creating a pointer from it's address is not going to work. There are two keywords for passing value types by reference (thier pointer),ref
andout
. If a value needs to be passed into a function then useref
. If the function doesn't need a value but there will be one there after the function returns then useout
. In the case ofdwDevNum
this should beout
butlpdwAPIVersion
anddtParams
should beref
. AsIntPtr
is a value type the pointer to a pointer forlphLineApp
can be done usingref
/out
as well. To the solution... have a look at this[^]. The guy says his C# code works.Dave
Binging is like googling, it just feels dirtier. Please take your VB.NET out of our nice case sensitive forum. Astonish us. Be exceptional. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)I will study the code you provided. Thank you!
There is some white cloud floating on the blue sky. That's the landscape I like.