« If it walks like a duck...National Federation of the Blind = Spammers »

Windows ShellExecute and CreateProcess annoyances

04/30/08

  11:15:00 by Joe, 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.

No feedback yet


Form is loading...

Posts about whatever I find worthy of posting...
May 2024
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    
 << <   > >>

Search

  XML Feeds

multiblog engine