网站首页  词典首页

请输入您要查询的函数:

 

术语 getprivateprofilestring
释义 GetPrivateProfileString
语法:
C++
DWORD WINAPI GetPrivateProfileString(
__in LPCTSTR lpAppName,
__in LPCTSTR lpKeyName,
__in LPCTSTR lpDefault,
__out LPTSTR lpReturnedString,
__in DWORD nSize,
__in LPCTSTR lpFileName
);
GetPrivateProfileString函数
从检索在初始化文件中指定的部分字符串。
注意:此功能仅提供了兼容性与16位Windows的应用程序。应用程序应该在注册表中存储初始化信息。
参数
lpAppName [in]
在包含键名节的名称。如果该参数为NULL,GetPrivateProfileString函数复制文件中的所有部分名称所提供的缓冲区。
lpKeyName [in]
在关键的关联的字符串的名称是要检索。如果该参数为NULL,由lpAppName参数指定的所有关键部分复制到名字的lpReturnedString参数指定的缓冲区。
lpDefault [in]
默认字符串。如果lpKeyName键不能找到初始化文件,GetPrivateProfileString默认字符串复制到lpReturnedString缓冲区。如果该参数为NULL,则默认值为空字符串“”。
避免与尾随指定一个空白字符的默认字符串。该函数在插入一个空字符lpReturnedString缓冲区剥夺任何尾随空格。
lpReturnedString [out]
一个缓冲区,它接收检索字符串指针。
nSize [in]
缓冲区的大小指向的lpReturnedString参数,以字符。
lpFileName [in]
在初始化文件的名称。如果这个参数不包含完整路径的文件,为在Windows系统目录中的文件的搜索。
返回值
返回值是复制到缓冲区的字符数,不包括终止空字符。
如果没有lpAppName也不lpKeyName为NULL和目的地提供的缓冲区太小举行请求的字符串,该字符串被截断,由一个空字符后,返回值等于nSize减1。
如果任lpAppName或lpKeyName为NULL和提供的目标缓冲区太小,无法容纳所有的字符串,最后一个字符串被截断及随后两个空字符。在这种情况下,返回值等于nSize减二。
备注
该GetPrivateProfileString函数搜索的关键匹配的lpKeyName参数指定的标题下的lpAppName参数指定部分的名称指定初始化文件。如果发现了这个关键,功能相应的字符串复制到缓冲区。如果不存在,该函数的默认字符串的lpDefault参数指定的副本。阿在初始化文件的部分必须有以下形式:
[节]
关键=字符串



