From: Aston Date: 2010-07-03T00:37:56+09:00 Subject: Ruby/DL problem Hello, I have very little experience with dl. But I want to use it to call SetEnvironmentVariable() from Win32. I could use FFI but cannot, since this script will be supplied to a customer where it is difficult to install. SetEnvironmentVariable on MSDN http://msdn.microsoft.com/en-us/library/ms686206(v=VS.85).aspx reading sparse, old, and cryptic documentation I came up with this snippet, which of course does not work require 'dl/import' module Win32 extend DL::Importer extern "int SetEnvironmentVariableA( char* lpName, char* lpValue)" extern "int GetEnvironmentVariableA( char* lpName, char* lpValue, int size)" end buff = Array.new( 256, 0).pack("c*") Win32.GetEnvironmentVariableA( "ENV_VAR", buff, 255) puts buff.unpack("a*") this is the error i get D:/ruby/usr/lib/ruby/1.9.1/dl/import.rb:194:in `import_function': undefined method `sym' for nil:NilClass (NoMethodError) from D:/ruby/usr/lib/ruby/1.9.1/dl/import.rb:118:in `extern' from test.rb:5:in `' from test.rb:3:in `
' machine is WinXP ruby 1.9.1 (2008-10-28 revision 19983) [i386-mswin32_80] can anybody suggest a better signature ? Aston