B
BVayer
I am trying to P/Invoke a Motorola API and all I keep getting is the
NotSupportException.
The api uses a struct to manipulate the data and returns a DWORD
variable which I converted to uint.
The Struct is made up of several variables of type WORD and 3 variables
which are TCHAR of a fixed length. Those I have as strings; I also
tried them as StringBuilders. The variables which are of type WORD I
am converting to UInt16's.
The API:
typedef TCHAR DIAG_BATTERY_STRINGS_T [BATTERY_STRINGS_SIZE];
typedef struct tagMAIN_BATTERY_PACK_PARAMS
{
WORD wRemainingCapacity;
WORD wCycleCount;
WORD wTimeToFull;
WORD wSerialNumber;
WORD wRatedCapacity;
WORD wActualCapacity;
WORD wManufactureDate;
WORD wBatteryStatus;
DIAG_BATTERY_STRINGS_T ManufactureName;
DIAG_BATTERY_STRINGS_T DeviceName;
DIAG_BATTERY_STRINGS_T DeviceChemistry;
}
MY CODE:
[DllImport("DiagApi.dll")]
private static extern uint DiagBatGetBatteryPackParams( ref
MAIN_BATTERY_PACK_PARAMS MainBatteryInfo);
[StructLayout(LayoutKind.Sequential)]
public struct MAIN_BATTERY_PACK_PARAMS
{
public UInt16 wRemainingCapacity;
public UInt16 wCycleCount;
public UInt16 wTimeToFull;
public UInt16 wSerialNumber;
public UInt16 wRatedCapacity;
public UInt16 wActualCapacity;
public UInt16 wManufactureDate;
public UInt16 wBatteryStatus;
public System.Text.StringBuilder ManufactureName;
public System.Text.StringBuilder DeviceName;
public System.Text.StringBuilder DeviceChemistry;
}
Can anyone give me a hand with this one?
NotSupportException.
The api uses a struct to manipulate the data and returns a DWORD
variable which I converted to uint.
The Struct is made up of several variables of type WORD and 3 variables
which are TCHAR of a fixed length. Those I have as strings; I also
tried them as StringBuilders. The variables which are of type WORD I
am converting to UInt16's.
The API:
typedef TCHAR DIAG_BATTERY_STRINGS_T [BATTERY_STRINGS_SIZE];
typedef struct tagMAIN_BATTERY_PACK_PARAMS
{
WORD wRemainingCapacity;
WORD wCycleCount;
WORD wTimeToFull;
WORD wSerialNumber;
WORD wRatedCapacity;
WORD wActualCapacity;
WORD wManufactureDate;
WORD wBatteryStatus;
DIAG_BATTERY_STRINGS_T ManufactureName;
DIAG_BATTERY_STRINGS_T DeviceName;
DIAG_BATTERY_STRINGS_T DeviceChemistry;
}
MY CODE:
[DllImport("DiagApi.dll")]
private static extern uint DiagBatGetBatteryPackParams( ref
MAIN_BATTERY_PACK_PARAMS MainBatteryInfo);
[StructLayout(LayoutKind.Sequential)]
public struct MAIN_BATTERY_PACK_PARAMS
{
public UInt16 wRemainingCapacity;
public UInt16 wCycleCount;
public UInt16 wTimeToFull;
public UInt16 wSerialNumber;
public UInt16 wRatedCapacity;
public UInt16 wActualCapacity;
public UInt16 wManufactureDate;
public UInt16 wBatteryStatus;
public System.Text.StringBuilder ManufactureName;
public System.Text.StringBuilder DeviceName;
public System.Text.StringBuilder DeviceChemistry;
}
Can anyone give me a hand with this one?