如果lpAppName是NULL,GetPrivateProfileString副本指定的文件中的所有部分名称所提供的缓冲区。如果lpKeyName为NULL,则函数复制指定部分所提供的所有缓冲区键名。应用程序可以使用此方法来枚举文件中的部分和所有键。在任何情况下,每个字符串后跟一个空字符,最后串是由第二个空字符。如果提供的目标缓冲区太小,无法容纳所有的字符串,最后一个字符串被截断及随后两个空字符。
如果与lpKeyName相关的字符串单引号或双引号,该商标将被丢弃时,GetPrivateProfileString封闭函数检索字符串。
该GetPrivateProfileString函数是不区分大小写,该字符串可以是一个大写和小写字母的组合。
检索一个从Win.ini文件字符串,请使用GetProfileString功能。
该系统的地图最。ini文件到注册表中的引用,使用以下注册表项中定义的映射:
HKEY_LOCAL_MACHINE \\软件\\微软\\视窗NT \\ CurrentVersion \\ IniFileMapping
这个映射可能是,如果一个应用程序修改,如Control.ini,的System.ini系统组件初始化文件中,Winfile.ini。在这种情况下,检索功能,从注册表信息,而不是从初始化文件,在存储位置的变化并没有对函数的行为的影响。
配置文件函数使用下列步骤定位初始化信息:
查找在为下IniFileMapping关键初始化文件的名称登记。
查询由lpAppName指定的节的名称。这将是一个命名值中具有关键的初始化文件名,或者一个子项与此名称或名称将不存在,一个值或子项。
如果区段名称由lpAppName指定一个命名值,则该值指定在注册表中您会发现,该科的钥匙。
如果区段名称由lpAppName指定一个子项,然后命名该子项下的具体值,其中,在注册表中您会发现,该科的钥匙。如果密钥您正在寻找不存在的一个命名值,就会有一个未命名的值(显示为<无名称>),指定注册表中的默认位置,您会发现关键。
如果按lpAppName区段名称不存在指定作为一个命名值或一个子项,然后会有一个未命名的值(显示为<无名称>),指定注册表中的默认位置,您将找到的钥匙一节。
如果没有子项或部分名称项,然后查找磁盘上的实际初始化文件并阅读其内容。
当在注册表值寻找其他指定的注册表位置,有几个前缀是改变的。ini文件映射的行为:
! -这个人物写的所有部队都进入到注册表和。ini文件在磁盘上。
# -该字符会导致注册表值被设置为在Windows 3.1的。ini文件中的价值当新用户登录的安装后的第一次。
@ -此字不允许任何人去。ini文件在磁盘上,如果请求的数据不在注册表中读取。
USR: -这个前缀代表HKEY_CURRENT_USER,文本后的前缀是相对于该键。
SYS: -这个前缀代表HKEY_LOCAL_MACHINE \\软件,文本后的前缀是相对于该键。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesGetPrivateProfileStringW(Unicode)和GetPrivateProfileStringA(ANSI)的
参见
GetProfileString
WritePrivateProfileString
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==GetPrivateProfileString Function
Retrieves a string from the specified section in an initialization file.
Note This function is provided only for compatibility with 16-bit Windows-based applications. Applications should store initialization information in the registry.
Syntax
C++
DWORD WINAPI GetPrivateProfileString(
__in LPCTSTR lpAppName,
__in LPCTSTR lpKeyName,
__in LPCTSTR lpDefault,
__out LPTSTR lpReturnedString,
__in DWORD nSize,
__in LPCTSTR lpFileName
);
Parameters
lpAppName [in]
The name of the section containing the key name. If this parameter is NULL, the GetPrivateProfileString function copies all section names in the file to the supplied buffer.
lpKeyName [in]
The name of the key whose associated string is to be retrieved. If this parameter is NULL, all key names in the section specified by the lpAppName parameter are copied to the buffer specified by the lpReturnedString parameter.
lpDefault [in]
A default string. If the lpKeyName key cannot be found in the initialization file, GetPrivateProfileString copies the default string to the lpReturnedString buffer. If this parameter is NULL, the default is an empty string, "".
Avoid specifying a default string with trailing blank characters. The function inserts a null character in the lpReturnedString buffer to strip any trailing blanks.
lpReturnedString [out]
A pointer to the buffer that receives the retrieved string.
nSize [in]
The size of the buffer pointed to by the lpReturnedString parameter, in characters.
lpFileName [in]
The name of the initialization file. If this parameter does not contain a full path to the file, the system searches for the file in the Windows directory.
Return Value
The return value is the number of characters copied to the buffer, not including the terminating null character.
If neither lpAppName nor lpKeyName is NULL and the supplied destination buffer is too small to hold the requested string, the string is truncated and followed by a null character, and the return value is equal to nSize minus one.
If either lpAppName or lpKeyName is NULL and the supplied destination buffer is too small to hold all the strings, the last string is truncated and followed by two null characters. In this case, the return value is equal to nSize minus two.
Remarks
The GetPrivateProfileString function searches the specified initialization file for a key that matches the name specified by the lpKeyName parameter under the section heading specified by the lpAppName parameter. If it finds the key, the function copies the corresponding string to the buffer. If the key does not exist, the function copies the default character string specified by the lpDefault parameter. A section in the initialization file must have the following form:
[section]
key=string
.
.
.
If lpAppName is NULL, GetPrivateProfileString copies all section names in the specified file to the supplied buffer. If lpKeyName is NULL, the function copies all key names in the specified section to the supplied buffer. An application can use this method to enumerate all of the sections and keys in a file. In either case, each string is followed by a null character and the final string is followed by a second null character. If the supplied destination buffer is too small to hold all the strings, the last string is truncated and followed by two null characters.
If the string associated with lpKeyName is enclosed in single or double quotation marks, the marks are discarded when the GetPrivateProfileString function retrieves the string.
The GetPrivateProfileString function is not case-sensitive; the strings can be a combination of uppercase and lowercase letters.
To retrieve a string from the Win.ini file, use the GetProfileString function.
The system 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
This mapping is likely if an application modifies system-component initialization files, such as Control.ini, System.ini, and Winfile.ini. In these cases, the function retrieves information from the registry, not from the initialization file; the change in the storage location has no effect on the function's behavior.
The profile functions use the following steps to locate initialization information:
Look in the registry for the name of the initialization file under the IniFileMapping key.
Look for the section name specified by lpAppName. This will be a named value under the key that has the name of the initialization file, or a subkey with this name, or the name will not exist as either a value or subkey.
If the section name specified by lpAppName is a named value, 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, 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 ) 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, then there will be an unnamed value (shown as ) that specifies the default location in the registry where you will find the keys for the section.
If there is no subkey or entry for the section name, then look for the actual initialization file on the disk and read its contents.
When looking at values in the registry that specify other registry locations, there are several prefixes that change the behavior of the .ini file mapping:
! - this character forces all writes to go both to the registry and to the .ini file on disk.
# - this character causes the registry value to be set to the value in the Windows 3.1 .ini file when a new user logs in for the first time after setup.
@ - this character prevents any reads from going to the .ini file on disk if the requested data is not found in the registry.
USR: - this prefix stands for HKEY_CURRENT_USER, and the text after the prefix is relative to that key.
SYS: - this prefix stands for HKEY_LOCAL_MACHINE\\SOFTWARE, and the text after the prefix is relative to that key.
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesGetPrivateProfileStringW (Unicode) and GetPrivateProfileStringA (ANSI)
See Also
GetProfileString
WritePrivateProfileString
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms724353(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:26:14