![]() |
|
Модераторы: Akina |
![]()
|
|
| GUI |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 9 Регистрация: 4.6.2003 Репутация: нет Всего: нет |
Опишите, пожалуйста, способ чтения значения параметра из реестра (из произвольного места).
Допустим в программе на VB надо прочесть имя компьютера ... HKEY_LOCAL_MACHINE SYSTEM\CurrentControlSet\ControlActiveComputerName ComputerName или что-то подобное. Заранее благодарю всех за сотрудничество. PS Способ записи и чтения раздела реестра HKEY_CURRENT_USER\Software\VB and VBA Program Settings\... уже описан в MSDN , мне интересно прочесть параметр из ПРОИЗВОЛЬНОГО раздела Это сообщение отредактировал(а) GUI - 4.6.2003, 14:26 |
|||
|
||||
| cardinal |
|
|||
![]() Инженер ![]() ![]() ![]() ![]() Профиль Группа: Экс. модератор Сообщений: 6003 Регистрация: 26.3.2002 Где: Германия Репутация: 19 Всего: 99 |
Вот немного чтиво по поводу этого из MSDN. Если что непонятно то смотри там примеры или спрашивай на форуме.
In Microsoft Windows 3.1 and earlier versions of Windows, program settings like window positions, files used, and other items were commonly stored in .ini files. In Windows NT, Windows 95, and later versions of Windows these program settings are stored in the system registry. Visual Basic provides a standard registry location for storing program information for applications created in Visual Basic: HKEY_CURRENT_USER\Software\VB and VBA Program Settings\appname\section\key Visual Basic also provides four statements and functions to manipulate the settings stored in your application's registry location. Function or Statement Description GetSetting: function Retrieves registry settings. SaveSetting: statement Saves or creates registry settings. GetAllSettings: function Returns an array containing multiple registry settings. DeleteSetting: statement Deletes registry settings. ------------------------------------------------------------------------------------------------------------------------------- GetSetting Function Returns a key setting value from an application's entry in the Windowsregistry. Syntax GetSetting(appname, section, key[, default]) The GetSetting function syntax has thesenamed arguments: Part Description appname Required.String expression containing the name of the application or project whose key setting is requested. section Required. String expression containing the name of the section where the key setting is found. key Required. String expression containing the name of the key setting to return. default Optional.Expression containing the value to return if no value is set in the key setting. If omitted, default is assumed to be a zero-length string (""). Remarks If any of the items named in the GetSetting arguments do not exist, GetSetting returns the value of default. Saves or creates an application entry in the application's entry in the Windowsregistry. ------------------------------------------------------------------------------------------------------------------------------- SaveSetting Statement Syntax SaveSetting appname, section, key, setting The SaveSetting statement syntax has thesenamed arguments: Part Description appname Required.String expression containing the name of the application orproject to which the setting applies. section Required. String expression containing the name of the section where the key setting is being saved. key Required. String expression containing the name of the key setting being saved. setting Required.Expression containing the value that key is being set to. Remarks An error occurs if the key setting can’t be saved for any reason. Deletes a section or key setting from an application's entry in the Windowsregistry. ------------------------------------------------------------------------------------------------------------------------------- DeleteSetting Statement Syntax DeleteSetting appname, section[, key] The DeleteSetting statement syntax has thesenamed arguments: Part Description appname Required.String expression containing the name of the application orproject to which the section or key setting applies. section Required. String expression containing the name of the section where the key setting is being deleted. If only appname and section are provided, the specified section is deleted along with all related key settings. key Optional. String expression containing the name of the key setting being deleted. Remarks If allarguments are provided, the specified setting is deleted. A run-time error occurs if you attempt to use the DeleteSetting statement on a non-existent section or key setting. -------------------- Немецкая оппозиция потребовала упростить натурализацию иммигрантов В моем блоге: Разные истории из жизни в Германии "Познание бесконечности требует бесконечного времени, а потому работай не работай - все едино". А. и Б. Стругацкие |
|||
|
||||
| Cyrax |
|
|||
![]() Новичок Профиль Группа: Участник Сообщений: 2 Регистрация: 29.5.2003 Где: Magnitogors, Russ ia Репутация: нет Всего: нет |
2cardinal: это стандартные VB'шные функции и они работают только с одним разделом реестра
2GUI: смотри в API-Guide описание функций по работе с реестром. раздел называется Registry скачать можно на AllAPI.Net либо на VBRussian.com в разделе Контролы посмотри библиотеку Это сообщение отредактировал(а) Cyrax - 6.6.2003, 17:22 |
|||
|
||||
| cardinal |
|
|||
![]() Инженер ![]() ![]() ![]() ![]() Профиль Группа: Экс. модератор Сообщений: 6003 Регистрация: 26.3.2002 Где: Германия Репутация: 19 Всего: 99 |
А я разве что-то другое говорил? А то, что они с одним разделом реестра работают сделано тоже с замыслом, а именно для того чтобы человек не запортил себе что-нибудь. Если GUI уверен в себе -------------------- Немецкая оппозиция потребовала упростить натурализацию иммигрантов В моем блоге: Разные истории из жизни в Германии "Познание бесконечности требует бесконечного времени, а потому работай не работай - все едино". А. и Б. Стругацкие |
|||
|
||||
| GriKo |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 41 Регистрация: 7.6.2003 Где: Израиль Репутация: нет Всего: нет |
... вот чего нашёл, чтоб в МСДН не копаться....
Как записать\прочитать ключ в реестр 'Registry keys Public Const HKEY_CLASSES_ROOT = &H80000000 Public Const HKEY_CURRENT_USER = &H80000001 Public Const HKEY_LOCAL_MACHINE = &H80000002 Public Const HKEY_USERS = &H80000003 Public Const HKEY_PERFORMANCE_DATA = &H80000004 Public Const HKEY_CURRENT_CONFIG = &H80000005 Public Const HKEY_DYN_DATA = &H80000006 'Registry access constants Public Const KEY_QUERY_VALUE = &H1 'Permission to query subkey data. Public Const KEY_SET_VALUE = &H2 'Permission to set subkey data. Public Const KEY_CREATE_SUB_KEY = &H4 Public Const KEY_ENUMERATE_SUB_KEYS = &H8 Public Const KEY_NOTIFY = &H10 Public Const KEY_CREATE_LINK = &H20 Public Const KEY_READ = KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Public Const KEY_WRITE = KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Public Const KEY_ALL_ACCESS = KEY_QUERY_VALUE Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_SUB_KEY Or KEY_CREATE_LINK Or KEY_SET_VALUE Public Const REG_OPTION_NON_VOLATILE = 0& Public Const REG_OPTION_VOLATILE = &H1 Public Type SECURITY_ATTRIBUTES nLength As Long lpSecurityDescriptor As Long bInheritHandle As Long End Type Public Enum RegTypes RegNonee = 0 RegSZ = 1 RegExpandSz = 2 RegBinary = 3 RegDword = 4 RegDwordLittleEndian = 4 RegDwordBigEndian = 5 RegLink = 6 RegMultiSz = 7 RegResourceList = 8 RegFulResourceDesc = 9 End Enum Declare Function RegOpenKeyEx Lib "advapi32" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long Declare Function RegSetValueEx Lib "advapi32" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, ByVal szData As String, ByVal cbData As Long) As Long Declare Function RegCloseKey Lib "advapi32" (ByVal hKey As Long) As Long Declare Function RegQueryValueEx Lib "advapi32" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal szData As String, ByRef lpcbData As Long) As Long Declare Function RegCreateKeyEx Lib "advapi32" Alias "RegCreateKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal Reserved As Long, ByVal lpClass As String, ByVal dwOptions As Long, ByVal samDesired As Long, ByRef lpSecurityAttributes As SECURITY_ATTRIBUTES, phkResult As Long, lpdwDisposition As Long) As Long Public Function RegGetValue(Root As Long, SubKey As String, Key As String) As String Dim Buffer As String, hKey As Long, nType As Long, nSize As Long RegGetValue = "" If Not RegOpenKeyEx(Root, SubKey, 0, KEY_READ, hKey) Then nSize = 0 RegQueryValueEx hKey, Key, 0, nType, Buffer, nSize If hKey And nSize > 0 And nType = RegSZ Then Buffer = Space(nSize + 1) RegQueryValueEx hKey, Key, 0, nType, Buffer, nSize RegGetValue = Left(Buffer, nSize - 1) RegCloseKey hKey End If End If End Function Public Sub RegSetValue(Root As Long, SubKey As String, Key As String, value As String) Dim hKey As Long, sa As SECURITY_ATTRIBUTES, nDisp As Long If Not RegCreateKeyEx(Root, SubKey, 0, vbNull, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, sa, hKey, nDisp) Then RegSetValueEx hKey, Key, 0, RegSZ, value, Len(value) + 1 RegCloseKey hKey End If End Sub Использование: sUser = RegGetValue(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion", "RegisteredOwner") RegSetValue HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion", "RegisteredOwner", "Darth Vader" |
|||
|
||||
| GUI |
|
|||
|
Новичок Профиль Группа: Участник Сообщений: 9 Регистрация: 4.6.2003 Репутация: нет Всего: нет |
Уважаемые господа!
Благодарю всех за содействие. Отдельное спасибо GriKo - код, присланный Вами, заработал мгновенно и великолепно. GUI. |
|||
|
||||
![]()
|
| Правила форума "VB6" | |
|
|
Запрещается! 1. Публиковать ссылки на вскрытые компоненты 2. Обсуждать взлом компонентов и делиться вскрытыми компонентами
Если Вам понравилась атмосфера форума, заходите к нам чаще! С уважением, Akina. |
| 0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей) | |
| 0 Пользователей: | |
| « Предыдущая тема | VB6 | Следующая тема » |
|
|
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности Powered by Invision Power Board(R) 1.3 © 2003 IPS, Inc. |