Open sschuberth opened 8 years ago
@djberg96 I just realized the same error occurs when using the example code from the windows-api project's synopsis, so the issue probably is in that gem instead.
@sschuberth I will take a look at this tonight, as I'm not sure right off.
I should also mention that win32-api and windows-api are in maintenance mode only, as I pretty much exclusively use ffi now instead.
@djberg96 Thanks! While I'm aware of the increased use of ffi, so far I've not found a higher-level wrapper around it that supports the handle APIs. In particular, I'm interested in the wrapper around NtQueryObject
.
It's working for me. Did you install win32-api and windows-api?
Note that you will need the Devkit in order to install win32-api because I'm not putting out precompiled binaries any more.
Yes, I have the DevKit installed, and had installed the gems successfully:
$ gem install win32-api windows-api
Successfully installed win32-api-1.5.3-universal-mingw32
Parsing documentation for win32-api-1.5.3-universal-mingw32
Done installing documentation for win32-api after 0 seconds
Successfully installed windows-api-0.4.4
Parsing documentation for windows-api-0.4.4
Done installing documentation for windows-api after 0 seconds
2 gems installed
Still, I'm getting the error. Do I need to require
anything else than exactly what is given in the example?
@sschuberth Please show me the actual script that you are trying to run.
Here it goes:
require 'windows/path'
class Foo
include Windows::Path
if PathIsRoot.call("C:\\") > 0
#...
end
# or
if PathIsRoot("C:\\")
#...
end
end
The only thing I changed compared to the example is to comment out the ...
lines. I'm saving this as a.rb
and running it as ruby a.rb
.
@sschuberth Still hitting this? @cosmo0920 Are you able to confirm/deny?
I just did a fresh install with RubyInstaller-2.4.1-2, did gem install win32-api windows-api windows-pr
, and now the example basically seems to work. The original error I saw is gone, but now I get
a.rb:6:in `<class:Foo>': undefined method `PathIsRoot' for Foo:Class (NoMethodError)
So it seems that doing if PathIsRoot("C:\\") > 0
works, while doing if PathIsRoot("C:\\")
does not. Is that intended?
Glad it's mostly working. As for the behavior change, I'll have to defer to @cosmo0920.
Thanks for notifying it. I'll investigate this issue.
I think that this gem is only win32-api gem wrapper, so it should handle Windows API as <WindowsAPI>.call(argments)
.
I've saved the below as example.rb
require 'windows/path'
class Foo
include Windows::Path
if PathIsRoot.call("C:\\") > 0
#...
end
# or
if PathIsRoot("C:\\") > 0
#...
end
end
I got the following error:
./example.rb:11:in `<class:Foo>': undefined method `PathIsRoot' for Foo:Class (NoMethodError)
from ./example.rb:3:in `<main>'
I didn't get success to work if PathIsRoot("C:\\") > 0
. :<
Yeah, that's exactly what I wrote above already. The question is: Should the if PathIsRoot("C:\\")
syntax work?
AFAIK, if PathIsRoot("C:\\")
syntax should work within method or top-level like as irb environment, but does not work outside method.
When trying to run the synopsis example from the README I get:
As you can see form the path names, this is with Ruby 2.3.0, windows-pr 1.2.4 and windows-api 0.4.4.