Solved

TRegIniFile.Create('') fails in D6

Posted on 2002-07-04
10
319 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:mnasman
Comment Utility
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
Comment Utility
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:mnasman
Comment Utility
yes
i just copy what u wrote exactly and it worked fine without any errors
0
 
LVL 3

Author Comment

by:SteveWaite
Comment Utility
Strange?!

I have D6 pro
0
 
LVL 3

Author Comment

by:SteveWaite
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 8

Expert Comment

by:TOndrej
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
ok, having a look, back soon.
0
 
LVL 3

Author Comment

by:SteveWaite
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 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

12 Experts available now in Live!

Get 1:1 Help Now