Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Can anyone give me or provide me with a link as to how to use to create and read an ini file in borland C++ 6. I have inherited some applications developed in C++ borland 6 that read and write to the registry and my boss wants that to change to ini files or another method. I can only think of ini files, but any files will do.
Can anyone help me?
Posted
Updated 5-Apr-11 23:33pm
v2
Comments
[no name] 6-Apr-11 7:51am    
You can use text formated file to save program settings and data.
Each line in the file consist of parameter name, tabulation symbol and parameted value.

take look at this article the code is plaform independent as such it should suite your purposes:

http://www.codeguru.com/Cpp/misc/misc/article.php/c233/[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Apr-11 14:47pm    
Should work, my 5.
--SA
I would use XML files. Check out this article. I wrote it for C++/MFC, but you should be able to adapt it to Borland C++ easily enough.

XML Application Profile Class[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Apr-11 14:47pm    
Much better choice. My 5.
--SA
CPallini 6-Apr-11 15:31pm    
Incidentally, John's proposed article wouldn't work without registry...:-D
Sergey Alexandrovich Kryukov 6-Apr-11 17:54pm    
Oh really?! Well, that would certainly makes John's arguments not so convincing, but his idea is good nevertheless. Registry must die (maybe not, but limited to system-wide settings)!

I used to propose a different variant which is fundamentally important to me: Data Contract. (And nothing to do with the Registry, of course. :-) Too bad I cannot reference it here: it's for .NET only.
By the way, in many places of .NET documentation Microsoft officially recommends to give up installation and develop products which are installed by just copy (xcopy or whatever). I understand you're not very interested in references. Me neither; I more rely on my own head.

Thank you.
--SA
#realJSOP 6-Apr-11 18:21pm    
See my reply to Henry. The registry use he talks about is because I use a COM DLL provided by Microsoft. I'm not breaking my rule of storing anything in the registry from my own apps.
Sergey Alexandrovich Kryukov 6-Apr-11 19:06pm    
Thank you for the explanation. On the principal issue about Registry use I already supported you.
--SA
You may read/write INI files using Windows API functions like WritePrivateProfileString.
You may find such functions listed at the bottom of this MSDN page[^].
As the documentation page remarks:

These functions are provided only for compatibility with 16-bit versions of Windows. New applications should use the registry.




 
Share this answer
 
Comments
#realJSOP 6-Apr-11 6:04am    
Of course, no programmer in his right mind is going to intentionally use the registry. I know I avoid it like the plague.
CPallini 6-Apr-11 6:08am    
The registry (tree) structure is much better than the INI files one, in my opinion.
Hans Dietrich 6-Apr-11 6:48am    
It seems like this goes in cycles. First, we had INI files. Then that was bad (per MS), we should use the registry. Then with .NET we're told to use config files (aka INI files). I suppose it will be The Cloud next. :)
#realJSOP 6-Apr-11 8:23am    
It's never been a cycle for me. Look at what we have right now. Vista/Weven won't even let your write to the registry without the right permissions. This inherently BREAKS pretty much every app that did so in the past. I have never had a reason or seen a justification for general use of the the registry for storing data.
CPallini 6-Apr-11 8:29am    
The registry is a central repository for storing application settings (not general data). It has drawbacks, of course, but it also has certain advantages (the tree structure, for instance).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900