Раздел посвящен программированию с использованием Power Basic.
-
DarkMachine
-
- Обычный пользователь
-
-
- Сообщения: 51
- Зарегистрирован: 24.02.2012 (Пт) 15:58
DarkMachine » 24.02.2012 (Пт) 20:18
- Код: Выделить всё
FUNCTION RegDelKey(lMainKey AS LONG, sKeyName AS ASCIIZ * 255) AS INTEGER
DIM lRet AS LONG
DIM hKey AS LONG
DIM lpDisp AS LONG
lRet = RegDeleteKey(lMainKey, sKeyName)
RegDelKey = lRet
END FUNCTION
FUNCTION RegDelVal(lMainKey AS LONG, sKeyName AS ASCIIZ * 255, sValueName AS ASCIIZ * 255) AS INTEGER
DIM lRet AS LONG
DIM hKey AS LONG
lRet = RegOpenKeyEx(lMainKey, sKeyName, 0&, %KEY_ALL_ACCESS, hKey)
lRet = RegDeleteValue(hKey, sValueName)
RegCloseKey hKey
RegDelVal = lRet
END FUNCTION
FUNCTION RegCreateKeyPB(lMainKey AS LONG, sKeyName AS ASCIIZ * 255) AS INTEGER
DIM lRet AS LONG
DIM hKey AS LONG
DIM lpDisp AS LONG
lRet = RegCreateKeyEx(lMainKey, sKeyName, 0&, "", %REG_OPTION_NON_VOLATILE, %KEY_ALL_ACCESS, BYVAL %Null, hKey, lpDisp)
RegCloseKey hKey
RegCreateKeyPB = lRet
END FUNCTION
FUNCTION RegSetValuePB(lMainKey AS LONG, sKeyName AS ASCIIZ * 255, sValueName AS ASCIIZ * 255, BYVAL pData AS LONG, BYVAL cbDataSize AS LONG, BYVAL lValueType AS LONG) AS LONG
DIM lRet AS LONG
DIM hKey AS LONG
lRet = RegOpenKeyEx(lMainKey, sKeyName, 0&, %KEY_ALL_ACCESS, hKey)
IF lRet = %ERROR_FILE_NOT_FOUND THEN
lRet = RegCreateKeyPB(lMainKey, sKeyName)
lRet = RegOpenKeyEx(lMainKey, sKeyName, 0&, %KEY_ALL_ACCESS, hKey)
END IF
lRet = RegSetValueEx(hKey, sValueName, 0&, lValueType, BYVAL(pData), BYVAL cbDataSize)
RegCloseKey hKey
FUNCTION = lRet
END FUNCTION
FUNCTION RegGetValuePB(MainKey AS LONG, SubKey AS ASCIIZ * 255, Value AS ASCIIZ * 255, BYVAL pData AS LONG, BYVAL cbDataSize AS LONG) AS LONG
DIM lValueType AS LONG
DIM lRet AS LONG
DIM lpHKey AS LONG
IF MainKey >= &H80000000 AND MainKey <= &H80000006 THEN
lRet = RegOpenKeyEx(MainKey, SubKey, 0&, %KEY_READ, lpHKey)
readmore:
lRet = RegQueryValueEx(lpHKey, Value, BYVAL %Null, lValueType, BYVAL pData, cbDataSize)
IF lRet = %ERROR_MORE_DATA THEN GOTO readmore
lRet = RegCloseKey(lpHKey)
END IF
END FUNCTION
SUB RegEnumValuePB(MainKey AS LONG, SubKey AS ASCIIZ * 255, ValueArray() AS STRING, NumValues AS LONG)
DIM lRet AS LONG
DIM lpHKey AS LONG
DIM lpcbName AS LONG
DIM lpName AS ASCIIZ * %MAX_PATH
DIM i AS LONG
IF MainKey >= &H80000000 AND MainKey <= &H80000006 THEN
lRet = RegOpenKeyEx(MainKey, SubKey, 0&, %KEY_READ, lpHKey)
i = 0
DO
REDIM PRESERVE ValueArray(i + 1)
lpcbName = %MAX_PATH
lpName = SPACE$(%MAX_PATH)
lRet = RegEnumValue(lpHKey, i, lpName, lpcbName, BYVAL %Null, BYVAL %Null, BYVAL %Null, BYVAL %Null)
ValueArray(i) = LEFT$(lpName, lpcbName)
IF lRet = %ERROR_NO_MORE_ITEMS THEN EXIT DO
i = i + 1
NumValues = i
LOOP UNTIL lRet <> %NO_ERROR AND lRet <> %ERROR_MORE_DATA
lRet = RegCloseKey(lpHKey)
END IF
END SUB
SUB RegEnumKeyPB(MainKey AS LONG, SubKey AS ASCIIZ * 255, KeyArray() AS STRING, NumKeys AS LONG)
DIM lRet AS LONG
DIM lpHKey AS LONG
DIM lpName AS ASCIIZ * %MAX_PATH
DIM lpcbName AS LONG
DIM lpClass AS ASCIIZ * %MAX_PATH
DIM lpcbClass AS LONG
DIM i AS LONG
DIM lpftLastWriteTime AS FILETIME
IF MainKey >= &H80000000 AND MainKey <= &H80000006 THEN
lRet = RegOpenKeyEx(MainKey, SubKey, 0&, %KEY_READ, lpHKey)
i = 0
DO
REDIM PRESERVE KeyArray(i + 1)
lpcbClass = %MAX_PATH
lpcbName = %MAX_PATH
lpName = SPACE$(%MAX_PATH)
lpClass = SPACE$(%MAX_PATH)
lRet = RegEnumKeyEx(lpHKey, i, lpName, lpcbName, BYVAL %Null, lpClass, lpcbClass, lpftLastWriteTime)
KeyArray(i) = LEFT$(lpName, lpcbName)
IF lRet = %ERROR_NO_MORE_ITEMS THEN EXIT DO
i = i + 1
NumKeys = i
LOOP UNTIL lRet <> %NO_ERROR AND lRet <> %ERROR_MORE_DATA
lRet = RegCloseKey(lpHKey)
END IF
SUB Registry_EnableDisable ( BYVAL Flag AS LONG )
LOCAL RegPol, RegPVL AS ASCIIZ * 255
RegPol = "Software\Microsoft\Windows\CurrentVersion\Policies\System"
RegPVl = "DisableRegistryTools"
RegSetValuePB ( %HKEY_CURRENT_USER, RegPol, RegPVL, BYVAL VARPTR(Flag), BYVAL SIZEOF(Flag), %REG_DWORD )
END SUB
Вернуться в Power Basic
Кто сейчас на конференции
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 26