From: Paul Leonard Date: 2005-05-20T11:58:17+09:00 Subject: Re: Win32API question - pathstriptoroot 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�der wrote: >�On 19/05/05, Austin Ziegler �wrote: > >>�On 5/19/05, Berger, Daniel �wrote: >> >>>�require "Win32API" >>> >>>�PathStripToRoot = >>>�Win32API.new("shlwapi","PathStripToRoot","P","L") path = >>>�'C:\foo\bar' >>> >>>�rv = PathStripToRoot.call(path) >>>�puts "RV: #{rv}" >>>�puts "Path is [#{path}]" >>> >>>�With that I end up with: >>> >>>�RV: 1 >>>�Path is [C:\ oo bar] >>> >>>�Do I need to encode and/or decode 'path' somehow first? >>> >>�All PathStripToRoot is doing is putting \000 after C:\. Do an >>�#inspect. >> >>�I'm not sure what the right answer is in this case. >> >�I can't test it because I'm on linux, but wouldn't >�rv = PathStripToRoot.call(path) >�path = path.split(0.chr, 2)[0] >�puts "RV: #{rv}" >�puts "Path is [#{path}]" > >�work? > >�best regards, > >�Brian