Link to home
Start Free TrialLog in
Avatar of nimitt
nimitt

asked on

Creation of INI files in VC++

Dear Sir/Madam,
         How can I create my own ini file by VC++ code?I want create ny 1 own ini file and then write certain information in that.So how can I doi this?Which class and functions are there in VC++ for this purpose?
Thank you in advance.
                              Nimitt.
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Have a look at ReadPrivateProfileString and associated functions.

ps. Microsoft recommend you use the registry.  Maybe a future version of VC++ will pull support of ini files away completely?
ASKER CERTIFIED SOLUTION
Avatar of Zoppo
Zoppo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pkreddy
pkreddy

Hi,
 If you are using MFC you can use the following functions of CWinApp derived class.

 * SetRegistryKey()
 * WriteProfileInt()
 * WriteProfileString()
 * GetProfileInt()
 * GetProfileString()

    Now the applications store the data in the windows registry instead of .ini files. If you do not use call to SetRegistryKey("Application name") then your data will be stored in .ini files.
-PK


 
The CWinApp class has a member m_pszProfileName witch contains the path of the app's .ini file.
To read and write form the file use the folowing functions:
GetProfileInt
WriteProfileInt
GetProfileString
WriteProfileString
witch are also members of CWinApp class.
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 by: Zoppo

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Roshan Davis
EE Cleanup Volunteer