Jump to content
msd

C Libraries to Delphi

Recommended Posts

Hi there,

The most recent libraries I have for certain APIs are three C libraries; however, Delphi libraries are not offered.

To work with apps, all libraries require DDL files; therefore, I need someone with expertise in Delphi to convert those libraries to native Delphi Pascal files.

Many thanks in advance to all the specialists...

CelikApi.h

eVehicleRegistrationAPI.h

eVehicleRegistrationCOM.h

Share this post


Link to post
On 4/4/2024 at 4:39 PM, msd said:

To work with apps, all libraries require DDL files; therefore, I need someone with expertise in Delphi to convert those libraries to native Delphi Pascal files.

Yea the articles linked by Brandon are on the spot. What you need is to make a C-style interface to the DLL's. The header files just tell you how you can implement the functions. I'd estimate an experienced programmer can easily do this within a week. 

 

For example struct _DATA_REGISTRATION:
 

typedef struct _REGISTRATION_DATA
    {
    VARIANT registrationData;
    VARIANT signatureData;
    VARIANT issuingAuthority;
    } 	REGISTRATION_DATA;

becomes
 

type
  REGISTRATION_DATA = record
    registrationData: Variant;
    signatureData: Variant;
    issuingAuthority: Variant;
  end;

Some of the IRegistration:
 

#ifndef __IRegistration_INTERFACE_DEFINED__
#define __IRegistration_INTERFACE_DEFINED__

/* interface IRegistration */
/* [unique][helpstring][uuid][dual][object] */ 


EXTERN_C const IID IID_IRegistration;

#if defined(__cplusplus) && !defined(CINTERFACE)
    
    MIDL_INTERFACE("0BE1D001-A538-476B-8F59-6594741D7720")
    IRegistration : public IUnknown
    {
    public:
        virtual /* [source][helpstring] */ HRESULT STDMETHODCALLTYPE Initialize( 
            /* [retval][out] */ LONG *result) = 0;
        
        virtual /* [source][helpstring] */ HRESULT STDMETHODCALLTYPE Finalize( 
            /* [retval][out] */ LONG *result) = 0;
        
        virtual /* [source][helpstring] */ HRESULT STDMETHODCALLTYPE GetReaderName( 
            /* [in] */ LONG index,
            /* [out] */ BSTR *readerName,
            /* [retval][out] */ LONG *result) = 0;

Becomes:

  IRegistration = interface(IUnknown)
    ['{0BE1D001-A538-476B-8F59-6594741D7720}']
    function Initialize(out result: LongInt): HRESULT; stdcall;
    function Finalize(out result: LongInt): HRESULT; stdcall;
    function GetReaderName(index: LongInt; out readerName: WideString; out result: LongInt): HRESULT; stdcall;
  end;

I just quickly scrabbled these together to give you an impression.

Share this post


Link to post
19 minutes ago, mitch.terpak said:

 

I just quickly scrabbled these together to give you an impression.

Yes, try Chat-GPT to translate sourcecode. It is quite good in it..

 

image.thumb.png.a1dccb0af0b3c618a25b5a801ced7ba4.png

Share this post


Link to post
Posted (edited)
24 minutes ago, Die Holländer said:

Yes, try Chat-GPT to translate sourcecode. It is quite good in it..

 

image.thumb.png.a1dccb0af0b3c618a25b5a801ced7ba4.png

Yeah, the header files seem easy enough that it can probably do a quite good job. But if you don't know what you're doing and make type mistakes you get an external error that will be very hard to track down. It will probably be a bit stubborn since it's so much code, so you'll have to step through it 

Edited by mitch.terpak

Share this post


Link to post

Yes, but the use is not to get a clean 100% translation.

It will give you a lot of insight of the differences between Delphi/Pascal and C keywords/declarations etc..  

 

>It will probably be a bit stubborn since it's so much code, so you'll have to step through it

Yes, like the programmer that has to translate the code..

Share this post


Link to post
10 minutes ago, Die Holländer said:

Yes, but the use is not to get a clean 100% translation.

It will give you a lot of insight of the differences between Delphi/Pascal and C keywords/declarations etc..  

 

>It will probably be a bit stubborn since it's so much code, so you'll have to step through it

Yes, like the programmer that has to translate the code..

Large spectrum between unpaid intern translating or well paid software engineer of course

Share this post


Link to post
On 4/4/2024 at 3:39 PM, msd said:

therefore, I need someone with expertise in Delphi to convert those libraries to native Delphi Pascal files

I'm not quite sure what you are saying here? Are you looking to hire somebody?

Share this post


Link to post

Is this code running in C++ Builder?

 

If so, you may just need an interface unit, not a full DLL.

 

I can probably help if you'd like to discuss it.

Share this post


Link to post

Hello,

 

Google Gemini (please don't even give it a try).

ChatGPT 3.5: Correct Translation

ChatGPT 4.0: Pro Translation

 

Thanks to all the advice.

  • Like 1

Share this post


Link to post
3 hours ago, msd said:

Google Gemini (please don't even give it a try).

ChatGPT 3.5: Correct Translation

ChatGPT 4.0: Pro Translation

This is pretty epic, let's be honest. Take all the drudge out, and let us work on the brain stuff.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×