Results 1 to 2 of 2

Thread: RegSetKeySecurity

  1. #1
    simon55
    Guest

    Lightbulb

    I am trying to find a vb example for using RegSetKeySecurity. I want to take ownership of a registry key.

    Can anyone help

  2. #2
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    I do not have a VB example, but maybe this info from MSDN can be a little help:
    Code:
    RegSetKeySecurity
    The RegSetKeySecurity function sets the security of an open registry key. 
    
    LONG RegSetKeySecurity(
      HKEY hKey,  // open handle of key to set
      SECURITY_INFORMATION SecurityInformation,
                  // descriptor contents
      PSECURITY_DESCRIPTOR pSecurityDescriptor 
                  // address of descriptor for key
    );
     
    Parameters
    hKey 
    Identifies an open key for which the security descriptor is set. 
    SecurityInformation 
    Specifies the components of the security descriptor to set. The value can be a combination of the following flags. Value Meaning 
    OWNER_SECURITY_INFORMATION 
     Sets the key's owner security identifier (SID). The hKey handle must have WRITE_OWNER access, or the calling process must be the object's owner or have the SE_TAKE_OWNERSHIP_NAME privilege enabled. 
    GROUP_SECURITY_INFORMATION 
     Sets the key's primary group SID. The hKey handle must have WRITE_OWNER access, or the calling process must be the object's owner. 
    DACL_SECURITY_INFORMATION 
     Sets the key's discretionary access control list (DACL). The hKey handle must have WRITE_DAC access, or the calling process must be the object's owner. 
    SACL_SECURITY_INFORMATION 
     Sets the key's system access control list (SACL). The hKey handle must have ACCESS_SYSTEM_SECURITY access. The proper way to get this access is to enable the SE_SECURITY_NAME privilege in the caller's current access token, open the handle for ACCESS_SYSTEM_SECURITY access, and then disable the privilege. 
    
    
    pSecurityDescriptor 
    Points to a SECURITY_DESCRIPTOR structure that specifies the security attributes to set for the specified key. 
    Return Values
    If the function succeeds, the return value is ERROR_SUCCESS.
    
    If the function fails, the return value is a nonzero error code defined in WINERROR.H. You can use the FormatMessage function with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic description of the error.
    
    Remarks
    If hKey is one of the predefined keys, the predefined key should be closed with RegCloseKey. That ensures that the new security information is in effect the next time the predefined key is referenced. 
    
    QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Unsupported.
      Windows CE: Unsupported.
      Header: Declared in winreg.h.
      Import Library: Use advapi32.lib.
    
    See Also
    Low-Level Access-Control Overview, Low-Level Access Control Functions, RegCloseKey, RegDeleteKey, RegGetKeySecurity, SECURITY_INFORMATION
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

Posting Permissions

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



Click Here to Expand Forum to Full Width