Skip to content

Instantly share code, notes, and snippets.

@nrk
Created August 30, 2008 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nrk/8100 to your computer and use it in GitHub Desktop.
Save nrk/8100 to your computer and use it in GitHub Desktop.
Win32API.so ported to IronRuby: first (barely) working bits
IronRuby 1.0.0.0 on .NET 2.0.50727.1433
Copyright (c) Microsoft Corporation. All rights reserved.
Note that local variables do not work today in the console.
As a workaround, use globals instead (eg $x = 42 instead of x = 42).
>>> require 'mscorlib'
=> true
>>> require 'Win32API'
=> true
>>>
=> nil
>>> StringBuilder = System::Text::StringBuilder
=> System::Text::StringBuilder
>>>
=> nil
>>> $name = StringBuilder.new
=> #<System::Text::StringBuilder:0x000005c>
>>> $size = StringBuilder.new
=> #<System::Text::StringBuilder:0x000005e>
>>>
=> nil
>>> $api = Win32API.new('kernel32', 'GetComputerName', ['P','P'], 'I')
=> #<Win32API:0x0000060>
>>> $ret = $api.call($name, $size)
=> 1
>>>
=> nil
>>> p $ret, $name.ToString()
1
"VM-WINXP-001"
=> nil
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment