Created
August 30, 2008 09:13
-
-
Save nrk/8100 to your computer and use it in GitHub Desktop.
Win32API.so ported to IronRuby: first (barely) working bits
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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