Solved

TRegIniFile.Create('') fails in D6

Posted on 2002-07-04
10
320 Views
Last Modified: 2010-04-04
I often used TRegIniFile and declared
var
  RegItem: TRegIniFile;

and did
  RegItem := TRegIniFile.Create('');

Which fails in D6.

I've got round it by using TRegistry and declared
var
  RegItem: TRegistry;

and doing
  RegItem := TRegistry.Create;

But TRegIniFile.Create('') always worked OK in D5 and below as far as I remember. Just tested and still works OK in D5 on same system.

Is this a D6 bug or was I doing something wrong until D6 stopped me?

I have Delphi 6 sp2 installed and running on winxp.
I searched but have not found anything relevant so far.

Anyone know what is going on here?

Regards
Steve


0
Comment
Question by:SteveWaite
  • 6
  • 2
  • 2
10 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7130652
Hello Steve

>> Which fails in D6.

what do u mean by that?, it's working fine with me in Delphi 6 and win XP, r u sure that u add Registry to the uses clause?
and what's the error message you got?

aslo why u don't use TRegistry instead of it?



0
 
LVL 3

Author Comment

by:SteveWaite
ID: 7130665
Hi Mohammed,

Thanks,

Registry is added to uses clause ;-), but I did say I just run the whole thing in D5 and worked fine!

I do use TRegistry but found this from a section that writes .ini files as well.

No error message, just silently leaves the procedure on the line

  RegItem := TRegIniFile.Create('');

Are you sure you do the same thing, declare a file of no name?

Regards
Steve
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7130739
yes
i just copy what u wrote exactly and it worked fine without any errors
0
 
LVL 3

Author Comment

by:SteveWaite
ID: 7130795
Strange?!

I have D6 pro
0
 
LVL 3

Author Comment

by:SteveWaite
ID: 7130850
Now in unit Registry..

function IsRelative(const Value: string): Boolean;
begin
  Result := not ((Value <> '') and (Value[1] = '\'));
end;

IsRelative() fails at Value[1] because Value = ''

So I went to 'complete boolean eval' and needed unchecking so that ((Value <> '') prevents the computation of (Value[1] = '\').

This still works ok in D5!! the 'complete boolean eval' setting makes no difference to IsRelative().

So now I ask the same question but a different way:

Why with D6 must we have 'complete boolean eval' unchecked for code in the Registry to work when it was fine in D5 checked or not? What is is causing this?



0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 8

Expert Comment

by:TOndrej
ID: 7131057
Not to use complete Boolean evaluation is the default.
In D5, you're probably using the .dcu supplied by Borland which was compiled with {$B-}.
In D6, you're probably compiling your own new .dcu.
0
 
LVL 3

Author Comment

by:SteveWaite
ID: 7131905
Thanks TOndrej,

Exactly! Now why, all of a sudden, am i compiling my own .dcu?
0
 
LVL 8

Accepted Solution

by:
TOndrej earned 100 total points
ID: 7131948
Because the .dcu file is not found or the .pas file is found sooner.
Check your paths.
The .pas directory probably appears in your library path before the .dcu directory; or maybe the .dcu directory is missing in your library path.

IMO you should not have the .pas directory included in your library path at all; remove it if it's there.
The same applies to your Project Options search path.
0
 
LVL 3

Author Comment

by:SteveWaite
ID: 7131975
ok, having a look, back soon.
0
 
LVL 3

Author Comment

by:SteveWaite
ID: 7131988
Woah! The .pas dir was slipped in there but hey, it wasn't me!

Thanks TOndrej, you have it this time, Mohammed thanks for your time too.

Regards
Steve
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now