Страница: 1 |
|
Вопрос: реестр и файлы
|
Добавлено: 25.06.03 19:12
|
|
Автор вопроса: ZoomerSD | ICQ: 148640473
|
вот у меня тут список вопросиков может кто хоть что-то знает. 1)как добавить в реестр папку 2) как добавить в реестр запись или изменить запись 3) как прикрепить к exe шнику файл и потом его скопировать в определённую папку вот и всё
Ответить
|
Номер ответа: 5 Автор ответа: Legik
ICQ: 292375033
Вопросов: 3 Ответов: 72
|
Профиль | | #5
|
Добавлено: 27.06.03 09:07
|
Используй GetRegValue и SetRegValue, соответственно для получения и записи строкового значения: Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Any, lpcbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value. Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As Any, ByVal cbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value. Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Const READ_CONTROL = &H20000 Public Const SYNCHRONIZE = &H100000 Public Const STANDARD_RIGHTS_ALL = &H1F0000 Public Const STANDARD_RIGHTS_READ = (READ_CONTROL) Public Const STANDARD_RIGHTS_WRITE = (READ_CONTROL) Public Const KEY_CREATE_LINK = &H20 Public Const KEY_CREATE_SUB_KEY = &H4 Public Const KEY_ENUMERATE_SUB_KEYS = &H8 Public Const KEY_EVENT = &H1 ' Event contains key event record Public Const KEY_NOTIFY = &H10 Public Const KEY_QUERY_VALUE = &H1 Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE)) Public Const KEY_EXECUTE = ((KEY_READ) And (Not SYNCHRONIZE)) Public Const KEY_SET_VALUE = &H2 Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE)) Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Function GetRegValue(hKey As Long, SubKey As String, NameKey As String) As String Dim x As Long, lpType As Long, lpcbData As Long, phkResult As Long Dim lpData As String * 100 GetRegValue = "" x = RegOpenKeyEx(hKey, SubKey, 0, KEY_ALL_ACCESS, phkResult) If x = 0 Then lpcbData = 100 x = RegQueryValueEx(phkResult, NameKey, 0, lpType, lpData, lpcbData) If x = 0 Then GetRegValue = Mid(lpData, 1, lpcbData - 1) End If x = RegCloseKey(phkResult) End If End Function Sub SetRegValue(hKey As Long, SubKey As String, NameKey As String, lpData As String) Dim x As Long, lpType As Long, cbData As Long Dim phkResult As Long x = RegOpenKeyEx(hKey, SubKey, 0, KEY_ALL_ACCESS, phkResult) cbData = Len(lpData) x = RegSetValueEx(phkResult, NameKey, 0, REG_SZ, lpData, cbData) x = RegCloseKey(phkResult) End Sub
Ответить
|
Номер ответа: 6 Автор ответа: Legik
ICQ: 292375033
Вопросов: 3 Ответов: 72
|
Профиль | | #6
|
Добавлено: 27.06.03 09:07
|
Используй GetRegValue и SetRegValue, соответственно для получения и записи строкового значения: Public Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long Public Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As Any, lpcbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value. Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal lpData As Any, ByVal cbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value. Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Const READ_CONTROL = &H20000 Public Const SYNCHRONIZE = &H100000 Public Const STANDARD_RIGHTS_ALL = &H1F0000 Public Const STANDARD_RIGHTS_READ = (READ_CONTROL) Public Const STANDARD_RIGHTS_WRITE = (READ_CONTROL) Public Const KEY_CREATE_LINK = &H20 Public Const KEY_CREATE_SUB_KEY = &H4 Public Const KEY_ENUMERATE_SUB_KEYS = &H8 Public Const KEY_EVENT = &H1 ' Event contains key event record Public Const KEY_NOTIFY = &H10 Public Const KEY_QUERY_VALUE = &H1 Public Const KEY_READ = ((STANDARD_RIGHTS_READ Or KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY) And (Not SYNCHRONIZE)) Public Const KEY_EXECUTE = ((KEY_READ) And (Not SYNCHRONIZE)) Public Const KEY_SET_VALUE = &H2 Public Const KEY_WRITE = ((STANDARD_RIGHTS_WRITE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY) And (Not SYNCHRONIZE)) Public Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
Function GetRegValue(hKey As Long, SubKey As String, NameKey As String) As String Dim x As Long, lpType As Long, lpcbData As Long, phkResult As Long Dim lpData As String * 100 GetRegValue = "" x = RegOpenKeyEx(hKey, SubKey, 0, KEY_ALL_ACCESS, phkResult) If x = 0 Then lpcbData = 100 x = RegQueryValueEx(phkResult, NameKey, 0, lpType, lpData, lpcbData) If x = 0 Then GetRegValue = Mid(lpData, 1, lpcbData - 1) End If x = RegCloseKey(phkResult) End If End Function Sub SetRegValue(hKey As Long, SubKey As String, NameKey As String, lpData As String) Dim x As Long, lpType As Long, cbData As Long Dim phkResult As Long x = RegOpenKeyEx(hKey, SubKey, 0, KEY_ALL_ACCESS, phkResult) cbData = Len(lpData) x = RegSetValueEx(phkResult, NameKey, 0, REG_SZ, lpData, cbData) x = RegCloseKey(phkResult) End Sub
Ответить
|
Страница: 1 |
Поиск по форуму