GetPrivateProfileString的目的是什么? [英] What is the purpose of GetPrivateProfileString?
问题描述
我在C ++程序中遇到了 GetPrivateProfileString
这个术语。
I have come across the term GetPrivateProfileString
in a C++ program. Could anyone give me a simple explanation of the use of this function?
我的页面上的代码是:
GetPrivateProfileString("files", "directory", "/mediadb/files/", directory, os.path.getsize(directory), "apache")
推荐答案
GetPrivateProfileString()
读取.ini文件中的值。
GetPrivateProfileString()
reads values from .ini files.
在16位Windows的时代,它是读写应用程序配置数据的方式。然后,应用程序将其配置存储在一个共享的.ini文件中,该文件位于系统目录中,称为win.ini。 Bad times!
Way back when, in the days of 16-bit Windows, it was the way to read and write application configuration data. Back then applications stored their configuration in a shared .ini file that lived in the system directory, called win.ini. Bad times!
要从win.ini读取,您呼叫 GetProfileString()
。 GetPrivateProfileString()
中的私有表示这个精彩函数允许您访问除win.ini以外的.ini文件,即对您的应用程序为私有的.ini文件。如果我记得正确(和我的记忆是朦胧的),大多数应用程序使用win.ini多年和多年后,正式地皱眉这样做。
To read from win.ini you called GetProfileString()
. The private in GetPrivateProfileString()
is indicative of the fact that this wonderful function allowed you to access an .ini file other than win.ini, i.e. one private to your application. If I recall correctly (and my memory is hazy), most applications carried on using win.ini for years and years after it was officially frowned upon to do so.
它所以发生 GetPrivateProfileString()
是一个令人难以置信的皱纹野兽与可怕的性能特点和难以理解的怪异。我个人避免它像瘟疫,如果我必须处理.ini文件我使用定制代码这样做。
It so happens that GetPrivateProfileString()
is an incredibly wrinkly beast with terrible performance characteristics and hard to understand oddities. I personally avoid it like the plague and if I have to process .ini files I use bespoke code to do so.
Raymond Chen有一个很好的文章关于为什么.ini文件被弃用赞成注册表。
Raymond Chen has a nice article about why .ini files were deprecated in favour of the registry.
这篇关于GetPrivateProfileString的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!