Windows ShellExecute and CreateProcess annoyances

04/30/08

Windows ShellExecute and CreateProcess annoyances

Permalink 11:15:43 am, Categories: Programming  

Working with the Windows ShellExecute and ShellExecuteEx APIs and the CreateProcess API I have come across a major annoyance:
The directory and filename passed into these APIs can not be longer than MAX_PATH (i.e., 260) characters.
This is particularly idiotic given that Microsoft nowadays uses fairly long directory names, e.g., C:\Documents and Settings\All Users\Application Data.
Furthermore, the ShellExecute(Ex) documentation does not even state this limit.

Anyway, I did find a way around it:
Microsoft maintains both long and short names for files and directories, even on NTFS.
So, the long path C:\Documents and Settings\All Users\Application Data is equivalent to the short path C:\Docume~1\alluse~1\applic~1
This way, the path to the batch file I was trying to execute was cut down from 261 characters to 106 characters.

Creative Commons LicenseThis post is licensed under a Creative Commons License.


Trackback address for this post:

This is a captcha-picture. It is used to prevent mass-access by robots.

Please enter the characters from the image above. (case insensitive)

Comments, Trackbacks, Pingbacks:

No Comments/Trackbacks/Pingbacks for this post yet...

Leave a comment:

Your email address will not be displayed on this site.
Your URL will be displayed.

Allowed XHTML tags: <p, ul, ol, li, dl, dt, dd, address, blockquote, ins, del, span, bdo, br, em, strong, dfn, code, samp, kdb, var, cite, abbr, acronym, q, sub, sup, tt, i, b, big, small>
(Line breaks become <br />)
(Set cookies for name, email and url)
(Allow users to contact you through a message form (your email will NOT be displayed.))
This is a captcha-picture. It is used to prevent mass-access by robots.

Please enter the characters from the image above. (case insensitive)

January 2009
Mon Tue Wed Thu Fri Sat Sun
 << <   > >>
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Joe's Random Ramblings

Posts about whatever I find worthy of posting...

Search

Categories

XML Feeds

What is this?

powered by b2evolution free blog software