The api call is just taking the char buffer you're sending it, dropping a null after the path to terminate it just like a normal Windows application would expect. I would have thought that the Win32API module would take care of this sort of thing for you, but that doesn't seem to be the case.
You could do the split, or the amusing but probably terrible:
puts "Path is [#{path.unpack(A4*).join}]"
Paul Leonard
On Fri, 20 May 2005 06:52:37 +0900, Brian Schröäer wrote:
>n 19/05/05, Austin Ziegler <halostatue / gmail.com>rote:
>
>>n 5/19/05, Berger, Daniel <Daniel.Berger / qwest.com>rote:
>>
>>>equire "Win32API"
>>>
>>>athStripToRoot =
>>>in32API.new("shlwapi","PathStripToRoot","P","L") path =
>>>C:\foo\bar'
>>>
>>>v = PathStripToRoot.call(path)
>>>uts "RV: #{rv}"
>>>uts "Path is [#{path}]"
>>>
>>>ith that I end up with:
>>>
>>>V: 1
>>>ath is [C:\ oo bar]
>>>
>>>o I need to encode and/or decode 'path' somehow first?
>>>
>>ll PathStripToRoot is doing is putting \000 after C:\. Do an
>>inspect.
>>
>>'m not sure what the right answer is in this case.
>>
> can't test it because I'm on linux, but wouldn't
>v = PathStripToRoot.call(path)
>ath = path.split(0.chr, 2)[0]
>uts "RV: #{rv}"
>uts "Path is [#{path}]"
>
>ork?
>
>est regards,
>
>rian