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. Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

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

    cheers, Paul

  4. #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...

  5. #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.

  6. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    5,896
    Thanks
    0
    Thanked 86 Times in 82 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.

  7. #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

  8. #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
  •