Results 1 to 7 of 7
  1. #1
    New Lounger
    Join Date
    Dec 2009
    Location
    Melbourne, Australia
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi all,

    I am using a function that I got from another user to read the registry and while it works under Windows XP, it fails under Win 7. Here's the function:

    Function DymoLabelFolder() As String
    Dim Desc As String, hKey As Long, cb As Long, strPath As String, q As Variant
    RegOpenKeyEx HKEY_LOCAL_MACHINE, "Software\DYMO\LabelWriter\Defaults\Directorie s", 0, KEY_ALL_ACCESS, hKey
    RegQueryValueExNULL hKey, "Label Directory", 0&, REG_SZ, 0&, cb
    strPath = String(cb, 0)
    RegQueryValueExString hKey, "Label Directory", 0&, REG_SZ, strPath, cb
    DymoLabelFolder = Left(strPath, cb - 1) + "\"
    End Function

    hKey and cb both stay 0 when running this function under Win 7 which makes me think that the RegOpenKeyEx line is failing. Is there a better way to get that folder listing that will work across Windows versions?

    Thanks for the assistance...!

    CK

  2. #2
    Platinum Lounger
    Join Date
    Dec 2009
    Location
    Earth
    Posts
    3,840
    Thanks
    7
    Thanked 253 Times in 238 Posts
    Is the registry key the same in W7? Have a look in regedit.

    cheers, Paul

  3. #3
    New Lounger
    Join Date
    Dec 2009
    Location
    Melbourne, Australia
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes the key is in the same location as it was...

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    Could it be a permissions issue? Not sure whether/how you can gain access to other programs' registry settings in Windows 7.

  5. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,939
    Thanks
    0
    Thanked 94 Times in 90 Posts
    I suspect you will find it works if you turn off User Account Control. Failing that, I think the VBScript Shell registry methods will work regardless, unlike the API. And IIRC, if you are using 64-bit Win7, there's an issue with virtualised registry keys too when using the API.
    Regards,
    Rory
    Microsoft MVP - Excel.

  6. #6
    New Lounger
    Join Date
    Dec 2009
    Location
    Melbourne, Australia
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Rory - I'll give that a try and report back

  7. #7
    New Lounger
    Join Date
    Dec 2009
    Location
    Melbourne, Australia
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rory,

    I tested this out tonight and the function works when UAC is disabled - thanks for this...

    CK

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •