Convert C Struct to Delphi (with "file" member)

I'm not sure where to post this question.  Someone suggested I post it here.

I need to convert the following C struct to Delphi. I think I have the right record, but I can't use the "file" member name. The C struct is:

typedef struct {
char file[MAX_PATH];
int index;
} fileinfo;

Thanks for the help.

- Jeff
0
Registered
7/22/2009 7:57:23 PM
embarcadero.delphi.rtl 934 articles. 0 followers. Follow

5 Replies
706 Views

Similar Articles

[PageSpeed] 42

Registered User wrote:
> I'm not sure where to post this question.  Someone suggested I post it here.
> 
> I need to convert the following C struct to Delphi. I think I have the right record, but I can't use the "file" member name. The C struct is:
> 
> typedef struct {
> char file[MAX_PATH];
> int index;
> } fileinfo;
> 
> Thanks for the help.
> 
> - Jeff

fileinfo = record
   file: array[0..MAX_PATH-1] of AnsiChar;
   index: Integer;
end;
0
Olivier
7/22/2009 8:15:24 PM
> {quote:title=Olivier Sannier wrote:}{quote}
> Registered User wrote:
> > I'm not sure where to post this question.  Someone suggested I post it here.
> > 
> > I need to convert the following C struct to Delphi. I think I have the right record, but I can't use the "file" member name. The C struct is:
> > 
> > typedef struct {
> > char file[MAX_PATH];
> > int index;
> > } fileinfo;
> > 
> > Thanks for the help.
> > 
> > - Jeff
> 
> fileinfo = record
>    file: array[0..MAX_PATH-1] of AnsiChar;
>    index: Integer;
> end;

Thanks.  I tried that, but the compiler doesn't like the use of the reserved word "file" as a record member.

- Jeff
0
Registered
7/22/2009 8:23:54 PM
Registered User wrote:
>> {quote:title=Olivier Sannier wrote:}{quote}
>> Registered User wrote:
>>> I'm not sure where to post this question.  Someone suggested I post it here.
>>>
>>> I need to convert the following C struct to Delphi. I think I have the right record, but I can't use the "file" member name. The C struct is:
>>>
>>> typedef struct {
>>> char file[MAX_PATH];
>>> int index;
>>> } fileinfo;
>>>
>>> Thanks for the help.
>>>
>>> - Jeff
>> fileinfo = record
>>    file: array[0..MAX_PATH-1] of AnsiChar;
>>    index: Integer;
>> end;
> 
> Thanks.  I tried that, but the compiler doesn't like the use of the reserved word "file" as a record member.

Ah right. well, name it anyway you see fit then. The name is of no 
importance whatsoever when passing the record to a DLL.
0
Olivier
7/22/2009 8:42:08 PM
> {quote:title=Olivier Sannier wrote:}{quote}
> Registered User wrote:
> >> {quote:title=Olivier Sannier wrote:}{quote}
> >> Registered User wrote:
> >>> I'm not sure where to post this question.  Someone suggested I post it here.
> >>>
> >>> I need to convert the following C struct to Delphi. I think I have the right record, but I can't use the "file" member name. The C struct is:
> >>>
> >>> typedef struct {
> >>> char file[MAX_PATH];
> >>> int index;
> >>> } fileinfo;
> >>>
> >>> Thanks for the help.
> >>>
> >>> - Jeff
> >> fileinfo = record
> >>    file: array[0..MAX_PATH-1] of AnsiChar;
> >>    index: Integer;
> >> end;
> > 
> > Thanks.  I tried that, but the compiler doesn't like the use of the reserved word "file" as a record member.
> 
> Ah right. well, name it anyway you see fit then. The name is of no 
> importance whatsoever when passing the record to a DLL.

Thank you so much, Olivier.  My code was actually working, but I didn't realize it.  You made me focus on something other than the declaration of the record.

- Jeff
0
Registered
7/22/2009 9:16:09 PM
Hi Jeff,

I can't remember since what Delphi version, but you can prefix a reserved 
symbol with the & character nowadays, which prevents the problems you are 
having.
The compiler will accept the symbol name then, but do remember that you need 
to use this in Delphi code using the same &-prefix!

Regards,
--
Patrick van Logchem
Every Angle
http://www.everyangle.com


<Registered User> wrote in message news:140633@forums.codegear.com...
>> {quote:title=Olivier Sannier wrote:}{quote}
>> Registered User wrote:
>> > I'm not sure where to post this question.  Someone suggested I post it 
>> > here.
>> >
>> > I need to convert the following C struct to Delphi. I think I have the 
>> > right record, but I can't use the "file" member name. The C struct is:
>> >
>> > typedef struct {
>> > char file[MAX_PATH];
>> > int index;
>> > } fileinfo;
>> >
>> > Thanks for the help.
>> >
>> > - Jeff
>>
>> fileinfo = record
>>    file: array[0..MAX_PATH-1] of AnsiChar;
>>    index: Integer;
>> end;
>
> Thanks.  I tried that, but the compiler doesn't like the use of the 
> reserved word "file" as a record member.
>
> - Jeff
0
Patrick
7/30/2009 7:18:39 AM
Reply:

Similar Artilces:

Convert "xls" file to "txt" file
Hi, I hope someone can help. I need to convert an Excel spreadsheet to an ASCI text file, in order to import data into a datawindow. I want to try and avoid asking users to save their files as text files and there are issues surrounding the use of ODBC to link to Excel. I am currently able to view my Excel data by way of an OLE object but if I try "Getdata", only the first 72 rows are imported to a string or blob and then subsequently to the datawindow. So I am looking for an OLE function which will "save as" my file. Help would be greatly appeciated. ...

Delphi 2010 IDE throws error on "find" and "find in files"
I will greatly appreciate any advice how to cure the suddenly appeared misbehaviour: I just loaded the main project file and then tried to find code snippets fore re-use with "find" and "find in files" the Eurekalog extract is: 2.2 Address : 20EB30B6 2.3 Module Name : vclide140.bpl - (Integrated Development Environment Specific Components) 2.4 Module Version: 14.0.3593.25826 2.5 Type : EOutOfResources 2.6 Message : Unable to insert a line. 2.7 ID : 61FB 2.8 Count : 1 2.9 Status ...

Convert a Static Library ".a" header file to Delphi
Hi, I have bough the RedPark serial cable to connect my iPad to one of our product. I have very little knowledge of XCode and I am trying to interface the static library with Delphi Mobile and the Fire Monkey. I spent 2 days trying to understand how the conversion works but it seems I am missing something. Is there someone who can help me with an example on how to proceed. I believe I have the header file converted to delphi unit. The 2 files compile without error. I have a class for the delegate and I have the manager (see below). I have instantiate TRscMgr class but it seems th...

XE7 / Delphi
If I right-click, say TTouches, in the IDE and select [Find Declaration] I am getting an error, "Unable to locate file FMX.Types.pas". I see similar errors (for FXM.Xxx and VCL.Xxx units) while debugging. How can I fix this? I am SERIOUSLY hoping that I'm not going to have to manually add a series of directories to search paths, or anything like that. Any help [as always] is much appreciated. Thanks! ...

XE7 / Delphi
If I right-click, say TTouches, in the IDE and select [Find Declaration] I am getting an error, "Unable to locate file FMX.Types.pas". I see similar errors (for FXM.Xxx and VCL.Xxx units) while debugging. How can I fix this? I am SERIOUSLY hoping that I'm not going to have to manually add a series of directories to search paths, or anything like that. NOTE: I installed into d:\dev\xe7 Any help [as always] is much appreciated. Thanks! Based on 2 replies, I started by using the "-rtest" command-line switch. This changed nothing. Then I decided to try th...

Icon example for "How to convert 256x256 ICO file to BMP in Delphi 2010? "
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_40524.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" Hello Remy, it is sample icon for previewing purposes only. I have found the icon on virtuallnk dot com. Regards Eric --JivePart=_40524.zeB8CwDOH5aMJzMl Content-Type: application/zip; name="Icon256.zip" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="Icon256.zip" UEsDBBQAAAAIAMRhOTT2vb9vqlICAKbJCwA...

