G
Guest
Hi,
On both a pocket pc and a smart phone, I am trying to retrieve the devices
manufacture, model, revision, serial number, and subscriber id using
lineGetGeneralInfo.
The issue I am having is that lineGetGeneralInfo always returns a
-2147483595 (LINEERR_INVALPOINTER).
Below is the code and P/Invoke declarations that i am using:
~~~ CODE BEGIN ~~~
// lineInitializeEx
int result = NativeTapi.lineInitializeEx(out hLine, IntPtr.Zero,
IntPtr.Zero, null,
out dwNumDev, ref num1, ref lineInitializeParams);
if (result != 0) {
MessageBox.Show(string.Format("lineInitializeEx failed!\n\nError Code:
{0}", result.ToString()));
return;
}
// lineNegotiateAPIVerison
int version;
int dwAPIVersionLow = 0x10004;
int dwAPIVersionHigh = 0x20000;
LINEEXTENSIONID lineExtensionID;
result = NativeTapi.lineNegotiateAPIVersion(hLine, 0, dwAPIVersionLow,
dwAPIVersionHigh, out version, out lineExtensionID);
if (result != 0) {
MessageBox.Show(string.Format("lineNegotiateAPIVersion failed!\n\nError
Code: {0}", result.ToString()));
return;
}
// lineOpen
IntPtr hLine2;
result = NativeTapi.lineOpen(hLine, 0, out hLine2, version, 0, IntPtr.Zero,
0x00000002, 0x00000004, IntPtr.Zero);
if (result != 0) {
MessageBox.Show(string.Format("lineNegotiateAPIVersion failed!\n\nError
Code: {0}", result.ToString()));
return;
}
// lineGetGeneralInfo
byte[] bytes = new byte[512];
result = NativeTapi.lineGetGeneralInfo(hLine2, bytes);
// process
string manufacture;
string model;
string revision;
string serialNumber;
string subscriberID;
int size;
int offset;
// manufacture
size = BitConverter.ToInt32(bytes, 12);
offset = BitConverter.ToInt32(bytes, 16);
manufacture = Encoding.Unicode.GetString(bytes, offset, size);
// model
size = BitConverter.ToInt32(bytes, 20);
offset = BitConverter.ToInt32(bytes, 24);
model = Encoding.Unicode.GetString(bytes, offset, size);
// revision
size = BitConverter.ToInt32(bytes, 28);
offset = BitConverter.ToInt32(bytes, 32);
revision = Encoding.Unicode.GetString(bytes, offset, size);
// serial number
size = BitConverter.ToInt32(bytes, 36);
offset = BitConverter.ToInt32(bytes, 40);
serialNumber = Encoding.Unicode.GetString(bytes, offset, size);
// subscriber id
size = BitConverter.ToInt32(bytes, 44);
offset = BitConverter.ToInt32(bytes, 48);
subscriberID = Encoding.Unicode.GetString(bytes, offset, size);
// do something with the data
// lineClose for hLine2
NativeTapi.lineClose(hLine2);
// lineShutdown for hLine
NativeTapi.lineShutdown(hLine);
~~~ CODE END ~~~
~~~ P/Invoke BEGIN ~~~
[StructLayout(LayoutKind.Sequential)]
public struct LINEEXTENSIONID {
public IntPtr dwExtensionID0;
public IntPtr dwExtensionID1;
public IntPtr dwExtensionID2;
public IntPtr dwExtensionID3;
}
[StructLayout(LayoutKind.Sequential)]
public struct LINEINITIALIZEEXPARAMS {
public uint dwTotalSize;
public uint dwNeededSize;
public uint dwUsedSize;
public uint dwOptions;
public System.IntPtr hEvent;
public System.IntPtr hCompletionPort;
public uint dwCompletionKey;
}
internal class NativeTapi {
[DllImport("coredll")]
public static extern int lineInitializeEx(out IntPtr lpm_hLineApp, IntPtr
hInstance, IntPtr lpfnCallback, string lpszFriendlyAppName, out int
lpdwNumDevs,
ref int lpdwAPIVersion, ref LINEINITIALIZEEXPARAMS
lpLineInitializeExParams);
[DllImport("coredll")]
public static extern int lineOpen(IntPtr m_hLineApp, int dwDeviceID, out
IntPtr lphLine, int dwAPIVersion, int dwExtVersion, IntPtr
dwCallbackInstance,
int dwPrivileges, int dwMediaModes, IntPtr lpCallParams);
[DllImport("coredll")]
public static extern int lineNegotiateAPIVersion(IntPtr m_hLineApp, int
dwDeviceID, int dwAPILowVersion, int dwAPIHighVersion, out int
lpdwAPIVersion,
out LINEEXTENSIONID lpExtensionID);
[DllImport("cellcore")]
public static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bytes);
[DllImport("coredll")]
public static extern int lineClose(IntPtr hLine);
[DllImport("coredll")]
public static extern int lineShutdown(IntPtr m_hLineApp);
}
~~~ P/Invoke END ~~~
thanks in advance for your help,
allen
On both a pocket pc and a smart phone, I am trying to retrieve the devices
manufacture, model, revision, serial number, and subscriber id using
lineGetGeneralInfo.
The issue I am having is that lineGetGeneralInfo always returns a
-2147483595 (LINEERR_INVALPOINTER).
Below is the code and P/Invoke declarations that i am using:
~~~ CODE BEGIN ~~~
// lineInitializeEx
int result = NativeTapi.lineInitializeEx(out hLine, IntPtr.Zero,
IntPtr.Zero, null,
out dwNumDev, ref num1, ref lineInitializeParams);
if (result != 0) {
MessageBox.Show(string.Format("lineInitializeEx failed!\n\nError Code:
{0}", result.ToString()));
return;
}
// lineNegotiateAPIVerison
int version;
int dwAPIVersionLow = 0x10004;
int dwAPIVersionHigh = 0x20000;
LINEEXTENSIONID lineExtensionID;
result = NativeTapi.lineNegotiateAPIVersion(hLine, 0, dwAPIVersionLow,
dwAPIVersionHigh, out version, out lineExtensionID);
if (result != 0) {
MessageBox.Show(string.Format("lineNegotiateAPIVersion failed!\n\nError
Code: {0}", result.ToString()));
return;
}
// lineOpen
IntPtr hLine2;
result = NativeTapi.lineOpen(hLine, 0, out hLine2, version, 0, IntPtr.Zero,
0x00000002, 0x00000004, IntPtr.Zero);
if (result != 0) {
MessageBox.Show(string.Format("lineNegotiateAPIVersion failed!\n\nError
Code: {0}", result.ToString()));
return;
}
// lineGetGeneralInfo
byte[] bytes = new byte[512];
result = NativeTapi.lineGetGeneralInfo(hLine2, bytes);
// process
string manufacture;
string model;
string revision;
string serialNumber;
string subscriberID;
int size;
int offset;
// manufacture
size = BitConverter.ToInt32(bytes, 12);
offset = BitConverter.ToInt32(bytes, 16);
manufacture = Encoding.Unicode.GetString(bytes, offset, size);
// model
size = BitConverter.ToInt32(bytes, 20);
offset = BitConverter.ToInt32(bytes, 24);
model = Encoding.Unicode.GetString(bytes, offset, size);
// revision
size = BitConverter.ToInt32(bytes, 28);
offset = BitConverter.ToInt32(bytes, 32);
revision = Encoding.Unicode.GetString(bytes, offset, size);
// serial number
size = BitConverter.ToInt32(bytes, 36);
offset = BitConverter.ToInt32(bytes, 40);
serialNumber = Encoding.Unicode.GetString(bytes, offset, size);
// subscriber id
size = BitConverter.ToInt32(bytes, 44);
offset = BitConverter.ToInt32(bytes, 48);
subscriberID = Encoding.Unicode.GetString(bytes, offset, size);
// do something with the data
// lineClose for hLine2
NativeTapi.lineClose(hLine2);
// lineShutdown for hLine
NativeTapi.lineShutdown(hLine);
~~~ CODE END ~~~
~~~ P/Invoke BEGIN ~~~
[StructLayout(LayoutKind.Sequential)]
public struct LINEEXTENSIONID {
public IntPtr dwExtensionID0;
public IntPtr dwExtensionID1;
public IntPtr dwExtensionID2;
public IntPtr dwExtensionID3;
}
[StructLayout(LayoutKind.Sequential)]
public struct LINEINITIALIZEEXPARAMS {
public uint dwTotalSize;
public uint dwNeededSize;
public uint dwUsedSize;
public uint dwOptions;
public System.IntPtr hEvent;
public System.IntPtr hCompletionPort;
public uint dwCompletionKey;
}
internal class NativeTapi {
[DllImport("coredll")]
public static extern int lineInitializeEx(out IntPtr lpm_hLineApp, IntPtr
hInstance, IntPtr lpfnCallback, string lpszFriendlyAppName, out int
lpdwNumDevs,
ref int lpdwAPIVersion, ref LINEINITIALIZEEXPARAMS
lpLineInitializeExParams);
[DllImport("coredll")]
public static extern int lineOpen(IntPtr m_hLineApp, int dwDeviceID, out
IntPtr lphLine, int dwAPIVersion, int dwExtVersion, IntPtr
dwCallbackInstance,
int dwPrivileges, int dwMediaModes, IntPtr lpCallParams);
[DllImport("coredll")]
public static extern int lineNegotiateAPIVersion(IntPtr m_hLineApp, int
dwDeviceID, int dwAPILowVersion, int dwAPIHighVersion, out int
lpdwAPIVersion,
out LINEEXTENSIONID lpExtensionID);
[DllImport("cellcore")]
public static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bytes);
[DllImport("coredll")]
public static extern int lineClose(IntPtr hLine);
[DllImport("coredll")]
public static extern int lineShutdown(IntPtr m_hLineApp);
}
~~~ P/Invoke END ~~~
thanks in advance for your help,
allen