win32utils-devel@rubyforge.org
2004-Sep-21 00:42 UTC
[Win32utils-devel] win32-shortcut problems
Hi all, I''ve started porting the Win32::Shortcut Perl module over to Ruby. I''ve done some initial work and committed it to CVS (look under win32utils - I goofed and made a toplevel dir as well - it''s empty). Anyway, everything compiles fine, but when I do "s = Shortcut.new" I get a weird error: test.rb:11:in `initialize'': undefined method `new'' for false:FalseClass (NoMethodError) The initialize method is copied from the _Instance(...) part of the Shortcut.xs file. Any ideas as to what''s wrong? Regards, Dan
win32utils-devel@rubyforge.org
2004-Sep-21 09:33 UTC
[Win32utils-devel] win32-shortcut problems
Hi Dan,> Hi all, > > I''ve started porting the Win32::Shortcut Perl module over to Ruby. I''ve > done some initial work and committed it to CVS (look under win32utils - I > goofed and made a toplevel dir as well - it''s empty). > > Anyway, everything compiles fine, but when I do "s = Shortcut.new" I get a > weird error: > > test.rb:11:in `initialize'': undefined method `new'' for false:FalseClass > (NoMethodError) > > The initialize method is copied from the _Instance(...) part of the > Shortcut.xs file. > > Any ideas as to what''s wrong? >You have missed two things. 1) call CoInitialize before call CoCreateInstance like this: hres = CoInitialize(NULL); if(SUCCEEDED(hres)){ hres = CoCreateInstance( CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) &ptr->ilink ); } 2) define error class cShortcutError after rb_define_class_under like this: cShortcutError = rb_define_class_under(mWin32,"ShortcutError",rb_eStandardError); Cheers, Park Heesob