Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ini Files in Delphi

Status
Not open for further replies.

Rajesh171983

Programmer
Mar 10, 2010
4
US
Hi,

I am using Delphi and reading ini files with delphi. Interestingly while reading ini file it is not extracting any information. but the same exe is extracting information from the same ini file in another system. Please suggest me regarding this issue.
 
Do you mean that it runs OK on one computer but not another?
Is it the same Operating system (version of windows)?

Is this actually a registry entry you are trying to access?
Vista and 7 wont let you write to HKLM is that the problem.

I think we need a bit more information about what you are doing, maybe if you posted some code?



Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
 
Actually opearating system is same Windows version. It is not a registry entry. It is pure ini file.I am copying code here

Thank You

Try
Ini:=TIniFile.Create(GetCurrentDir+'\DATA32.INI');
LocalSources.RamDrive:=Ini.ReadString('Directories','RAMDrive','');
LocalSources.MainDir:=Ini.ReadString('Directories','InstallDir','');
Ini.ReadSectionValues('DeskTop',DDetector);
Ini.ReadSectionValues('Notebook',NDetector);
Ini.ReadSection('ContextLessLocations',ContextLess);
LocalSettings.NoteBookOU:=Ini.ReadString('DomainMachineOU','NoteBook','');
LocalSettings.DeskTopOU:=Ini.ReadString('DomainMachineOU','DeskTop','');
Finally
Ini.Free;
End;
 
Is it the same exact INI file (meaning files completely identical and not just file name) or a different one?

I'm waiting for the white paper entitled "Finding Employment in the Era of Occupational Irrelevancy
 
2 questions:

- what OS has system 1 and system 2?
- is the ini located in the same path?

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
system1 and system2 have the same os Windows xp sp3. Ini is located in the same path only.
 
Code:
DomainMachineOU
Sorry to labour the point here, but in both cases this is the same Delphi exe, accessing an ini file on the machine where it is installed?
That is to say there is no acessing of network files involved?


Steve: N.M.N.F.
If something is popular, it must be wrong: Mark Twain
 
I suggest that you check the existence of the file before trying to open it. For example, something like:
Code:
if not FileExists(GetCurrentDir+'\DATA32.INI') then begin
  ShowMessage( 'Unable to open ' + GetCurrentDir+'\DATA32.INI');
...
end
else begin
  // Your code to read ini file
I suspect that the most likely cause of your problem is that the application has not been correctly installed and the ini file is either missing or in the wrong folder.

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top