The equivalent call in perl can be written like this:DWORD GetShortPathName( LPCTSTR lpszLongPath, // null-terminated path string LPTSTR lpszShortPath, // short form buffer DWORD cchBuffer // size of short form buffer );
On my system, this returnsuse Win32::API; #import the function my $GetShortPathName = new Win32::API("kernel32","GetShortPathName",[ +P,P,N ],N); if (not defined $GetShortPathName) { die "could not import GetShortPathName"; } #the name we want to convert $longname = "C:\\Program Files\\Microsoft Office\\Office\\OLREAD9.TXT" +; #create a string big enough to hold the shortname $shortname = " " x 80; #retval will be length of the DOSified short name $retval = $GetShortPathName->Call($longname,$shortname,80); #trim the trailing blanks #recall that $shortname = " " x 80 #and retval is the length of the name returned by GetShortPathName $shortname = substr($shortname,0,$retval); print "longname = \n\"$longname\", \nshortname = \n\"$shortname\"";
C:\temp>perl shortname.pl longname = "C:\Program Files\Microsoft Office\Office\OLREAD9.TXT", shortname = "C:\PROGRA~1\MICROS~3\Office\OLREAD9.TXT" C:\temp>
In reply to Re: Re: execute a file
by RhetTbull
in thread execute a file
by Larinda Stone
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |