So if I edit win32api.dat to correct the definition of GetShortPathName
(as specified in my previous post), the following will open the file
with the application associated with the file extension without
displaying the cmd window:
getShortPathName=: 3 : 0
lpnlen=. #y
spn=. 'GetShortPathNameA'win32api y;(lpnlen#' ');lpnlen
spn=. (0{::spn){.2{::spn
)
longfilename=: 'd:\path with spaces\file with spaces.xls'
shortfilename=: getShortPathName longfilename
wd 'winexec "cmd /C ',shortfilename,'" sw_hide'
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Sherlock, Ric
> Sent: Thursday, 12 July 2007 10:43
> To: Programming forum
> Subject: RE: [Jprogramming] Open file with associated application
>
> Yes you're right. In fact this works too:
> wd 'winexec *cmd /C "drive:/path to/file"'
>
> The only downside is that it's not possible to give any
> options (such as
> sw_hide) to winexec.
> wd 'winexec *cmd /C start "" "drive:/path to/file" sw_hide'
>
> I think these are interpreted as parameters to the
> application starting, rather than parameters for winexec and
> so the cmd window displays briefly. A bit ugly but I can live with it.
>
> I was thinking that I could call the winapi function
> GetShortPathName for my filename before I give it to:
> wd 'winexec "cmd /C ',filename,'" sw_hide'
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm