Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

MFC Class for Reading and Writing INI Files?

291 views
Skip to first unread message

Frank Jermann

unread,
Sep 23, 1998, 3:00:00 AM9/23/98
to
I am searching for a class that allows me to read an INI file with all
sections and tags, modify them and store them back to the INI file. I
think it must be available, or not?

Thanks for all help!

Please answer only to my e-mail address: Frank....@mchp.siemens.de


Wilfried Thuwis

unread,
Sep 23, 1998, 3:00:00 AM9/23/98
to
Maybe you can use the CIni-class that's available on
www.codeguru.com/doc_view.
It's an INI-like save-system.


Frank Jermann wrote in message <3608F034...@mchp.siemens.de>...

ChainsaW

unread,
Sep 23, 1998, 3:00:00 AM9/23/98
to
>I am searching for a class that allows me to read an INI file with all
>sections and tags, modify them and store them back to the INI file. I
>think it must be available, or not?

Get/WriteProfileInt
Get/WriteProfileString
Get/WriteProfileSection

Also available as CWinApp methods - declare "extern CMyApp theApp" in header file and you can use theApp.Get/WriteProfile* methods everywhere in your project.

CWinApp::m_pszProfileName contains the name of the application’s .INI file. Use SetRegistryKey(...) when you would like to use registry instead of INI files.

ChainsaW


Tim Morgan

unread,
Sep 23, 1998, 3:00:00 AM9/23/98
to Frank Jermann
If you are using VC++ 5.0, you will want to comment out the call to
SetRegistryKey in your applications 'InitInstance' method. If you don't
do this, things will go to the registry instead of the file. Then, do
something like the following to set up the path to the INI file:

// Set up the path to the INI file
// First free the string allocated by MFC at CWinApp startup.
// The string is allocated before InitInstance is called.
free((void*)m_pszProfileName);
//Change the name of the .INI file; it is located in working directory
char workingDir[_MAX_PATH+1] = "";
CString cfgPath;
if (_getcwd(workingDir, _MAX_PATH)) {
cfgPath = workingDir;
cfgPath += "\\";
cfgPath += CONFIG_FILENAME;
}
else { // try root direcotry
cfgPath = "c:\\";
cfgPath += CONFIG_FILENAME;
}
//The CWinApp destructor will free this memory.
m_pszProfileName=_tcsdup(_T(cfgPath));

You can then use the Get/WriteProfileString and Get/WriteProfileInt
methods that are part of CWinApp. Info will get written to the INI file
you specified in InitInstance.

--

~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
~ Tim Morgan
~ Programmer/Analyst
~ Envoy Global, Inc. *Internet Conferencing Solutions*
~ tmo...@envoyglobal.com
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~


Frank Jermann wrote:

> I am searching for a class that allows me to read an INI file with all
> sections and tags, modify them and store them back to the INI file. I
> think it must be available, or not?
>

Lance Lovette

unread,
Sep 24, 1998, 3:00:00 AM9/24/98
to
The next release of the ITCLib library will contain ITCPrivateProfile, a
class that manipulates INI formatted files. Early next week you will able to
read through an online version of the documentation for the class and then
download the source from http://devcentral.iftech.com/library.

Lance

lov...@iftech.com
Interface Technologies, Inc.
http://devcentral.iftech.com
http://codevizor.iftech.com


Frank Jermann wrote in message <3608F034...@mchp.siemens.de>...

Serge Sly

unread,
Sep 26, 1998, 3:00:00 AM9/26/98
to

Lance Lovette wrote in message ...

0 new messages