From: Brian Takita Date: 2005-04-26T04:59:33+09:00 Subject: Re: Get the Current Domain Name in Windows Thank you for your response Ryan. This did get me moving forward. I looked at some VB samples in using the WKSTA_USER_INFO_1 structure and it looks like four of the parameters are long data types. http://vbnet.mvps.org/index.html?code/network/netwkstagetinfouserinfo.htm It seems like they are pointers to the strings. The example uses a RtlMoveMemory and then extracts the string from the pointer. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/memory/base/movememory.asp I tried this but still can't get this to work. I can use Dan's solution to my problem, but would be nice to know how to work with the Windows API. Here is my code: require 'dl/win32' getUserNameInfo = Win32API.new('Netapi32.dll', 'NetWkstaUserGetInfo', %w{p l P}, 'i') bufferFree = Win32API.new('Netapi32.dll', 'NetApiBufferFree', 'p', 'l') memoryCopy = Win32API.new('kernel32.dll', 'RtlMoveMemory', 'ppl', '') reserved = 0 buf = ' ' * 4 * 4 begin returnCode = getUserNameInfo.call(reserved, 1, buf) username_loc, logon_domain_loc, oth_domains_loc, logon_server_loc = buf.unpack('llll') puts 'username: ' + username_loc.to_s puts 'logon_domain: ' + logon_domain_loc.to_s puts 'oth_domains: ' + oth_domains_loc.to_s puts 'logon_server: ' + logon_server_loc.to_s puts returnCode username = 0 memoryCopy.call(username, username_loc, 255) result = username.unpack('a') puts result.to_s ensure bufferFree.call(buf) bufferFree.call(username) end I am getting the following output: username: 287528 logon_domain: 538976288 oth_domains: 538976288 logon_server: 538976288 0 c:/program files/ruby/lib/ruby/1.8/dl/win32.rb:20:in `call': 2 arguments are needed (ArgumentError) from c:/program files/ruby/lib/ruby/1.8/dl/win32.rb:20:in `call' from test.rb:20 It's strange that I get this error, because the RtlMoveMemory function calls for three argements.