日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

SetRegistryKey的作用

發(fā)布時(shí)間:2024/4/11 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SetRegistryKey的作用 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

SetRegistryKey

(2011-01-30 10:47:25) 轉(zhuǎn)載▼
標(biāo)簽:

雜談

分類(lèi):c 特殊語(yǔ)言用法

?

SetRegistryKeyCauses application settings to be stored in the registryinstead of .INI files.

?

SetRegistryKey 這個(gè)函數(shù)功能是設(shè)置MFC程序的注冊(cè)表訪問(wèn)鍵,并把讀寫(xiě) ini文件的成員函數(shù)映射到讀寫(xiě)注冊(cè)表。只要調(diào)用一下 SetRegistryKey并指定注冊(cè)表鍵值,那么下面6個(gè)成員函數(shù),就被映射到進(jìn)行注冊(cè)表讀取了~

WriteProfileBinaryWrites binary data to an entry in the application's .INIfile.
WriteProfileIntWrites an integer to an entry in the application's .INIfile.
WriteProfileStringWrites a string to an entry in the application's .INIfile.

GetProfileBinaryRetrieves binary data from an entry in the application's .INIfile.
GetProfileIntRetrieves an integer from an entry in the application's .INIfile.
GetProfileStringRetrieves a string from an entry in the application's .INIfile.

MSDN上面寫(xiě)上面6個(gè)函數(shù)是寫(xiě)到INI文件的。所以俺就忽略了其訪問(wèn)注冊(cè)表的功能。無(wú)意中看了其MFC實(shí)現(xiàn)才有所了解。

例子如下:
SetRegistryKey(_T("boli's app"));//這里是準(zhǔn)備在注冊(cè)表HKEY_CURRENT_USER\\software 下面生成一個(gè)boli's app分支~為什么說(shuō)是準(zhǔn)備呢?因?yàn)槿绻徽{(diào)用相關(guān)函數(shù),如上面提到的6個(gè)函數(shù),它是不會(huì)真正讀寫(xiě)注冊(cè)表的。具體本文最最下面的MFC實(shí)現(xiàn)摘錄。
CString strUserName,strPassword;
WriteProfileString("LogInfo","UserName",strUserName);//向注冊(cè)表HKEY_CURRENT_USER\\software\\boli's app\\LogInfo\\分支下寫(xiě)入U(xiǎn)serName 字符串行鍵值~
WriteProfileString("LogInfo","Password",strPassword);//同上~

strUserName = GetProfileString("LogInfo","UserName");//這里是讀取HKEY_CURRENT_USER\\software\\boli's app\\LogInfo\\分支下的UserName 字符串鍵值到 strUserName~
strPassword =GetProfileString("LogInfo","Password");?

如果不是在CWinApp 派生的類(lèi)中讀寫(xiě)注冊(cè)表,可以直接用:
strUserName = theApp.GetProfileString("LogInfo","UserName");
strPassword = theApp.GetProfileString("LogInfo","Password");
或?
strUserName =AfxGetApp()->GetProfileString("LogInfo","UserName");
條條大路通羅馬。

總結(jié)

以上是生活随笔為你收集整理的SetRegistryKey的作用的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。