Open Jeff-Lawson opened 14 years ago
I don't think I'm actually using the admin? method anywhere. Can you verify if you're still getting an error on 0.3.0.pre? If so, I may just remove it entirely.
http://groups.google.com/group/discuss_pik/browse_thread/thread/ea94cb38d26ca92b
On Windows 2000, pik commands produce:
pik/windows_env.rb:83:in
initialize': GetProcAddress: IsUserAnAdmin or IsUserAnAdminA (RuntimeError) from pik/windows_env.rb:83:in
new' from pik/windows_env.rb:83The Windows 2000 shell32.dll implements IsUserAnAdmin but does not make it visible by that name. Instead, MAKEINTRESOURCE(680) can be used (see http://www.ureader.com/message/1095758.aspx). As far as I can tell, there doesn't appear to be a way to make MAKEINTRESOURCE work with the Ruby Win32API.new method.
May I suggest that a command line option be provided, e.g. -admin
This could be implemented with two changes...
Ignoring the first exception:
IsUserAnAdmin = Win32API.new('shell32', 'IsUserAnAdmin', 'v', 'i') rescue nil
and handling the second exception:
def admin? true if IsUserAnAdmin.call.nonzero? rescue ARGV.include?('-admin') end
This would make no difference for developers using Windows XP and later but would enable developers using Windows 2000 to get past the IsUserAnAdmin problem.