diff options
author | Salim Alam <salam@chef.io> | 2015-08-27 16:17:49 -0700 |
---|---|---|
committer | Salim Alam <salam@chef.io> | 2015-08-27 16:17:49 -0700 |
commit | 71925f0b253c0dd1b0943029d5399c3e20641ced (patch) | |
tree | 57355bf57cf02780577aef38e615e412830b5ac6 | |
parent | 397e983aba9c1dd8e590da31a54a84da812c5e9a (diff) | |
download | chef-71925f0b253c0dd1b0943029d5399c3e20641ced.tar.gz |
Fix build break, use RegDeleteKeyExW
-rw-r--r-- | lib/chef/provider/registry_key.rb | 5 | ||||
-rw-r--r-- | lib/chef/win32/api/registry.rb | 7 | ||||
-rw-r--r-- | lib/chef/win32/registry.rb | 13 |
3 files changed, 18 insertions, 7 deletions
diff --git a/lib/chef/provider/registry_key.rb b/lib/chef/provider/registry_key.rb index 948fa6c63f..25fe76cdc1 100644 --- a/lib/chef/provider/registry_key.rb +++ b/lib/chef/provider/registry_key.rb @@ -25,7 +25,10 @@ require 'chef/provider' require 'etc' require 'fileutils' require 'chef/scan_access_control' -require 'chef/win32/registry' + +if Chef::Platform::windows? + require 'chef/win32/registry' +end class Chef diff --git a/lib/chef/win32/api/registry.rb b/lib/chef/win32/api/registry.rb index 9d813cef3e..8a123c37cd 100644 --- a/lib/chef/win32/api/registry.rb +++ b/lib/chef/win32/api/registry.rb @@ -30,6 +30,13 @@ class Chef ffi_lib 'advapi32' + # LONG WINAPI RegDeleteKeyEx( + # _In_ HKEY hKey, + # _In_ LPCTSTR lpSubKey, + # _In_ REGSAM samDesired, + # _Reserved_ DWORD Reserved + # ); + safe_attach_function :RegDeleteKeyExW, [ :HKEY, :LPCTSTR, :LONG, :DWORD ], :LONG safe_attach_function :RegDeleteKeyExA, [ :HKEY, :LPCTSTR, :LONG, :DWORD ], :LONG end diff --git a/lib/chef/win32/registry.rb b/lib/chef/win32/registry.rb index 9fb13f505c..64cc18f038 100644 --- a/lib/chef/win32/registry.rb +++ b/lib/chef/win32/registry.rb @@ -17,12 +17,10 @@ # limitations under the License. # require 'chef/reserved_names' +require 'win32/registry' +require 'win32/api' require 'chef/win32/api/registry' - -if RUBY_PLATFORM =~ /mswin|mingw32|windows/ - require 'win32/registry' - require 'win32/api' -end +require 'chef/mixin/wstring' class Chef class Win32 @@ -31,6 +29,9 @@ class Chef include Chef::ReservedNames::Win32::API::Registry extend Chef::ReservedNames::Win32::API::Registry + include Chef::Mixin::WideString + extend Chef::Mixin::WideString + attr_accessor :run_context attr_accessor :architecture @@ -148,7 +149,7 @@ class Chef def delete_key_ex(hive, key) hive_num = hive.hkey - (1 << 32) begin - RegDeleteKeyExA(hive_num, key, ::Win32::Registry::KEY_WRITE | registry_system_architecture, 0) + RegDeleteKeyExW(hive_num, wstring(key), ::Win32::Registry::KEY_WRITE | registry_system_architecture, 0) return true rescue ::Win32::Registry::Error => e return false |