byte[] bPlate = new byte[15];
fixed (byte* pPlate = bPlate)
{
retVal = _LocateVehicleBarcode(Instance, ncodeToBytes(barcode.ToCharArray()), out customer, pPlate);
}
I have one function however that takes a pointer to a struct. The closest I can get to a fixed pointer to a struct is a fixed pointer to the first element in the struct. This is the unmanaged signature.
int __stdcall __export POSAddJournalRecord(tTenderedMoney* money);
This is the declaration of the delegate used to call it.
private unsafe delegate dbErrEnum POSAddJournalRecordD(ref tTenderedMoney money);
private static POSAddJournalRecordD _POSAddJournalRecord;
_POSAddJournalRecord = (POSAddJournalRecordD)Marshal.GetDelegateForFunctionPointer(
(IntPtr)ICSAPI.DllCalls.GetProcAddress("POSAddJournalRecord"), typeof(POSAddJournalRecordD));
Then when I call the delegate I pass the struct by ref.
public dbErrEnum POSAddJournalRecord(tTenderedMoney money)
{
return _POSAddJournalRecord(ref money);
}
My question is, will this cause problems by not being fixed Will the framework marshal that type to a fixed pointer I don't want GC to come along and move my struct in the middle of this call. What is the right way to do this
Thanks in advance!