From: daz Date: 2005-11-09T00:07:12+09:00 Subject: Re: Win32API help: PathFindOnPath() Thanks for posting that tricky snippet, Nobu. IIUC, the ENV['PATH'] prefix is /not/ required because environment PATH is /always/ searched after any additional dirs added by us. Instead of asking you for clarification, I'll assume (A) you don't expect M$ API to do anything useful ;) or (B) you pasted it from a similar example and forgot to remove it. Test: #--------------------- require 'Win32API' PathFindOnPath = Win32API.new('shlwapi', 'PathFindOnPath', 'PP', 'L') def path_fop(file, *xtra) buf = file + ("\0" * (260-file.length)) # buflen >= MAX_PATH(260) path = (xtra << nil).pack('p*') PathFindOnPath.call(buf, path).nonzero? and buf[/\A[^\0]+/] end puts path_fop('set_test.rb', 'C:\TEMP', 'C:\TEMP\clr') #-> C:\TEMP\clr\set_test.rb puts path_fop('set_test.rb', 'C:\TEMP' ) #-> nil puts path_fop('kernel32.dll', 'C:\TEMP', 'C:\TEMP\clr') #-> C:\WINDOWS\SYSTEM\kernel32.dll puts path_fop('kernel32.dll' ) #-> C:\WINDOWS\SYSTEM\kernel32.dll #--------------------- daz