зеркало из https://github.com/github/ruby.git
* 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:
Родитель
95189045d0
Коммит
2a89c088a2
|
@ -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>
|
||||
|
||||
* ext/dl/lib/dl/func.rb (DL::Function.name): delegate to @cfunc.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
=end
|
||||
|
||||
require "dl/import"
|
||||
require 'win32/registry'
|
||||
|
||||
module Win32
|
||||
|
@ -33,7 +34,11 @@ module Win32
|
|||
[ search, nameserver ]
|
||||
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
|
||||
getv.call(info)
|
||||
if info.unpack('V5')[4] == 2 # VER_PLATFORM_WIN32_NT
|
||||
|
@ -255,8 +260,12 @@ else
|
|||
end
|
||||
|
||||
module WsControl
|
||||
WsControl = Win32API.new('wsock32.dll', 'WsControl', 'LLPPPP', 'L')
|
||||
WSAGetLastError = Win32API.new('wsock32.dll', 'WSAGetLastError', 'V', 'L')
|
||||
module WSock32
|
||||
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
|
||||
IPPROTO_TCP = 6
|
||||
|
|
Загрузка…
Ссылка в новой задаче