Quick Info
|
WritePrivateProfileString
The WritePrivateProfileString function copies a string into the specified section of the specified initialization file. This function is provided for compatibility with 16-bit Windows-based applications. WIn32-based applications should store initialization information in the registry. BOOL WritePrivateProfileString( LPCTSTR lpAppName,
| // pointer to section name
|
LPCTSTR lpKeyName,
| // pointer to key name
|
LPCTSTR lpString,
| // pointer to string to add
|
LPCTSTR lpFileName
| // pointer to initialization filename
|
);
|
|
key=string
.
.
. If the lpFileName parameter does not contain a full path and filename for the file, WritePrivateProfileString searches the Windows directory for the file. If the file does not exist, this function creates the file in the Windows directory. If lpFileName contains a full path and filename and the file does not exist, WriteProfileString creates the file. The specified directory must already exist. Windows NT: Windows NT maps most .INI file references to the registry, using the mapping defined under the following registry key: HKEY_LOCAL_MACHINE\Software\Microsoft\
Windows NT\CurrentVersion\IniFileMapping Windows NT keeps a cache for the IniFileMapping registry key. Calling WritePrivateProfileStringW with the value of all arguments set to NULL will cause Windows NT to refresh its cache of the IniFileMappingKey for the specified .INI file. The Win32 Profile functions (Get/WriteProfile*, Get/WritePrivateProfile*) use the following steps to locate initialization information:
- Look in the registry for the name of the initialization file, say myfile.ini, under IniFileMapping:
Windows NT\CurrentVersion\IniFileMapping\myfile.ini
- Look for the section name specified by lpAppName. This will be a named value under myfile.ini, or a subkey of myfile.ini, or will not exist.
- If the section name specified by lpAppName is a named value under myfile.ini, then that value specifies where in the registry you will find the keys for the section.
- If the section name specified by lpAppName is a subkey of myfile.ini, then named values under that subkey specify where in the registry you will find the keys for the section. If the key you are looking for does not exist as a named value, then there will be an unnamed value (shown as "<No Name>") that specifies the default location in the registry where you will find the key.
- If the section name specified by lpAppName does not exist as a named value or as a subkey under myfile.ini, then there will be an unnamed value (shown as "<No Name>") under myfile.ini that specifies the default location in the registry where you will find the keys for the section.
- If there is no subkey for myfile.ini, or if there is no entry for the section name, then look for the actual myfile.ini on the disk and read its contents.
- Ensure that no .INI file of the specified name exists on the system.
- Ensure that there is a key entry in the registry that specifies the .INI file. This entry should be under the path HKEY_LOCAL_MACHINE\SOFTWARE \Microsoft\Windows NT\CurrentVersion\IniFileMapping.
- Specify a value for that .INI file key entry that specifies a section. That is to say, an application must specify a section name, as it would appear within an .INI file or registry entry. Here is an example: [My Section].
- For system files, specify SYS for an added value.
- For application files, specify USR within the added value. Here is an example: "My Section: USR: App Name\Section". And, since USR indicates a mapping under HKEY_CURRENT_USER, the application should also create a key under HKEY_CURRENT_USER that specifies the application name listed in the added value. For the example just given, that would be "App Name".
- After following the preceding steps, an application setup program should call WritePrivateProfileStringW with the first three parameters set to NULL, and the fourth parameter set to the INI filename. For example:
- Such a call causes the mapping of an .INI file to the registry to take effect before the next system reboot. The operating system re-reads the mapping information into shared memory. A user will not have to reboot their computer after installing an application in order to have future invocations of the application see the mapping of the .INI file to the registry.
- There is an application named "App Name."
- That application uses an .INI file named "appname.ini."
- There is a section in the .INI file that we want to look like this:
- The user will not have to reboot the system in order to have future invocations of the application see the mapping of the .INI file to the registry.
- Software for developers
-
Delphi Components
.Net Components
Software for Android Developers - More information resources
-
MegaDetailed.Net
Unix Manual Pages
Delphi Examples - Databases for Amazon shops developers
-
Amazon Categories Database
Browse Nodes Database