Jump to content

dpallas

Members
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

0 Neutral
  1. dpallas

    C++ to Delphi conversion problem

    I don't get why the target hardware has anything to do with it, though it is desktop computers (x64). The header comes from a driver library, for which I do not have the source. I agree, however, that the only solution is either a C SDK, or writing a C-like interface dll.
  2. dpallas

    C++ to Delphi conversion problem

    Remy thanks again for your response. But I have no idea about C++. So it is impossible for me to implement the C code you wrote. Yes I definitely need this SDK. The only solution is to find someone to write this code.
  3. dpallas

    C++ to Delphi conversion problem

    The problem is that I don't know how to write in VC++ Thank you David.
  4. dpallas

    C++ to Delphi conversion problem

    Remy thank you for your answer Please look at the code below, I think the field sizes are defined. Thank you again typedef struct EFTPOS_CONTEXT { char* licenseKey; char* vatNumber; vector<EFTPOS_DEVICE> devices; vector<SIGNATURE_PROVIDER> providers; EFTPOS_CONTEXT() : licenseKey(NULL) , vatNumber(NULL) { devices.clear(); providers.clear(); } EFTPOS_CONTEXT(EFTPOS_CONTEXT* context) { if (NULL != context->licenseKey) { licenseKey = new char[strlen(context->licenseKey) + 1]; lstrcpy(licenseKey, context->licenseKey); } if (NULL != context->vatNumber) { vatNumber = new char[strlen(context->vatNumber) + 1]; lstrcpy(vatNumber, context->vatNumber); } devices.clear(); providers.clear(); for (vector<EFTPOS_DEVICE>::iterator it = context->devices.begin(); it != context >devices.end(); it++) { EFTPOS_DEVICE device(it); devices.push_back(device); } for (vector<SIGNATURE_PROVIDER>::iterator it = context->providers.begin(); it != context->providers.end(); it++) { providers.push_back(*it); } }
  5. dpallas

    C++ to Delphi conversion problem

    Thanks David Is there an alternative way to do this?
  6. dpallas

    C++ to Delphi conversion problem

    I will try Merci beaucoup M. François
  7. dpallas

    C++ to Delphi conversion problem

    Thank you Mr Francois. Unfortunately I don't have the ability to use C++
  8. dpallas

    C++ to Delphi conversion problem

    Thank you for your answer. Translation in delphi: PEFTPOS_DEVICE = ^EFTPOS_DEVICE; EFTPOS_DEVICE = record posId: PChar; terminalId: PChar; apiKey: PChar; host: PChar; port: LongInt; posProtocol: POS_PROTOCOL; end; PEFTPOS_CONTEXT = ^EFTPOS_CONTEXT; EFTPOS_CONTEXT = record licenseKey: PChar; vatNumber: PChar; devices: TList<EFTPOS_DEVICE>; providers: TList<SIGNATURE_PROVIDER>; end; procedure InitializeEFTPOSDevice(var device: EFTPOS_DEVICE); begin device.posId := nil; device.terminalId := nil; device.apiKey := nil; device.host := nil; device.posProtocol := NOT_SET; device.port := 0; end; procedure InitializeEFTPOSContext(var context: EFTPOS_CONTEXT); begin context.licenseKey := nil; context.vatNumber := nil; context.devices := TList<EFTPOS_DEVICE>.Create; context.providers := TList<SIGNATURE_PROVIDER>.Create; end; The same happens if I use devices: Array<EFTPOS DEVICE>; Thanks again
  9. There is this h header in VC++ typedef struct EFTPOS_ERROR { ERROR_LEVEL errorLevel; ERROR_CODE errorCode; char* errorMessage; } typedef struct EFTPOS_DEVICE { char* posId; char* terminalId; char* apiKey; char* host; LONG port; POS_PROTOCOL posProtocol; } typedef struct EFTPOS_CONTEXT { char* licenseKey; char* vatNumber; vector<EFTPOS_DEVICE> devices; vector<SIGNATURE_PROVIDER> providers; } extern "C" __declspec(dllexport) void __cdecl InitContext(char** contextId, EFTPOS_ERROR* error, EFTPOS_CONTEXT context); I tried with PAnsiChar and PChar types and when I call InitContext it shows External Exception or Access violation Can anyone help? Thank you
×