SetRegistryKey的作用

在利用mfc框架的时候,在App应用类的InitInstance()函数中,初始化时总有一个 SetRegistryKey("字符串XXX")。如果你使用注册表保存相关参数,则它为你提供了很便利的方法,当然如果不使用系统注册表,这句可以注释掉。

 

SetRegistryKey 这个函数功能是设置MFC程序的注册表访问键,并把读写 ini 文件的成员函数映射到读写注册表。只要调用一下 SetRegistryKey 并指定注册表键值,那么下面6个成员函数,就被映射到进行注册表读取了~

WriteProfileBinary

Writes binary data to an entry in the application's .INI file.

WriteProfileInt

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

WriteProfileString

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

 

GetProfileBinary

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

GetProfileInt

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

GetProfileString

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

 

废话少说,举例如下:

BOOL COLContactFinal2005App::InitInstance()

{

SetRegistryKey(_T("COLContact "));

    WriteProfileString(_T("OLTest"),_T("Test1"),_T("abc"));

}

 

执行上述代码将在注册表生成如下键值:

[HKEY_CURRENT_USER\Software\COLContact \OLContactFinal2005\OLTest]
"Test1"="abc"

http://apps.hi.baidu.com/share/detail/34874018

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值