mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/dl/win32/lib/win32/{registry,resolv}.rb: use dl/import instead
of Win32API. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
95189045d0
commit
2a89c088a2
3 changed files with 39 additions and 18 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Mar 3 15:54:11 2009 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/dl/win32/lib/win32/{registry,resolv}.rb: use dl/import instead
|
||||||
|
of Win32API.
|
||||||
|
|
||||||
Tue Mar 3 15:53:20 2009 NAKAMURA Usaku <usa@ruby-lang.org>
|
Tue Mar 3 15:53:20 2009 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* ext/dl/lib/dl/func.rb (DL::Function.name): delegate to @cfunc.
|
* ext/dl/lib/dl/func.rb (DL::Function.name): delegate to @cfunc.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
=begin
|
=begin
|
||||||
= Win32 Registry I/F
|
= Win32 Registry I/F
|
||||||
win32/registry is registry accessor library for Win32 platform.
|
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
|
== example
|
||||||
Win32::Registry::HKEY_CURRENT_USER.open('SOFTWARE\foo') do |reg|
|
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
|
=end
|
||||||
|
|
||||||
require 'Win32API'
|
require 'dl/import'
|
||||||
|
|
||||||
module Win32
|
module Win32
|
||||||
class Registry
|
class Registry
|
||||||
|
@ -334,7 +334,11 @@ module Win32
|
||||||
# Error
|
# Error
|
||||||
#
|
#
|
||||||
class Error < ::StandardError
|
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)
|
def initialize(code)
|
||||||
@code = code
|
@code = code
|
||||||
msg = "\0".force_encoding(Encoding::ASCII_8BIT) * 1024
|
msg = "\0".force_encoding(Encoding::ASCII_8BIT) * 1024
|
||||||
|
@ -376,20 +380,23 @@ module Win32
|
||||||
# Win32 APIs
|
# Win32 APIs
|
||||||
#
|
#
|
||||||
module API
|
module API
|
||||||
|
extend DL::Importer
|
||||||
|
dlload "advapi32.dll"
|
||||||
[
|
[
|
||||||
%w/RegOpenKeyExA LPLLP L/,
|
"long RegOpenKeyExA(void *, void *, long, long, void *)",
|
||||||
%w/RegCreateKeyExA LPLLLLPPP L/,
|
"long RegCreateKeyExA(void *, void *, long, long, long, long, void *, void *)",
|
||||||
%w/RegEnumValueA LLPPPPPP L/,
|
"long RegEnumValueA(void *, long, void *, void *, void *, void *, void *, void *)",
|
||||||
%w/RegEnumKeyExA LLPPLLLP L/,
|
"long RegEnumKeyExA(void *, long, void *, void *, void *, void *, void *, void *)",
|
||||||
%w/RegQueryValueExA LPLPPP L/,
|
"long RegQueryValueExA(void *, void *, void *, void *, void *, void *)",
|
||||||
%w/RegSetValueExA LPLLPL L/,
|
"long RegSetValueExA(void *, void *, long, long, void *, long)",
|
||||||
%w/RegDeleteValue LP L/,
|
"long RegDeleteValue(void *, void *)",
|
||||||
%w/RegDeleteKey LP L/,
|
"long RegDeleteKey(void *, void *)",
|
||||||
%w/RegFlushKey L L/,
|
"long RegFlushKey(void *)",
|
||||||
%w/RegCloseKey L L/,
|
"long RegCloseKey(void *)",
|
||||||
%w/RegQueryInfoKey LPPPPPPPPPPP L/,
|
"long RegQueryInfoKey(void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *, void *)",
|
||||||
].each do |fn|
|
].each do |fn|
|
||||||
const_set fn[0].intern, Win32API.new('advapi32.dll', *fn)
|
cfunc = extern fn, :stdcall
|
||||||
|
const_set cfunc.name.intern, cfunc
|
||||||
end
|
end
|
||||||
|
|
||||||
module_function
|
module_function
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
|
require "dl/import"
|
||||||
require 'win32/registry'
|
require 'win32/registry'
|
||||||
|
|
||||||
module Win32
|
module Win32
|
||||||
|
@ -33,7 +34,11 @@ module Win32
|
||||||
[ search, nameserver ]
|
[ search, nameserver ]
|
||||||
end
|
end
|
||||||
|
|
||||||
getv = Win32API.new('kernel32.dll', 'GetVersionExA', 'P', 'L')
|
module Kernel32
|
||||||
|
extend DL::Importer
|
||||||
|
dlload "kernel32"
|
||||||
|
end
|
||||||
|
getv = Kernel32.extern "int GetVersionExA(void *)", :stdcall
|
||||||
info = [ 148, 0, 0, 0, 0 ].pack('V5') + "\0" * 128
|
info = [ 148, 0, 0, 0, 0 ].pack('V5') + "\0" * 128
|
||||||
getv.call(info)
|
getv.call(info)
|
||||||
if info.unpack('V5')[4] == 2 # VER_PLATFORM_WIN32_NT
|
if info.unpack('V5')[4] == 2 # VER_PLATFORM_WIN32_NT
|
||||||
|
@ -255,8 +260,12 @@ else
|
||||||
end
|
end
|
||||||
|
|
||||||
module WsControl
|
module WsControl
|
||||||
WsControl = Win32API.new('wsock32.dll', 'WsControl', 'LLPPPP', 'L')
|
module WSock32
|
||||||
WSAGetLastError = Win32API.new('wsock32.dll', 'WSAGetLastError', 'V', 'L')
|
extend DL::Importer
|
||||||
|
dlload "wsock32.dll"
|
||||||
|
end
|
||||||
|
WsControl = WSock32.extern "int WsControl(int, int, void *, void *, void *, void *", :stdcall
|
||||||
|
WSAGetLastError = WSock32.extern "int WSAGetLastError(void)", :stdcall
|
||||||
|
|
||||||
MAX_TDI_ENTITIES = 512
|
MAX_TDI_ENTITIES = 512
|
||||||
IPPROTO_TCP = 6
|
IPPROTO_TCP = 6
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue