Code: Select all
Procedure CreateKey(topKey, sKeyName.s, ComputerName.s)
If ComputerName = ""
GetHandle = RegCreateKeyEx_(topKey, sKeyName, 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, @lpSecurityAttributes, @hNewKey, @GetHandle)
Else
lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry)
GetHandle = RegCreateKeyEx_(lhRemoteRegistry, sKeyName, 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, @lpSecurityAttributes, @hNewKey, @GetHandle)
EndIf
If GetHandle = #ERROR_SUCCESS
GetHandle = RegCloseKey_(hNewKey)
CreateKey = 1
Else
CreateKey = 0
EndIf
ProcedureReturn CreateKey
EndProcedure
Procedure SetValue(topKey.l, sKeyName.s, sValueName.s, vValue.s, lType.l, ComputerName.s)
If ComputerName = ""
GetHandle = RegOpenKeyEx_(topKey, sKeyName, 0, #KEY_ALL_ACCESS, @hKey)
Else
lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry)
GetHandle = RegOpenKeyEx_(lhRemoteRegistry, sKeyName, 0, #KEY_ALL_ACCESS, @hKey)
EndIf
If GetHandle = #ERROR_SUCCESS
Select lType
Case #REG_SZ
GetHandle = RegSetValueEx_(hkey, sValueName, 0, #REG_SZ, @vValue, Len(vValue) + 1)
Case #REG_DWORD
lValue = Val(vValue)
GetHandle = RegSetValueEx_(hKey, sValueName, 0, #REG_DWORD, @lValue, 4)
EndSelect
RegCloseKey_(hkey)
SetValue = 1
Else
RegCloseKey_(hKey)
SetValue = 0
EndIf
ProcedureReturn SetValue
EndProcedure
Procedure DeleteKey(topKey.l, sKeyName.s, ComputerName.s)
If ComputerName = ""
GetHandle = RegDeleteKey_(topKey, @sKeyName)
Else
lReturnCode = RegConnectRegistry_(ComputerName, topKey, @lhRemoteRegistry)
GetHandle = RegDeleteKey_(lhRemoteRegistry, @sKeyName)
EndIf
If GetHandle = #ERROR_SUCCESS
DeleteKey = 1
Else
DeleteKey = 0
EndIf
ProcedureReturn DeleteKey
EndProcedure
sTopKey.l = #HKEY_CURRENT_USER
sKeyName.s = "SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
;**********************( Disable Task Manager )*****************************
;
CreateKey(sTopKey, sKeyName, "")
SetValue(sTopKey, sKeyName, "DisableTaskMgr", "01", #REG_DWORD, "")
;**********************(Enable Task Manager )*******************************
;DeleteKey(sTopKey, sKeyName, "")