阅读:2375回复:22
注册表的删除问题
如何删除2000系统下的注册表加密键。多谢谢大侠们的帮助。郁闷中!!!!!!!!!
[编辑 - 2/27/05 by ZFDok] [编辑 - 3/2/05 by ZFDok] |
|
沙发#
发布于:2005-03-05 17:42
没有用啊!
用lResult = SetSecurityInfo(hRegHandle, SE_REGISTRY_KEY, \\ DACL_SECURITY_INFORMATION | 0x20000000,\\ NULL, NULL, NULL, NULL);时和用 lResult = SetSecurityInfo(hRegHandle, SE_REGISTRY_KEY, \\ DACL_SECURITY_INFORMATION ,\\ NULL, NULL, NULL, NULL);时结果是一样的,怎么回事呢? |
|
板凳#
发布于:2005-03-05 08:50
str = \"SYSTEM\\\\CurrentControlSet\\\\Enum\\\\USB\\\\Vid_0403&Pid_1975\\\\NTNEWDFF\" ; 注册表权限与文件夹权限一样,可以从父亲继承,即子健继承父健的权限,这个权限是不能改的,但当你将继承关掉时,子健将不再继承父健的权限,所以它的所有继承于父健的权限全部消失,这样你必须重新给子健定义权限。建议不要关掉继承,只将父健权限改掉。如果对权限继承不太明白,请找本马克。米纳斯的Master Windows 2000,Master Windows 2003看看 |
|
|
地板#
发布于:2005-03-05 08:05
str = \"SYSTEM\\\\CurrentControlSet\\\\Enum\\\\USB\\\\Vid_0403&Pid_1975\\\\NTNEWDFF\" ;
lResult = SetSecurityInfo(hRegHandle, SE_REGISTRY_KEY, \\ DACL_SECURITY_INFORMATION , \\ NULL, NULL, NULL, NULL); 这个函数编译是通过的,如果这样使用时编译才通不过,lResult = SetSecurityInfo(hRegHandle, SE_REGISTRY_KEY, \\ DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION, \\ NULL, NULL, NULL, NULL); GetLastErrror() = 1008;是在编译通过的情况下的错误代码, 运行后我检查注册表是看到键的权限已经改过来了,可是下面的子键 LogConf和Control变成了灰色,其设置权限中的Everyone 项都没有了,是怎么回事? |
|
地下室#
发布于:2005-03-04 15:11
为什么我的程序编译时提示说error C2065: \'UNPROTECTED_DACL_SECURITY_INFORMATION\' : undeclared identifier 错误? 没编译通过,看GetLastError没用, UNPROTECTED_DACL_SECURITY_INFORMATION 为 0x20000000 |
|
|
5楼#
发布于:2005-03-03 13:57
为什么我的程序编译时提示说error C2065: \'UNPROTECTED_DACL_SECURITY_INFORMATION\' : undeclared identifier 错误?
|
|
6楼#
发布于:2005-03-03 13:27
GetLastError() = 1008
|
|
7楼#
发布于:2005-03-03 08:57
为什么我的提示说error C2065: \'UNPROTECTED_DACL_SECURITY_INFORMATION\' : undeclared identifier 错误? 怪了,看看GetLastError返回什么信息 |
|
|
8楼#
发布于:2005-03-02 20:22
我有#include \"AclApi.h\"
|
|
9楼#
发布于: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); 我的函数有什么问题吗?谢谢大哥! |
|
10楼#
发布于:2005-03-01 15:40
你不是说要在之前用的吗? 是啊,先改权限,然后再打开时才能用全部权限,开始时打开那个没有删除的权限 |
|
|
11楼#
发布于:2005-03-01 13:32
你不是说要在之前用的吗?
|
|
12楼#
发布于:2005-03-01 10:09
那handle 怎样指定,是那个键名的全称吗? 先打开键,设置安全信息,关闭键后,再次用全部权限打开键,删除即可 |
|
|
13楼#
发布于:2005-02-28 20:54
那handle 怎样指定,是那个键名的全称吗?
|
|
14楼#
发布于:2005-02-28 15:33
不成功啊,被拒绝访问。看看此代码哪不对? SetSecurityInfo要在RegOpenKeyEx之前用 |
|
|
15楼#
发布于: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; } } 感谢! |
|
16楼#
发布于:2005-02-27 18:05
非常感谢大佬的回贴,看样子是写得很详细了,我现在还没有仔细看,很感谢。怎么给你加分呢?要重新开贴吗? 不是有给分按钮吗,,,,楼主的。。。帖子下,, |
|
|
17楼#
发布于:2005-02-27 18:02
非常感谢大佬的回贴,看样子是写得很详细了,我现在还没有仔细看,很感谢。怎么给你加分呢?要重新开贴吗?
|
|
18楼#
发布于: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. |
|
|
19楼#
发布于:2005-02-25 19:02
我是用VC 编程的。
|
|
上一页
下一页