XE7 / Delphi
If I right-click, say TTouches, in the IDE and select [Find Declaration] I am getting an error, "Unable to locate file FMX.Types.pas". I see similar errors (for FXM.Xxx and VCL.Xxx units) while debugging. How can I fix this? I am SERIOUSLY hoping that I'm not going to have to manually add a series of directories to search paths, or anything like that. NOTE: I installed into d:\dev\xe7 Any help [as always] is much appreciated. Thanks! ...

"Using COFF C object files with Delphi X2" article on Code Project
Hi. For anyone who is interested in this Jose A Pascoa. Using COFF C object files with Delphi X2 http://www.codeproject.com/KB/tips/VSandDelphi.aspx -- Alex ...

LastIndexOf("/"c) -- what is "c" ?
I'm trying to convert some VB to C#, and ive run into a small problem due to my lack of experience with VB..... below is the VB code: ************************ Dim s As String = entry.Name.ToLower Dim i As Integer = s.LastIndexOf("/"c) ************************ on the 2nd line, at the end, it has the "/"c ...... what is the "c" there for? the "literal conversion" to C# of the above is this: ************************ string s = entry.Name.ToLower(); int i = s.LastIndexOf("/"c); ************************ but tha...

"File" to "File$date"
Okay... Thanks for all your answers! From all, I combinded the perfext solution: rename("test.txt", "test" . &heute() . ".txt"); sub heute { return (localtime(time))[3] . (localtime(time))[4] . = ((localtime(time))[5] 1900); } Thanks ;) Andreas -----Urspr=FCngliche Nachricht----- Von: Sudarshan Raghavan [mailto:sraghav@india.hp.com]=20 Gesendet: Samstag, 14. September 2002 15:21 An: Perl beginners Betreff: Re: AW: Rename "File" to "File$date" On Sat, 14 Sep 2002, Sudarshan Raghavan wrote: >=20 > #!/...

Convert file on a path to "Stream" without the use of html "file" control
Hello, Basically I am building a CMS of sorts, I have built in the functionality to generate a thumbnail of an image that get's catalogued, I then take my original file and transfer it to the server along with the thumbnail - which is all working fine... Using the html file control accpets the following: (name - "fileImage") Dim x As Stream = fileImage.PostedFile.InputStream() Which is fine - one file at a time, however I need to build in the functionality to get all the image files from a directory and batch transfer them. basically I will have the path similar to:...

Rename "File" to "File$date"
Hy everybody in the List! I have a Problem writing a little perl application... Im a very newbie to programming and need your help :) The Problem is: I have a file "dev.txt" and I want to rename it once a day (with a = cronjob) like "dev13092002.txt" So i need to rename it with a date variable. All I have at the moment is: #!/usr/bin/perl $d =3D `date`; $d =3D /pattern1(pattern2)/; sytem("cp test.txt test`$d`.txt"); Does anyone of you know how to do that? THANKS in advance! =09 | Telematikzentrum D=FCrrwangen GmbH &am...

replace("\","/") in c#
Hi Guys Please can you help me with the above command, I am getting an error CS1010: Newline in constant  this is what i was using temptxt.Replace("\", "/"); thanks in advance hesh   orangelightblub:"\" Didn't test this but I think it should be"\\" or @"\"instead.Grz, Kris. Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. Legend! Thanks Hesh  Hi XIII          Can you explain what is @ in the replace fun...

Convert "BCC" to "To:"
I'm guessing the answer to this is no, but I thought I'd ask. Is there any way to set GWIA to convert a "BCC:" recipient to a "To:" recipient? (Each person would be it's own To: Address) The problem we are having is that we use BCC because we don't want people to see other customers email addresses. We have found that some Spam software is tagging the e-mail as spam because the customers name is not in the "To:" field. Your thoughts or comments would be appreciated. --Matt No there isn't. Nor should there be because the recipien...

Web resources about - Convert C Struct to Delphi (with "file" member) - embarcadero.delphi.rtl

Resources last updated: 12/24/2015 7:59:30 PM