A
Aston
Hello,=0A=0AI have very little experience with dl. But I want to use it to =
=0Acall SetEnvironmentVariable() from Win32. I could use FFI but cannot, si=
nce this =0Ascript will be supplied to a customer where it is difficult to =
install.=0A=0ASetEnvironmentVariable on =0AMSDN http://msdn.microsoft.com/e=
n-us/library/ms686206(v=3DVS.85).aspx=0A=0Areading sparse, old, and cryptic=
documentation I came up with this snippet, =0Awhich of course does not wor=
k=0A=0Arequire 'dl/import'=0A=0Amodule Win32=0Aextend DL::Importer=0Aextern=
"int SetEnvironmentVariableA( char* lpName, char* lpValue)"=0Aextern "int =
GetEnvironmentVariableA( char* lpName, char* lpValue, int size)"=0Aend=0A=
=0Abuff =3D Array.new( 256, 0).pack("c*")=0AWin32.GetEnvironmentVariableA( =
"ENV_VAR", buff, 255)=0Aputs buff.unpack("a*")=0A=0Athis is the error i get=
=0AD:/ruby/usr/lib/ruby/1.9.1/dl/import.rb:194:in `import_function': undefi=
ned =0Amethod `sym' for nil:NilClass (NoMethodError)=0A from D:/ruby=
/usr/lib/ruby/1.9.1/dl/import.rb:118:in `extern'=0A from test.rb:5:i=
n `<module:Win32>'=0A from test.rb:3:in `<main>'=0A=0Amachine is Win=
XP=0Aruby 1.9.1 (2008-10-28 revision 19983) [i386-mswin32_80]=0A=0Acan anyb=
ody suggest a better signature ?=0A=0AAston=0A=0A=0A
=0Acall SetEnvironmentVariable() from Win32. I could use FFI but cannot, si=
nce this =0Ascript will be supplied to a customer where it is difficult to =
install.=0A=0ASetEnvironmentVariable on =0AMSDN http://msdn.microsoft.com/e=
n-us/library/ms686206(v=3DVS.85).aspx=0A=0Areading sparse, old, and cryptic=
documentation I came up with this snippet, =0Awhich of course does not wor=
k=0A=0Arequire 'dl/import'=0A=0Amodule Win32=0Aextend DL::Importer=0Aextern=
"int SetEnvironmentVariableA( char* lpName, char* lpValue)"=0Aextern "int =
GetEnvironmentVariableA( char* lpName, char* lpValue, int size)"=0Aend=0A=
=0Abuff =3D Array.new( 256, 0).pack("c*")=0AWin32.GetEnvironmentVariableA( =
"ENV_VAR", buff, 255)=0Aputs buff.unpack("a*")=0A=0Athis is the error i get=
=0AD:/ruby/usr/lib/ruby/1.9.1/dl/import.rb:194:in `import_function': undefi=
ned =0Amethod `sym' for nil:NilClass (NoMethodError)=0A from D:/ruby=
/usr/lib/ruby/1.9.1/dl/import.rb:118:in `extern'=0A from test.rb:5:i=
n `<module:Win32>'=0A from test.rb:3:in `<main>'=0A=0Amachine is Win=
XP=0Aruby 1.9.1 (2008-10-28 revision 19983) [i386-mswin32_80]=0A=0Acan anyb=
ody suggest a better signature ?=0A=0AAston=0A=0A=0A