Re: Convert C-Builder program to Delphi?

From: Maarten Wiltink (maarten_at_kittensandcats.net)
Date: 01/28/05

  • Next message: Maarten Wiltink: "Re: Get size of an image"
    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


  • Next message: Maarten Wiltink: "Re: Get size of an image"

    Relevant Pages

    • Re: Convert C-Builder program to Delphi?
      ... all the exports together in the project file. ... exists which is a pointer to TX. ... > that extra parameter, 'BOOL'. ...
      (comp.lang.cpp)
    • Re: HELP: AfxBeginThread problem
      ... You can pass one pointer. ... I want to add an extra parameter to SomeFunction: ... >i'm not passing in the pData, and the compiler says: error C2665: ... MVP Tips: http://www.flounder.com/mvp_tips.htm ...
      (microsoft.public.vc.mfc)
    • Re: Convert C-Builder program to Delphi?
      ... > all the exports together in the project file. ... Delphi is supposed to automatically handle the ... > exists which is a pointer to TX. ... A Boolean variable occupies one byte of memory, ...
      (comp.lang.pascal.delphi.misc)
    • Re: Convert C-Builder program to Delphi?
      ... > all the exports together in the project file. ... Delphi is supposed to automatically handle the ... > exists which is a pointer to TX. ... A Boolean variable occupies one byte of memory, ...
      (comp.lang.cpp)
    • Re: Exporting/importing a variable from a Dll
      ... > we can export it and retrieve through pointer to a class and use the method ... Maybe I'm missing something, but: ... Exports the whole class. ...
      (microsoft.public.vc.mfc)