阅读:2271回复:22
注册表的删除问题
如何删除2000系统下的注册表加密键。多谢谢大侠们的帮助。郁闷中!!!!!!!!!
[编辑 - 2/27/05 by ZFDok] [编辑 - 3/2/05 by ZFDok] |
|
沙发#
发布于:2005-02-25 10:12
需要修改一下Token权限
|
|
|
板凳#
发布于:2005-02-25 15:45
怎样修改权限啊,写一段代码来看看,我不会设置权限。小弟初学VC
给你加分。但不知道怎样加。昨天还看到有加分的标识。今天就不见了。怎么回事? |
|
地板#
发布于:2005-02-25 16:11
如何删除2000系统下的注册表加密键。多谢谢大侠们的帮助。郁闷中!!!!!!!!! 直接删不可以吗? [编辑 - 2/25/05 by aiwadgj] |
|
|
地下室#
发布于:2005-02-25 19:02
我是用VC 编程的。
|
|
5楼#
发布于:2005-02-26 09:05
看看这个API,SetSecurityInfo,其中的SE_OBJECT_TYPE设置为SE_REGISTRY_KEY
全文帖出 The SetSecurityInfo function sets specified security information in the security descriptor of a specified object. The caller identifies the object by a handle. DWORD SetSecurityInfo( HANDLE handle, // handle to the object SE_OBJECT_TYPE ObjectType, // type of object SECURITY_INFORMATION SecurityInfo, // type of security information to set PSID psidOwner, // pointer to the new owner SID PSID psidGroup, // pointer to the new primary group SID PACL pDacl, // pointer to the new DACL PACL pSacl // pointer to the new SACL ); Parameters handle A handle to the object for which to set security information. ObjectType Specifies a value from the SE_OBJECT_TYPE enumeration that indicates the type of object identified by the handle parameter. SecurityInfo A set of SECURITY_INFORMATION bit flags that indicate the type of security information to set. This parameter can be a combination of the following values. Value Meaning OWNER_SECURITY_INFORMATION Set the owner security identifier (SID) in the object\'s security descriptor. The psidOwner parameter points to the new SID. GROUP_SECURITY_INFORMATION Set the primary group SID in the object\'s security descriptor. The psidGroup parameter points to the new SID. DACL_SECURITY_INFORMATION Set the discretionary access-control list (DACL) in the object\'s security descriptor. The pDacl parameter points to the new DACL. SACL_SECURITY_INFORMATION Set the system access-control list (SACL) in the object\'s security descriptor. The pSacl parameter points to the new SACL. psidOwner Pointer to a SID that identifies the object\'s owner. The SID must be one that can be assigned as the owner SID of a security descriptor. The SecurityInfo parameter must include the OWNER_SECURITY_INFORMATION flag. The caller must have WRITE_OWNER access to the object or have the SE_TAKE_OWNERSHIP_NAME privilege enabled. This parameter can be NULL if you are not setting the owner SID. psidGroup Pointer to a SID that identifies the object\'s primary group. The SecurityInfo parameter must include the GROUP_SECURITY_INFORMATION flag. This parameter can be NULL if you are not setting the primary group SID. pDacl Pointer to the new DACL for the object. The SecurityInfo parameter must include the DACL_SECURITY_INFORMATION flag. The caller must have WRITE_DAC access to the object or be the object\'s owner. This parameter can be NULL if you are not setting the DACL. pSacl Pointer to the new SACL for the object. The SecurityInfo parameter must include the SACL_SECURITY_INFORMATION flag. The caller must have the SE_SECURITY_NAME privilege enabled. This parameter can be NULL if you are not setting the SACL. 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. The SE_OBJECT_TYPE enumeration type contains values that correspond to the types of Win32 objects that support security. The GetSecurityInfo, SetSecurityInfo, GetNamedSecurityInfo, and SetNamedSecurityInfo functions use these values to indicate the type of object. typedef enum _SE_OBJECT_TYPE { SE_UNKNOWN_OBJECT_TYPE = 0, SE_FILE_OBJECT, SE_SERVICE, SE_PRINTER, SE_REGISTRY_KEY, SE_LMSHARE, SE_KERNEL_OBJECT, SE_WINDOW_OBJECT } SE_OBJECT_TYPE; Enumerator Meaning SE_FILE_OBJECT Indicates a file or directory. The name string that identifies a file or directory object can be ?A relative path, such as \"abc.dat\" or \"..\\abc.dat\"?An absolute path, such as \"\\abc.dat\", \"c:\\dir1\\abc.dat\", or \"g:\\remotedir\\abc.dat\"?A UNC name, such as \"\\\\machinename\\sharename\\abc.dat\".?A local file system root, such as \"\\\\\\\\.\\\\c:\". Security set on a file system root does not persist when the system is restarted. SE_SERVICE Indicates a Windows NT service. A service object can be a local service, such as \"servicename\"; or a remote service, such as \"\\\\machinename\\servicename\". SE_PRINTER Indicates a printer. A printer object can be a local printer, such as \"printername\"; or a remote printer, such as \"\\\\machinename\\printername\". SE_REGISTRY_KEY Indicates a registry key. A registry key object can be in the local registry, such as \"CLASSES_ROOT\\somepath\"; or in a remote registry, such as \"\\\\machinename\\CLASSES_ROOT\\somepath\". The names of registry keys must use the following literal strings to identify the predefined registry keys: \"CLASSES_ROOT\", \"CURRENT_USER\", \"MACHINE\", and \"USERS\". SE_LMSHARE Indicates a Windows NT network share. A share object can be local, such as \"sharename\"; or remote, such as \"\\\\machinename\\sharename\". SE_KERNEL_OBJECT Indicates a local kernel object, which can be any of the following: a process, thread, semaphore, event, mutex, file mapping, or waitable timer. Only some kernel objects can be identified by name. Note that the GetSecurityInfo, SetSecurityInfo, GetNamedSecurityInfo, and SetNamedSecurityInfo functions do not work with the following types of kernel objects: access token, console screen buffer, mailslot, named pipe, and anonymous pipe. SE_WINDOW_OBJECT Indicates a window station or desktop object on the local computer. |
|
|
6楼#
发布于:2005-02-27 18:02
非常感谢大佬的回贴,看样子是写得很详细了,我现在还没有仔细看,很感谢。怎么给你加分呢?要重新开贴吗?
|
|
7楼#
发布于:2005-02-27 18:05
非常感谢大佬的回贴,看样子是写得很详细了,我现在还没有仔细看,很感谢。怎么给你加分呢?要重新开贴吗? 不是有给分按钮吗,,,,楼主的。。。帖子下,, |
|
|
8楼#
发布于:2005-02-28 13:31
不成功啊,被拒绝访问。看看此代码哪不对?
BOOL CSonicsUnDlg::WinNTDelRegKey() { CFile fn ; CFileFind SonicsFinder ; HKEY hRegHandle; long lResult ; DWORD dwRegType = REG_SZ ; DWORD dwPathSize = 80 ; UCHAR SonicsInfPath[80] ; str = \"SYSTEM\\\\CurrentControlSet\\\\Enum\\\\USB\\\\Vid_0403&Pid_1975\\\\NTNEWDFF\" ; lResult = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, str, NULL, KEY_READ, &hRegHandle); if (lResult == ERROR_SUCCESS) { lResult = SetSecurityInfo(hRegHandle, SE_REGISTRY_KEY, OWNER_SECURITY_INFORMATION, \\ NULL, NULL, NULL, NULL); lResult = SHDeleteKey(HKEY_LOCAL_MACHINE, str); if (lResult == ERROR_SUCCESS) { MessageBox(\"Delete the reg key Vid_0403&Pid_1975 successful\"); } else { MessageBox(\"Delete reg key unsuccessful\"); } ::RegCloseKey(hRegHandle) ; } else { MessageBox(\"RegOpenKeyEx unsuccessful\"); return FALSE; } } 感谢! |
|
9楼#
发布于:2005-02-28 15:33
不成功啊,被拒绝访问。看看此代码哪不对? SetSecurityInfo要在RegOpenKeyEx之前用 |
|
|
10楼#
发布于:2005-02-28 20:54
那handle 怎样指定,是那个键名的全称吗?
|
|
11楼#
发布于:2005-03-01 10:09
那handle 怎样指定,是那个键名的全称吗? 先打开键,设置安全信息,关闭键后,再次用全部权限打开键,删除即可 |
|
|
12楼#
发布于:2005-03-01 13:32
你不是说要在之前用的吗?
|
|
13楼#
发布于:2005-03-01 15:40
你不是说要在之前用的吗? 是啊,先改权限,然后再打开时才能用全部权限,开始时打开那个没有删除的权限 |
|
|
14楼#
发布于:2005-03-02 20:21
为什么我的提示说error C2065: \'UNPROTECTED_DACL_SECURITY_INFORMATION\' : undeclared identifier 错误?
是这样访问吗? lResult = SetSecurityInfo(hRegHandle, SE_REGISTRY_KEY, \\ DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION, \\ NULL, NULL, NULL, NULL); 可以以全部权限打开键,但是删除不了,被拒绝访问,为什么啊? lResult = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, str, NULL, KEY_ALL_ACCESS, &hRegHandle); lResult = ::RegDeleteKey(HKEY_LOCAL_MACHINE, str); 我的函数有什么问题吗?谢谢大哥! |
|
15楼#
发布于:2005-03-02 20:22
我有#include \"AclApi.h\"
|
|
16楼#
发布于:2005-03-03 08:57
为什么我的提示说error C2065: \'UNPROTECTED_DACL_SECURITY_INFORMATION\' : undeclared identifier 错误? 怪了,看看GetLastError返回什么信息 |
|
|
17楼#
发布于:2005-03-03 13:27
GetLastError() = 1008
|
|
18楼#
发布于:2005-03-03 13:57
为什么我的程序编译时提示说error C2065: \'UNPROTECTED_DACL_SECURITY_INFORMATION\' : undeclared identifier 错误?
|
|
19楼#
发布于:2005-03-04 15:11
为什么我的程序编译时提示说error C2065: \'UNPROTECTED_DACL_SECURITY_INFORMATION\' : undeclared identifier 错误? 没编译通过,看GetLastError没用, UNPROTECTED_DACL_SECURITY_INFORMATION 为 0x20000000 |
|
|
上一页
下一页