第2个回答 2009-02-04
代码如下。
===============================
Option Explicit
Dim hR As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private 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 ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Private Sub Command1_Click()
RegOpenKey HKEY_LOCAL_MACHINE, "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\Folder\Hidden\SHOWALL", hR '这里是项名
Dim r As Long
r = RegQueryValueEx(hR, "CheckedValue", 0, 0, 0, 0)
If r = 2 Then
MsgBox "不存在"
Else
MsgBox "存在"
End If
End Sub