资源描述:
《注册表api函数(registry api function)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、注册表api函数(RegistryAPIfunction)AboutregistryAPIfunctionAuthor:loose_wentreadingtime:341articlesource:VConlinereleasetime:2007-8-22userscomments(0)articleRegistryoperations,APIprovidesuswithabout25functions.Heprovidestheregistryread,write,delete,andopentheregistryandkeyvaluesofallfunctions,and
2、canachievethebackupoftheregistry,connectionsandremoteregistryview,andsoon.Registryisveryimportanttothewholesystem.Youmustthinkitoverwhenyoudoit.Thesefunctionshave:RegCloseKey,RegConnectRegistry,RegCreateKey,RegCreateKeyEx,RegDeleteKey,RegDeleteValeRegEnumKeyRegFlushKeyRegGetKeySecurity(this
3、function98doesnotapply)RegLoadKeyRegNotifyChangeKeyValue(98doesnotapply)RegOpenKey,RegOpenKeyEx,RegQueryInfoKey,RegQueryValueRegQueryValueExRegReplaceKeyRegRestoreKey(98doesnotapply)RegSaveKeyRegSetKeySecurity(98doesnotapply)RegSetValue,RegSetValueEx,RegUnLoadKeyWeintroduceseveralfunctionst
4、hatarefrequentlyused.1.RegClose()LONGRegCloseKeyHKEYhKey//releaseregistryhandleshasbeenopened);Returnvalue:unsuccessfulreturn.No0,successfullyreturnedERROR_SUCCESSExplanation:closesthespecifiedmastertablekeyandreleasesthehandle.Whenoneormorekeysorvaluesarecompleted,youneedtoturnoffthekeytos
5、avetheoperation.Whenakeyisclosed,thehandlebecomesillegalsothatitcannotbeusedagain.Thehandleisreleasedforsystemreuse.ExampleBOOLbRet=TRUE;If(m_hKey=NULL)Return(FALSE);BRet=(::RegCloseKey(m_hKey)=ERROR_SUCCESS);M_hKey=NULL;Return(bRet);2.RegCreateKeyEx()andRegCreateKey()LONGRegCreateKeyExHKEY
6、hKey,//primarykeynameLPCTSTRlpSubKey//subkeynameorpathDWORDReserved//reservations,0LPTSTRlpClass//Ididnotunderstand,isalsoalmostemptyDWORDdwOptions,Someoftheoptionsforyoutobuild/*key,canthesevaluesare:REG_OPTION_NON_VOLATILE,REG_OPTION_VOLATILE,REG_OPTION_BACKUP_RESTORE,thefirstisthedefault
7、.Generally,thefirstoneisok.*/REGSAMsamDesired,//permissionstoaccessthekeysettingsofyourbuildingLPSECURITY_ATTRIBUTESlpSecurityAttributes,//don'tunderstandPHKEYphkResult,//handlepointsyoubuiltLPDWORDlpdwDisposition//toseeistoopenaneworexistingkey,key);The