Re: C Style FILE pointers from Delphi
From: Rob Kennedy (me3_at_privacy.net)
Date: 08/08/04
- Previous message: Shane: "C Style FILE pointers from Delphi"
- In reply to: Shane: "C Style FILE pointers from Delphi"
- Next in thread: Shane: "Re: C Style FILE pointers from Delphi"
- Reply: Shane: "Re: C Style FILE pointers from Delphi"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 08 Aug 2004 02:16:04 -0500
Shane wrote:
> Greetings,
Howdy. Did you post this to enough newsgroups?
> I need to use a function in a DLL that requires a C Style FILE* to an open
> file as a parameter.
>
> Does any one know how can I open a binary file in Delphi and the pass it as
> a FILE* ?
Very carefully. I believe the FILE type is implementation-defined, so
each C compiler may provide its own definition to support whatever
information that compiler needs for managing files. Usually, a FILE* is
a pointer to a struct -- a record. But the layout of that record doesn't
need to be the same between, say, Visual C++ and C++ Builder.
I think your best chance of success will be if the DLL is dynamically
linked to its C run-time library. Then, you can also link your own
program to that same C run-time DLL and call its fopen function. Fopen
returns a FILE* value, which you can then pass along to the other DLL.
If the DLL was compiled with Visual C++, then use TDump to confirm that
it links with msvcrt.dll. Then import fopen and fclose to your program
and call them top open and class files that need to go to the DLL.
type
CFILE = Pointer;
function fopen(const filename, mode: PChar): CFILE; cdecl; external
'msvcrt.dll';
function fclose(stream: CFILE): Integer; cdecl; external 'mscvrt.dll';
-- Rob
- Previous message: Shane: "C Style FILE pointers from Delphi"
- In reply to: Shane: "C Style FILE pointers from Delphi"
- Next in thread: Shane: "Re: C Style FILE pointers from Delphi"
- Reply: Shane: "Re: C Style FILE pointers from Delphi"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|