Re: Convert C-Builder program to Delphi?
From: Maarten Wiltink (maarten_at_kittensandcats.net)
Date: 01/28/05
- Previous message: Maarten Wiltink: "Re: Question on network programming."
- In reply to: W. D.: "Re: Convert C-Builder program to Delphi?"
- Next in thread: W. D.: "Re: Convert C-Builder program to Delphi?"
- Reply: W. D.: "Re: Convert C-Builder program to Delphi?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 28 Jan 2005 19:39:25 +0100
"W. D." <NewsGroups@US-Webmasters.com> wrote in message
news:41F9DEB9.428@US-Webmasters.com...
[...]
> // C++: DLLFUNC(int) SomeDLL_Open();
> Function SomeDLL_Open(): Integer; StdCall;
> Exports SomeDLL_Open Name 'SomeDLL_Open';
>
> // Apparently, the 'Exports' keyword can be placed anywhere, so
> // why not just after the Function is declared?
It can? I didn't know that. It seems to be customary to have
all the exports together in the project file. There are things
to be said for both.
[...]
> Now I have a few more questions: Even though this format
> compiles, will I have any problems with the pointers that
> I pretty much ignored in these translations? If so, how
> should I alter this code?
Yes, that's one ugly habit you have. A pointer to something is
something decidedly different from the thing itself. You cannot
treat them as anything close to interchangeable.
If T is a type identifier, ^T is a type for pointers to items
of type T. For many types TX, a corresponding type PX already
exists which is a pointer to TX. The issue is muddied by the
fact the in C, an array is declared as a pointer to the first
element and further elements are accessed through pointer
arithmetic.
> Also, Type definitions 1, & 2, below seem to make sense,
> but #3 has multiple data types as arguments. And #4 has
> that extra parameter, 'BOOL'. What should I do in this
> case?
>
> // (1) C++: typedef int (__stdcall *FUNC_OPEN)();
> Type FUNC_OPEN = Function(): Integer; StdCall;
>
> // (2) C++: typedef void (__stdcall *FUNC_CLOSE)();
> Type FUNC_CLOSE = Function(): Integer; StdCall;
>
> // (3) C++: typedef int (__stdcall *FUNC_GET)(BYTE*,PBYTE*,DWORD*);
> Type FUNC_GET = Function({ ???? }): Integer; StdCall;
>
> // (4) C++: typedef void (__stdcall *FUNC_SHOWICON)(BOOL);
> Type FUNC_SHOWICON = Procedure(); StdCall;
You know what a procedure prototype looks like in Pascal, right?
In C, you're allowed to leave out the parameter names because they
don't need to match anyway. Pascal makes you include formal names
because otherwise it wouldn't look like Pascal or something.
As for "BOOL", see "LongBool".
Groetjes,
Maarten Wiltink
- Previous message: Maarten Wiltink: "Re: Question on network programming."
- In reply to: W. D.: "Re: Convert C-Builder program to Delphi?"
- Next in thread: W. D.: "Re: Convert C-Builder program to Delphi?"
- Reply: W. D.: "Re: Convert C-Builder program to Delphi?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|