summaryrefslogtreecommitdiff
path: root/ext/dl/win32/lib/win32/registry.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/dl/win32/lib/win32/registry.rb')
-rw-r--r--ext/dl/win32/lib/win32/registry.rb37
1 files changed, 22 insertions, 15 deletions
diff --git a/ext/dl/win32/lib/win32/registry.rb b/ext/dl/win32/lib/win32/registry.rb
index ccdd721818..175b34cede 100644
--- a/ext/dl/win32/lib/win32/registry.rb
+++ b/ext/dl/win32/lib/win32/registry.rb
@@ -1,7 +1,7 @@
=begin
= Win32 Registry I/F
win32/registry is registry accessor library for Win32 platform.
-It uses Win32API to call Win32 Registry APIs.
+It uses dl/import to call Win32 Registry APIs.
== example
Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\foo') do |reg|
@@ -261,7 +261,7 @@ For detail, see ((<MSDN Library|URL:http://msdn.microsoft.com/library/en-us/sysi
=end
-require 'Win32API'
+require 'dl/import'
module Win32
class Registry
@@ -334,7 +334,11 @@ module Win32
# Error
#
class Error < ::StandardError
- FormatMessageA = Win32API.new('kernel32.dll', 'FormatMessageA', 'LPLLPLP', 'L')
+ module Kernel32
+ extend DL::Importer
+ dlload "kernel32.dll"
+ end
+ FormatMessageA = Kernel32.extern "int FormatMessageA(int, void *, int, int, void *, int, void *)", :stdcall
def initialize(code)
@code = code
msg = "\0".force_encoding(Encoding::ASCII_8BIT) * 1024
@@ -376,20 +380,23 @@ module Win32
# Win32 APIs
#
module API
+ extend DL::Importer
+ dlload "advapi32.dll"
[
- %w/RegOpenKeyExA LPLLP L/,
- %w/RegCreateKeyExA LPLLLLPPP L/,
- %w/RegEnumValueA LLPPPPPP L/,
- %w/RegEnumKeyExA LLPPLLLP L/,
- %w/RegQueryValueExA LPLPPP L/,
- %w/RegSetValueExA LPLLPL L/,
- %w/RegDeleteValue LP L/,
- %w/RegDeleteKey LP L/,
- %w/RegFlushKey L L/,
- %w/RegCloseKey L L/,
- %w/RegQueryInfoKey LPPPPPPPPPPP L/,
+ "long RegOpenKeyExA(void *, void *, long, long, void *)",
+ "long RegCreateKeyExA(void *, void *, long, long, long, long, void *, void *)",
+ "long RegEnumValueA(void *, long, void *, void *, void *, void *, void *, void *)",
+ "long RegEnumKeyExA(void *, long, void *, void *, void *, void *, void *, void *)",
+ "long RegQueryValueExA(void *, void *, void *, void *, void *, void *)",
+ "long RegSetValueExA(void *, void *, long, long, void *, long)",
+ "long RegDeleteValue(void *, void *)",
+ "long RegDeleteKey(void *, void *)",
+ "long RegFlushKey(void *)",
+ "long RegCloseKey(void *)",
+ "long RegQueryInfoKey(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *)",
].each do |fn|
- const_set fn[0].intern, Win32API.new('advapi32.dll', *fn)
+ cfunc = extern fn, :stdcall
+ const_set cfunc.name.intern, cfunc
end
module_function