Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7783551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:52:19+00:00 2026-06-01T19:52:19+00:00

I took the following python recipe from Activestate.org, then I simply added the method

  • 0

I took the following python recipe from Activestate.org, then I simply added the method for deleting the key, however I getting error 5, access denied, and the key it’s only a fake key which I have just created to try out the function . Here ‘s the code

## {{{ http://code.activestate.com/recipes/576860/ (r2)
import win32api
import win32con

def regquerysubkeys(handle, key, keylist=[]):

#get registry handle
    reghandle = win32api.RegOpenKeyEx(handle, key, 0, win32con.KEY_ALL_ACCESS)    
    try:
        i = 0
    #enumerates subkeys and recursively calls this function again
        while True:
            subkey = win32api.RegEnumKey(reghandle, i)
            #the following is the line I added myself
            win32api.RegDeleteKey(handle, key)


            i += 1
        #braintwister here ;-)
            regquerysubkeys(handle, key + subkey + "\\", keylist)
    except win32api.error as ex:
        #If no more subkeys can be found, we can append ourself
        if ex[0] == 259:
            keylist.append(key)
        #unexpected exception is raised
        else:
            raise
    finally:
    #do some cleanup and close the handle
        win32api.RegCloseKey(reghandle)
#returns the generated list
    print keylist

#call to the function
regquerysubkeys(win32con.HKEY_LOCAL_MACHINE, "SOFTWARE\\suga\\") 

Those are the errors I m getting in the console.

Traceback (most recent call last):
File "C:\EclipseWorkspaces\csse120\MMS-auto\test1.py", line 34, in <module>
regquerysubkeys(win32con.HKEY_LOCAL_MACHINE, "SOFTWARE\\suga\\")
File "C:\EclipseWorkspaces\csse120\MMS-auto\test1.py", line 14, in regquerysubkeys
win32api.RegDeleteKey(handle, key)
pywintypes.error: (5, 'RegDeleteKey', 'Access is denied.')

Can anyone help out with it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:52:20+00:00Added an answer on June 1, 2026 at 7:52 pm

    Are you running 64-bit Windows 7 by any chance? There were some changes in the structure of the registry to account for running both 32-bit and 64-bit programs that require that you use different APIs for deletion. The RegDeleteKey Win32 API documentation mentions using RegDeleteKeyEx in some cases. The Win32 API is difficult to use reliably from one major version of Windows to the next. Unfortunately, pywin32 does its best to hide a number of the headaches, but it still requires that you really know the Win32 API and its caveats before you can effectively use it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I took the following code from the examples page on Asio class tcp_connection :
Following code is to save image took from camera into photo album. if ([mediaType
Following on from some comments of late, I have took the plunge and started
I took this from Jon Skeet's C# in depth. He mentioned the following is
I have the following text from an academic course I took a while ago
The following question is from a quiz I took a few weeks ago and
I took the following example from Jrista's answer to a post. Finding Twentyone count
While the following code is saving the image I took from my application into
A took a look at http://erlang.org/doc/apps/inets/http_client.html and found the following: An ordinary asynchronous request.
I took from somewhere the following script which clears all input controls in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.