Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Dll to load ini information

Posted on 2003-03-10
7
Medium Priority
?
282 Views
Last Modified: 2008-02-01
I'm trying to load the data from ini file.

I want to store the data in ini file like this:

[HeaderNeeded]
File1=true
File2=true


I have about 10 different DLL with their own configurations.  Some of the DLL split the raw data into two files, along with the header line on each file. Other do just make an output file.

I want to make the master program more generic, so creating new dll will simply interface with the master program.  

The situation is that TIniFiles class is a VCL class, which DLL cannot use. I'm trying to find the other way.

These File1 and File2 are being updated very frequently as the interpretation being processed.

Once the either File1 or File2 have a bool value of false, the header line will not be created.

Can anyone help?
0
Comment
Question by:Blubbo
6 Comments
 
LVL 6

Accepted Solution

by:
Mafalda earned 152 total points
ID: 8109953
Did you try to use the registry instead of INI files  ?
0
 
LVL 61

Assisted Solution

by:Julian Hansen
Julian Hansen earned 148 total points
ID: 8110757
Maybe I missed something but what is wrong with using the GetPrivateProfile functions

GetPrivateProfileString / WritePrivateProfileString
GetPrivateProfileInt / WritePrivateProfileInt

?
0
 

Expert Comment

by:mabotta
ID: 8112569
Hello,
For managing ini files I'm using a class with a map object, like map<string, string> and reading the file like a text file, so I can port it to another os.
In your case, the map would be load like this:

map<string, boolean> iniData;

iniData["HeaderNeeded.File1"] = true;
iniData["HeaderNeeded.File2"] = true;

I hope it would be usefull
bye
0
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!

 
LVL 6

Expert Comment

by:Mafalda
ID: 8113530
julianH,
You are not missing anything ...
The registry is another way to do it, while INI files functions were declared absolete for win32 applications and are kept for competability

From MSDN:
"GetPrivateProfileString
The GetPrivateProfileString function retrieves a string from the specified section in an initialization file. This function is provided for compatibility with 16-bit Windows-based applications. Win32-based applications should store initialization information in the registry."


By the way if you read about the INI files functions  implementations you will see that they use  . . . the registry to locate the INI file ;o)

As I knoe MS using the INI file should be safe enough for many more years
0
 
LVL 61

Expert Comment

by:Julian Hansen
ID: 8114604
Ah, yes but INI files are sometimes used where it is not possible to use the registry. For instance when multiple applications / workstations need to access the same configuration information - which workstation's registry is the one that must contain the data. Obviously you could set values in the registry on each machine but that would be an administration nightmare - wouldn't it? If you want a central config file (in INI format) then the registry is not the way to go.

GetPrivateProfileXXX uses the registry to locate the INI file ????? So what is the last parameter (lpFileName)for then? If you use the GetProfileXXX funtions i.e. without the Private part then yes the registry is used otherwise it is not.

My post was to find out why there is a need to use a complicated method for retrieving information from an INI file. Using the argument that you want to port other OS's is weak - if you can't implement the GetPrivateProfileXXX functions on other OS's you are still going to have to implement the map object so what is the difference?
0
 
LVL 11

Expert Comment

by:bcladd
ID: 9978951
No comment has been added lately, so it's time to clean up this TA. I will
leave a recommendation in the Cleanup topic area that this question is:

Answered: Points split between Mafalda and julianH

Please leave any comments here within the next seven days.

Experts: Silence means you don't care. Grading recommendations are made in light
of the posted grading guidlines (http://www.experts-exchange.com/help.jsp#hi73).

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

-bcl (bcladd)
EE Cleanup Volunteer
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

569 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