類別 Win32::Registry::Error

錯誤

常數

FormatMessageW

屬性

code[R]

公開類別方法

new(code) 按一下以切換來源
呼叫超類別方法 Exception::new
# File ext/win32/lib/win32/registry.rb, line 176
def initialize(code)
  @code = code
  buff = WCHAR_NUL * 1024
  lang = 0
  begin
    len = FormatMessageW.call(0x1200, 0, code, lang, buff, 1024, 0)
    msg = buff.byteslice(0, len * WCHAR_SIZE)
    msg.delete!(WCHAR_CR)
    msg.chomp!
    msg.encode!(LOCALE)
  rescue EncodingError
    raise unless lang == 0
    lang = 0x0409         # en_US
    retry
  end
  super msg
end