SetRegistryKey

来源:互联网 发布:流量劫持 sql注入 编辑:程序博客网 时间:2024/05/17 04:18

原型:

void SetRegistryKey( LPCTSTR lpszRegistryKey );

Void SetRegistryKey( UINT nIDRegistryKey );

参数
  lpszRegistryKey:字符串指针,包含了键的名字。

  nIDRegistryKey:注册表中键的ID/索引。

功能:SetRegistryKey 这个函数功能是设置MFC程序的注册表访问键,并把读写 ini 文件的成员函数映射到读写注册表。只要调用一下 SetRegistryKey 并指定注册表键值,那么下面6个成员函数,就被映射到进行注册表读取了。
1、WriteProfileBinary
Writes binary data to an entry in the application's .INI file.

2、WriteProfileInt
Writes an integer to an entry in the application's .INI file.

3、WriteProfileString
Writes a string to an entry in the application's .INI file.

4、GetProfileBinary
Retrieves binary data from an entry in the application's .INI file.

5、GetProfileInt
Retrieves an integer from an entry in the application's .INI file.

6、GetProfileString
Retrieves a string from an entry in the application's .INI file.

例如:使用CWinApp类的WriteProfileString 、GetProfileString等函数:

1、如果不调用SetRegistryKey(),CWinApp 会把信息保存系统目录的的Test.ini文件中(C:\Windows\Test.ini)
2、如果调用SetRegistryKey(<company name>),CWinApp 会把信息保存系统目录的的注册表中
HKEY_CURRENT_USER\Software\<company name>\Test\<section name>\<value name>.
注:SetRegistryKey()是CWinApp的保护成员,只能被CWinApp的成员函数调用。而WriteProfileString 、GetProfileString等函数则是公共成员,可以随便调用,一般调用形式如:
theApp->WriteProfileString(); //在Test.cpp中。
AfxGetApp()->WriteProfileString(); 在其它源文件中

0 0
原创粉丝点击