Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[Win32API] Need help with PathCreateFromUrl

59 views
Skip to first unread message

Daniel Berger

unread,
May 28, 2005, 3:40:10 PM5/28/05
to
Hi all,

Ruby 1.8.2
Windows XP

The following script dies a horrible death. I've tried different ways
of padding the url and buffer, but nothing has worked. Do I have the
method signature wrong?

# test.rb
require "Win32API"

MAX_PATH = 255
PathCreateFromUrl =
Win32API.new("shlwapi", "PathCreateFromUrl", "PPLL", "L")

buf = 0.chr * MAX_PATH
url = "file:///C:/foo" + 0.chr # I tried other ways of padding this
len = buf.length

p PathCreateFromUrl.call(url, buf, len, 0) # kaboom!
p buf

Regards,

Dan

va...@acd.net

unread,
May 28, 2005, 5:10:16 PM5/28/05
to
This works for me:

require "Win32API"

MAX_PATH = 255
PathCreateFromUrl =

Win32API.new("shlwapi", "PathCreateFromUrl", 'PPPL', "i")

buf = 0.chr * MAX_PATH

url = "file://localhost/c:/winzip.log"

lpLen = " " * 4 # lpLen is a pointer to a LONG

p PathCreateFromUrl.call(url, buf, lpLen, 0)
p buf

#config: Windows XP Pro SP2, ruby 1.8.2, cygwin

Daniel Berger

unread,
May 28, 2005, 11:47:38 PM5/28/05
to

That worked great, thanks.

Dan

nobu....@softhome.net

unread,
May 29, 2005, 12:34:43 AM5/29/05
to
Hi,

At Sun, 29 May 2005 06:15:20 +0900,
va...@acd.net wrote in [ruby-talk:143901]:


> lpLen = " " * 4 # lpLen is a pointer to a LONG

lpLen = [buf.size].pack("l")

> p PathCreateFromUrl.call(url, buf, lpLen, 0)

--
Nobu Nakada


0 new messages