diff --git a/src/lib.rs b/src/lib.rs index c48a5cf..341b309 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -443,8 +443,8 @@ impl RegKey { EnumValues{key: self, index: 0} } - /// Delete key. Cannot delete if it has subkeys. - /// Will delete itself if `path` is an empty string. + /// Delete key.Key names are not case sensitive. + /// Cannot delete if it has subkeys. /// Use `delete_subkey_all` for that. /// /// # Examples @@ -460,7 +460,7 @@ impl RegKey { match unsafe { advapi32::RegDeleteKeyW( self.hkey, - c_path.as_ptr(), + c_path.as_ptr(), //This parameter cannot be NULL. ) as DWORD } { 0 => Ok(()), @@ -475,11 +475,11 @@ impl RegKey { match unsafe { advapi32::RegDeleteKeyTransactedW( self.hkey, - c_path.as_ptr(), + c_path.as_ptr(), //The value of this parameter cannot be NULL. 0, 0, t.handle, - ptr::null_mut(), + ptr::null_mut(), ) as DWORD } { 0 => Ok(()), @@ -489,6 +489,7 @@ impl RegKey { /// Recursively delete subkey with all its subkeys and values. /// Will delete itself if `path` is an empty string. + /// If `path` is an empty string, the subkeys and values of this key are deleted. /// /// # Examples /// @@ -499,11 +500,18 @@ impl RegKey { /// .delete_subkey_all("Software\\MyProduct").unwrap(); /// ``` pub fn delete_subkey_all>(&self, path: P) -> io::Result<()> { - let c_path = to_utf16(path); + let c_path; + let path_ptr; + if path.as_ref().is_empty(){ + path_ptr = ptr::null(); + }else{ + c_path = to_utf16(path); + path_ptr = c_path.as_ptr(); + } match unsafe{ advapi32::RegDeleteTreeW( self.hkey, - c_path.as_ptr(), + path_ptr,//If this parameter is NULL, the subkeys and values of this key are deleted. ) as DWORD } { 0 => Ok(()),