Solved

TRegIniFile.Create('') fails in D6

Posted on 2002-07-04
10
324 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

689 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