Поскажите,как узнать показываются ли скрытые файлы или нет на VB.6
т.е стоит радио кнопка в меню сервис->вид->показать скрытые файлы
в положение показать или не показывать(спрятать)
и если онf стоит в положение показать, сделать так что б она стала в положение не показывать
В этом разделе Hidden есть два подраздела SHOWALL NOHIDDEN, эти два раздела существуют постояно не зависимо от положения кнопки,
при смене положения радио кнопки скрыть показать скрытые файлы они как были так и остаются не измеными, так какие же параметры счтитывать.
Hidden - не раздел, а параметр. Наверное, не туда смотришь. На NT 5.1 (XP) если скрытие включено - параметр равен 2, если отключено - 1 (параметр типа REG_DWORD).
Подскажите как правильно считывать данные и записывать в формате RegDword
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
'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
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
 im Buffer As String, hKey As Long, nType As Long, nSize As Long
RegGetValue = 0
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)
 im 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
' вместо Key - имя строковой переменной (которая будет храниться
' в реестре)
' вместо StringValue - значение строковой переменной
я поменял значения на свои вот как
Private Sub Command1_Click()
Dim a As Variant
Text1.Text = RegGetValue(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden"
End Sub
Private Sub Command2_Click()
RegSetValue HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden", "1"
End Sub
но как я понял эти функции меняют и получают данные только из строковых параметров , а каких переделать что б они получали данные из параметров RegDword я так и не понял
Единственное что я догался так это в строке RegSetValueEx hKey, Key, 0, RegSZ, value, Len(value) + 1
понять RegSZ на RegDword тогда вроде данные передаются в формате RegDword но пишется что не правильное значение RegDword
и при использование фунции RegGetValue всегда получаю 0
Код модуля
' -----------------
' ADVAPI32
' -----------------
' function prototypes, constants, and type definitions
' for Windows 32-bit Registry API
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 ERROR_SUCCESS = 0&
' Registry API prototypes
Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Public Const REG_DWORD = 4 ' 32-bit number
Function getdword(ByVal Hkey As Long, ByVal strPath As String, ByVal strValueName As String) As Long
Dim lResult As Long
Dim lValueType As Long
Dim lBuf As Long
Dim lDataBufSize As Long
Dim r As Long
Dim keyhand As Long
If lResult = ERROR_SUCCESS Then
If lValueType = REG_DWORD Then
getdword = lBuf
End If
'Else
' Call errlog("GetDWORD-" & strPath, False)
End If
r = RegCloseKey(keyhand)
End Function
Function SaveDword(ByVal Hkey As Long, ByVal strPath As String, ByVal strValueName As String, ByVal lData As Long)
 im lResult As Long
 im keyhand As Long
 im r As Long
r = RegCreateKey(Hkey, strPath, keyhand)
lResult = RegSetValueEx(keyhand, strValueName, 0&, REG_DWORD, lData, 4)
'If lResult <> error_success Then Call errlog("SetDWORD", False)
r = RegCloseKey(keyhand)
End Function
код формы
Private Sub Form_Load()
Dim lngDword As String
'Get a String out the Registry
lngDword = getdword(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden"
If lngDword = 1 Then
Call SaveDword(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "Hidden", "2"
End If