Then ''''if the key was created then rtn = RegCloseKey(hKey) ''''close the key SysRegControl = False Exit Function End If
''''========================================================================================= Case regDeleteKeys ''''=114 ''''删除末级子键同regDelAllKey
''''此处Key指定为SubKey下一级子键即被删除子键,SubKey可以为"",key若为"",则删除SubKey子键 ''''调用示例: ''''SysRegControl regHKEY_LOCAL_MACHINE, "", "jadgekylin", "", regTypeBinary, regDeleteKeys ''''SysRegControl regHKEY_LOCAL_MACHINE, "jadgekylin", "", "", regTypeBinary, regDeleteKeys ''''SysRegControl regHKEY_LOCAL_MACHINE, "" , "jadgekylin", "", regTypeBinary, regDeleteKeys ''''========================================================================================= rtn = RegOpenKeyEx(RootKey, SubKey, 0, KEY_WRITE, hKey) ''''open the key If rtn = ERROR_SUCCESS Then ''''if the key could be opened then rtn = RegDeleteKey(hKey, Key) ''''delete the key Else rtn = RegCloseKey(hKey) ''''close the key SysRegControl = False Exit Function End If
''''========================================================================================= Case regDelAllKey ''''=115 ''''删除非末级子键,暂时同RegDeleteKeys ''''========================================================================================= rtn = RegOpenKeyEx(RootKey, SubKey, 0, KEY_WRITE, hKey) ''''open the key If rtn = ERROR_SUCCESS Then ''''if the key could be opened then rtn = RegDeleteKey(hKey, Key) ''''delete the key Else rtn = RegCloseKey(hKey) ''''close the key SysRegControl = False Exit Function End If ''''========================================================================================= Case regDeleteValues ''''=116 ''''删除键值 '''' ''''此处KeyValue,regKeyType为保留字,可以设为任意值,调用示例: ''''SysRegControl regHKEY_LOCAL_MACHINE, "jadgekylin\jklpos", "pos", 0, regTypeDword, regDeleteValues ''''=========================================================================================
rtn = RegOpenKeyEx(RootKey, SubKey, 0, KEY_WRITE, hKey) ''''open the key If rtn = ERROR_SUCCESS Then rtn = RegDeleteValue(hKey, Key) Else rtn = RegCloseKey(hKey) SysRegControl = False Exit Function End If ''''========================================================================================= Case regOther ''''=120 ''''保留操作ID ''''========================================================================================= ''''在此处添加自己的处理 ''''========================================================================================= Case Else ''''========================================================================================= SysRegControl = False Exit Function End Select ''''end if ''''RootKey On Error GoTo 0 SysRegControl = True Exit Function
RegOptionError: ''''错误处理过程在此文中未调用,有必要的可以自己加上处理. ''''If an error does accurr, and the user wants error messages displayed, then ''''display one of the following error messages
Dim lErrorCode As Long Dim GetErrorMsg As String lErrorCode = Err() Select Case lErrorCode Case 1009, 1015 GetErrorMsg = "The Registry Database is corrupt!" Case 2, 1010 GetErrorMsg = "Bad Key Name" Case 1011 GetErrorMsg = "Can''''t Open Key" Case 4, 1012 GetErrorMsg = "Can''''t Read Key" Case 5 GetErrorMsg = "Access to this key is denied" Case 1013 GetErrorMsg = "Can''''t Write Key" Case 8, 14 GetErrorMsg = "Out of memory" Case 87 GetErrorMsg = "Invalid Parameter" Case 234 GetErrorMsg = "There is more data than the buffer has been allocated to hold." Case Else GetErrorMsg = Chr(13) & Chr(10) & Error(Err()) End Select MsgBox "Error: " & Err() & GetErrorMsg Exit Function Resume
End Function
上面这个函数是我作的一个OCX的其中一个方法,有兴趣的朋友可以向我索取此控件..
jadgekylin01@yesky.com
上一页 [1] [2] [3] |