From: daz Date: 2004-01-17T05:35:04+09:00 Subject: Re: NULL pointer given, Win32API Hi, "Berger, Daniel" wrote: > [snipped beyond recognition] > require "Win32API" > FormatMessage = Win32API.new("kernel32","FormatMessage","LPLLPLP","L") > GetLastError = Win32API.new("kernel32","GetLastError",[],"L") > > def get_error(error_code=GetLastError.call) > msg = " " * 255 > FormatMessage.call( > FORMAT_MESSAGE_FROM_SYSTEM + > FORMAT_MESSAGE_ARGUMENT_ARRAY, > '', > error_code, > 0, > msg, > 255, > '' > ) > msg.gsub!(/\000/, '') > msg.strip! > msg > end > GetLastError() using Win32API isn't very effective IMHE. By the time you get around to calling it, it's been zapped by other API calls that have been made on your behalf. While you're testing, though, you *really* need to see these errors. If you've self-built ruby, you might try this version: http://www.d10.karoo.net/ruby/Win32API.c (temporary) (Hope you can scrape it off your browser :-) Added class methods: Win32API.lasterr Win32API.message(code=lasterr) (produces 'FormatMessage' from system) (e.g.) puts Win32API.message unless Win32API.lasterr == 0 If it hasn't become useful within 15 minutes, pretend you didn't see this post :) Good luck, daz