P
Peter
Hello, I've a problem with P/Invoke a DLL
I get a message "not supported exception"
What is possible wrong ?
Thanks
Peter.
the DLL structure :
This function returns the track data from a user card swipe. HANDLE
IOC_GetCreditCardData(
LPCREDIT_CARD_DATA lpCreditCardData,
BOOL bClear
); ParameterslpCreditCardData [out] Long pointer to a CREDIT_CARD_DATA
structure in which the current card swipe data is returned. bClear [in]
Boolean that specifies whether the function should clear the card swipe data
from the stored buffer. Return ValuesNonzero indicates success. Zero
indicates failure.typedef struct _CREDIT_CARD_DATA {
WCHAR szTrack1Data[IOC_MAX_TRACK_LEN];
DWORD dwTrack1Status;
WCHAR szTrack2Data[IOC_MAX_TRACK_LEN];
DWORD dwTrack2Status;
WCHAR szTrack3Data[IOC_MAX_TRACK_LEN];
DWORD dwTrack3Status;
} CREDIT_CARD_DATA; //note : IOC_MAX_TRACK_LEN = 128I tried to call the DLL
in C# with :
public struct MyStruct
{
public String Data_Track_1;
public uint Status_Track_1;
public String Data_Track_2;
public uint Status_Track_2;
public String Data_Track_3;
public uint Status_Track_3;
}
[DllImport("IOCtrl.DLL", EntryPoint="IOC_GetCreditCardData",
SetLastError=true,
CharSet=CharSet.Unicode)]
public static extern bool IOC_GetCreditCardData(MyStruct lpCreditCardData,
bool bClear);
private void btnGetCCData_Click(object sender, System.EventArgs e)
{
MyStruct mystr = new MyStruct();
IOC_GetCreditCardData(mystr, false);
txtTrack2.Text = mystr.Data_Track_2;
}
I get a message "not supported exception"
What is possible wrong ?
Thanks
Peter.
the DLL structure :
This function returns the track data from a user card swipe. HANDLE
IOC_GetCreditCardData(
LPCREDIT_CARD_DATA lpCreditCardData,
BOOL bClear
); ParameterslpCreditCardData [out] Long pointer to a CREDIT_CARD_DATA
structure in which the current card swipe data is returned. bClear [in]
Boolean that specifies whether the function should clear the card swipe data
from the stored buffer. Return ValuesNonzero indicates success. Zero
indicates failure.typedef struct _CREDIT_CARD_DATA {
WCHAR szTrack1Data[IOC_MAX_TRACK_LEN];
DWORD dwTrack1Status;
WCHAR szTrack2Data[IOC_MAX_TRACK_LEN];
DWORD dwTrack2Status;
WCHAR szTrack3Data[IOC_MAX_TRACK_LEN];
DWORD dwTrack3Status;
} CREDIT_CARD_DATA; //note : IOC_MAX_TRACK_LEN = 128I tried to call the DLL
in C# with :
public struct MyStruct
{
public String Data_Track_1;
public uint Status_Track_1;
public String Data_Track_2;
public uint Status_Track_2;
public String Data_Track_3;
public uint Status_Track_3;
}
[DllImport("IOCtrl.DLL", EntryPoint="IOC_GetCreditCardData",
SetLastError=true,
CharSet=CharSet.Unicode)]
public static extern bool IOC_GetCreditCardData(MyStruct lpCreditCardData,
bool bClear);
private void btnGetCCData_Click(object sender, System.EventArgs e)
{
MyStruct mystr = new MyStruct();
IOC_GetCreditCardData(mystr, false);
txtTrack2.Text = mystr.Data_Track_2;
}