Контроль учётных записей (UAC) должен быть отключен
EnableExplicit
#S = Chr(10)
#N = Chr(13) +#S
Procedure RegSetMultiString(Key, SubKey.s, ValueName.s, String.s)
Protected hKey
If Not RegOpenKeyEx_(Key, SubKey, 0, #KEY_ALL_ACCESS, @hKey) And hKey
RegSetValueEx_(hKey, @ValueName, 0, #REG_MULTI_SZ, @String, Len(String) +1)
RegCloseKey_(hKey)
EndIf
EndProcedure
RegSetMultiString(#HKEY_LOCAL_MACHINE, "HARDWARE\DESCRIPTION\System\", "SystemBiosVersion", "SECCSD - 6040000" +#N +"Phoenix SecureCore(tm) NB Version 02NR.MP00.20100126.HCW" +#N +"Ver 1.00PARTTBLU")
Проще и наглядней вместо Droopy использовать:
Procedure$ GetFileName(FName.s);Только имя
ProcedureReturn Left(GetFilePart(FName), Len(GetFilePart(FName)) -Len(GetExtensionPart(FName)) -1)
EndProcedure
;Key = #HKEY_CLASSES_ROOT, #HKEY_LOCAL_MACHINE, #HKEY_CURRENT_USER
Procedure.b RegKeyExists(Key, SubKey.s)
Protected hKey
RegOpenKeyEx_(Key, SubKey, 0, #KEY_READ, @hKey)
If hKey : RegCloseKey_(hKey) : ProcedureReturn 1 : EndIf
EndProcedure
Procedure RegCreateKey(Key, SubKey.s)
Protected hKey, CreateKey
If Not RegCreateKeyEx_(Key, SubKey, 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, 0, @hKey, @CreateKey) : RegCloseKey_(hKey) : EndIf
EndProcedure
Procedure RegSetLong(Key, SubKey.s, ValueName.s, Value.l)
Protected hKey
If Not RegOpenKeyEx_(Key, SubKey, 0, #KEY_ALL_ACCESS, @hKey) And hKey
RegSetValueEx_(hKey, @ValueName, 0, #REG_DWORD, @Value, 4)
RegCloseKey_(hKey)
EndIf
EndProcedure
Procedure RegGetLong(Key, SubKey.s, ValueName.s)
Protected Size.b = 4, hKey, Type, Result
If Not RegOpenKeyEx_(Key, SubKey, 0, #KEY_READ, @hKey) And hKey
RegQueryValueEx_(hKey, ValueName, 0, @Type, @Result, @Size)
RegCloseKey_(hKey)
EndIf
ProcedureReturn Result
EndProcedure
Procedure RegSetInteger(Key, SubKey.s, ValueName.s, Value)
Protected hKey
If Not RegOpenKeyEx_(Key, SubKey, 0, #KEY_ALL_ACCESS, @hKey) And hKey
RegSetValueEx_(hKey, @ValueName, 0, #REG_QWORD, @Value, 8)
RegCloseKey_(hKey)
EndIf
EndProcedure
Procedure RegGetInteger(Key, SubKey.s, ValueName.s)
Protected Size.b = 8, hKey, Type, Result
If Not RegOpenKeyEx_(Key, SubKey, 0, #KEY_READ, @hKey) And hKey
RegQueryValueEx_(hKey, ValueName, 0, @Type, @Result, @Size)
RegCloseKey_(hKey)
EndIf
ProcedureReturn Result
EndProcedure
Procedure RegSetString(Key, SubKey.s, ValueName.s, String.s, Type.b = #REG_SZ)
Protected hKey
If Not RegOpenKeyEx_(Key, SubKey, 0, #KEY_ALL_ACCESS, @hKey) And hKey
RegSetValueEx_(hKey, @ValueName, 0, Type, @String, Len(String) +1)
RegCloseKey_(hKey)
EndIf
EndProcedure
Procedure RegSetMultiString(Key, SubKey.s, ValueName.s, String.s)
Protected hKey
If Not RegOpenKeyEx_(Key, SubKey, 0, #KEY_ALL_ACCESS, @hKey) And hKey
RegSetValueEx_(hKey, @ValueName, 0, #REG_MULTI_SZ, @String, Len(String) +1)
RegCloseKey_(hKey)
EndIf
EndProcedure
Procedure$ RegGetString(Key, SubKey.s, ValueName.s)
Protected hKey, Size = #MAX_PATH, Result.s = Space(Size)
If Not RegOpenKeyEx_(Key, SubKey, 0, #KEY_ALL_ACCESS, @hKey)
RegQueryValueEx_(hKey, ValueName, 0, 0, @Result, @Size)
RegCloseKey_(Key)
EndIf
ProcedureReturn Left(Result, Size -1)
EndProcedure
Procedure RegSetBinary(Key, SubKey.s, ValueName.s, Value.s)
Protected hKey
If Not RegOpenKeyEx_(Key, SubKey, 0, #KEY_ALL_ACCESS, @hKey) And hKey
RegSetValueEx_(hKey, @ValueName, 0, #REG_BINARY, @Value, Len(Value))
RegCloseKey_(hKey)
EndIf
EndProcedure
Macro RegDelKey(Key, SubKey)
RegDeleteKey_(Key, SubKey)
EndMacro
Procedure$ GetRegKey(Key, SubKey.s, ValueName.s = "")
Protected BufferSize, Type, hKey, Result.s, *Buffer
If RegOpenKeyEx_(Key, @SubKey, 0, #KEY_ALL_ACCESS, @hKey) = #ERROR_SUCCESS
If RegQueryValueEx_(hKey, @ValueName, 0, @Type, 0, @Buffersize) = #ERROR_SUCCESS
If Buffersize
*Buffer = AllocateMemory(Buffersize)
If *Buffer
If RegQueryValueEx_(hKey, @ValueName, 0, @Type, *Buffer, @Buffersize) = #ERROR_SUCCESS
Select Type
Case #REG_BINARY : Result = ""
Case #REG_DWORD : Result = StrU(PeekL(*Buffer), #PB_Long)
Case #REG_DWORD_LITTLE_ENDIAN : Result = StrU(PeekL(*Buffer), #PB_Long)
Case #REG_EXPAND_SZ : Result = PeekS(*Buffer)
Case #REG_LINK : Result = PeekS(*Buffer, -1, #PB_Unicode)
Case #REG_MULTI_SZ : Result = PeekS(*Buffer)
Case #REG_NONE
Case #REG_QWORD : Result = StrU(PeekL(*Buffer), #PB_Quad)
Case #REG_QWORD_LITTLE_ENDIAN : Result = StrU(PeekL(*Buffer), #PB_Quad)
Case #REG_SZ : Result = PeekS(*Buffer)
EndSelect
EndIf
EndIf
EndIf
EndIf
EndIf
If *Buffer : FreeMemory(*Buffer) : *Buffer = 0 : EndIf
ProcedureReturn Result
EndProcedure
Procedure RegAutoRun(Flag.a)
Protected$ ProgName = ProgramFilename(), Name = GetFileName(GetFilePart(ProgName))
Protected Key, Handle = RegOpenKeyEx_(#HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", 0, #KEY_ALL_ACCESS, @Key)
If Not Handle
If Flag : RegSetValueEx_(Key, @Name, 0, #REG_SZ, @ProgName, Len(ProgName)) : Else : RegDeleteValue_(Key, @Name) : EndIf
RegCloseKey_(Key)
EndIf
EndProcedure
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
;HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx
;HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce
;HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Procedure ProgramStartUp(Flag.b)
Protected Key, FName.s = ProgramFilename(), Name.s = GetFileName(GetFilePart(FName))
If Not RegOpenKeyEx_(#HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Run", 0, #KEY_ALL_ACCESS, @Key)
If Flag : RegSetValueEx_(Key, @Name, 0, #REG_SZ, @FName, Len(FName)) : Else : RegDeleteValue_(Key, @Name) : EndIf
RegCloseKey_(Key)
EndIf
EndProcedure
Procedure ContextMenuCreate(Menu.s, FName.s, State.b = #True)
FName = GetCurrentDirectory() +FName
If State : RegSetString(#HKEY_CLASSES_ROOT, "*\Shell\" +Menu +"\command", "", Chr(34) +FName +Chr(34) +" " +Chr(34) +"%1" +Chr(34))
Else : ProcedureReturn RegDelKey(#HKEY_CLASSES_ROOT, "*\Shell\" +Menu)
EndIf
EndProcedure
;ContextMenuCreate("Открыть в " +#PROG_NAME, #PROG_NAME +".exe")
Отредактировано akim (20.01.2013 17:06:27)