-
June 25th, 2009, 09:49 AM
#1
How does WriteProfileString() works...???
Hi all,
I am using WriteProfileString() function call in my application... Microsoft SDK says that : The WriteProfileString function copies a string into the specified section of the Win.ini file ..
But when i opened the file Win.ini .. i don't see any section or entry created. However when i use GetProfileString() function call i can fetch the data stored by WriteProfileString()...
So my question is where can i see the contents written by WriteProfileString()..
I also searched under Registry editor for my the contents... but could'nt find...
Please anybody explain me this....
Thanks,
-
June 25th, 2009, 10:26 AM
#2
Re: How does WriteProfileString() works...???
Have a look at the InitInstance method of your App: if SetRegistryKey(...) call is there and not commented out then registry is used rather than win.ini file. See MSDN article "CWinApp::SetRegistryKey" for details.
Last edited by VictorN; June 25th, 2009 at 11:24 AM.
Victor Nijegorodov
-
June 25th, 2009, 11:18 AM
#3
Re: How does WriteProfileString() works...???
No, there is not call to SetRegistryKey() .... Anyway in registry where can i look for the data written by WriteProfileString().
BTW i am call the fun like this:
CWinApp* pApp = AfxGetApp();
pApp->WriteProfileString(_T("Section_Name "),_T("Entry"),_T("Value"));
Any clue...
Thanks,
-
June 25th, 2009, 11:26 AM
#4
Re: How does WriteProfileString() works...???
Did you read MSDN article "CWinApp::SetRegistryKey" or not?
Anyway, you could debug your code stepping into the WriteProfileString() function and so on to see what and why happens.
Victor Nijegorodov
-
June 25th, 2009, 11:10 PM
#5
Re: How does WriteProfileString() works...???
Thanks for all of your efforts Victor_N, Those info were really helpful....
Also i found that the application creates an "App_Name.ini" file in "C:\Windows" and its doing read and write via this ini file and earlier i was confused looking into Win.ini file.
So WriteProfileString() creates a file with "App_Name.ini" and write the data into it not in Win.ini
Is it correct...???
Thanks,
-
June 26th, 2009, 01:27 AM
#6
Re: How does WriteProfileString() works...???
Remarks
Call this member function to write the specified string into the specified section of the application’s registry or .INI file.
The entries are stored as follows:
In Windows NT, the value is stored to a registry key.
In Windows 3.x, the value is stored in the WIN.INI file.
In Windows 95, the value is stored in a cached version of WIN.INI.
Example
CString strSection = "My Section";
CString strStringItem = "My String Item";
CString strIntItem = "My Int Item";
CWinApp* pApp = AfxGetApp();
pApp->WriteProfileString(strSection, strStringItem, "test");
CString strValue;
strValue = pApp->GetProfileString(strSection, strStringItem);
ASSERT(strValue == "test");
pApp->WriteProfileInt(strSection, strIntItem, 1234);
int nValue;
nValue = pApp->GetProfileInt(strSection, strIntItem, 0);
ASSERT(nValue == 1234);
-
June 26th, 2009, 01:39 AM
#7
Re: How does WriteProfileString() works...???
Originally Posted by fanronghua
Remarks
Call this member function to write the specified string into the specified section of the application’s registry or .INI file.
The entries are stored as follows:
In Windows NT, the value is stored to a registry key.
;
Yes thats true, But in my case i can see the values are getting stored in MyApp_Name.ini file under windows directory.
I think as Victor_N said in his above posts if we use SetRegistryKey() function, the values will be stored under the configured reg key... If not set values will be stored in an .ini file.
The only thing i want to confirm is that the ini file will be the Win.ini or App_Name.ini(as i can see in my application)...
Thanks,
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|