Access to Registry from Program : HKEY_LOCAL_MACHINE

Godzestla

New Member
Messages
1
Hello,
this is my first post here so my apologies if this is not the correct Sub-Forum.

I've a thread with VBA code accessing the registry.
This code, getting info from the registry in HKEY_LOCAL_MACHINE perfectly work with XP and VISTA, but does not return any results on a WIN8-64 box, dispte the searched key may be viewed using REGEDIT. (The condition ERROR_NO_MORE_ITEMS is directly met)

I assume the CONST HKEY_LOCAL_MACHINE should be different for WIN8-64, at least, but i don't know where to find the correct values.

Thank you in advance for any help.

Code:
Function Retrieve_Ghostscript_DLL(gs_pkg As Variant) As Boolean
Dim hKey As Long, Cnt As Long, sName As String, sData As String, ret As Long, RetData As Long
Const BUFFER_SIZE As Long = 255
[B]Const ERROR_NO_MORE_ITEMS = 259&
Const HKEY_CURRENT_CONFIG = &H80000005
Const HKEY_LOCAL_MACHINE = &H80000002[/B]
Dim Release As String
Dim Ghoscript_Key As String
Dim objWSH As Object




ret = BUFFER_SIZE
' "RegEnumKeyEx"
'Open the registry key
If RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\GPL Ghostscript", hKey) = 0 Then
    'Create a buffer
    sName = Space(BUFFER_SIZE)
    'Enumerate the keys
    [B]While RegEnumKeyEx(hKey, Cnt, sName, ret, ByVal 0&, vbNullString, ByVal 0&, ByVal 0&) <> ERROR_NO_MORE_ITEMS[/B]
    'Show the enumerated key
        Ghoscript_Key = "HKEY_LOCAL_MACHINE\SOFTWARE\GPL Ghostscript\" & Left$(sName, ret) & "\" & "GS_DLL"
        'prepare for the next key
        Cnt = Cnt + 1
        sName = Space(BUFFER_SIZE)
        ret = BUFFER_SIZE
    Wend
    'close the registry key
    RegCloseKey hKey
  Else
    Debug.Print " Error while calling RegOpenKey"
End If

'Read Ghoscript Key
Set objWSH = CreateObject("WScript.Shell")
Retrieve_Ghostscript_DLL = True

On Error Resume Next
 gs_pkg = objWSH.RegRead(Ghoscript_Key)
 If Err.Number <> 0 Then
    [B] MsgBox "Key """ & Ghoscript_Key & """ not inside the registry."[/B]
     Retrieve_Ghostscript_DLL = False
     gs_pkg = Null
 End If
 On Error GoTo 0

Set objWSH = Nothing

e_gs_dll:
End Function
 

My Computer

System One

  • OS
    XP-VISTA-8
Back
Top