Click here to Skip to main content
14,326,118 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi,


IS shellexecute LPCTSTR lpParameters has any character limit ?

In my program if "lpparameter" is large it is not calling .exe file

ShellExecute(NULL, ("open"), ("XYZ.exe"),(strtext1 ) ,NULL,SW_SHOWNORMAL);

strtext1 is a path to input file

strtext1 = C:\TestProjectExample\project12345\test12\s1rn1.sie (not working)
strtext1=C:\TestProjectExample\project1\s1rn1.sie(working)

If path is shorter then it will work. If path is lager it won't work.

It is giving Buffer too small assertion.

Please help me to solve this issue.

Thank you,
Posted
Comments
Wes Aday 18-Sep-14 14:49pm
   
Obvious thing to do would be to check and see what strtext1 is.
Sergey Alexandrovich Kryukov 18-Sep-14 15:03pm
   
Right, but the problems are: 1) MAX_PATH is defined as 260 characters, and OP's examples are all shorter, 2) according to documentation, UNC path should work, but I never managed to put it to work... (so far, I tried .NET only though.)
I put some answer, but this does not present an ultimate solution, just gives some ideas.
—SA
Sergey Alexandrovich Kryukov 18-Sep-14 14:59pm
   
Sigh... Well, this "path is too long" issue is one of those extremely idiotic Microsoft problems, known for many years, already totally archaic in nature but never properly fixed...
However... This is what makes me doubtful: both your path name examples are really short. Probably, there is something wrong in your observations.
—SA

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Please see my comment to the question.

For some background: http://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/48ea2ff7-fab6-4484-ab12-9307399cf47e/shellexecute-with-long-32k-unc-path-how-do-that-on-windows-7?forum=windowsgeneraldevelopmentissues[^],
http://blogs.msdn.com/b/bclteam/archive/2007/02/13/long-paths-in-net-part-1-of-3-kim-hamilton.aspx[^] (even though it is for .NET only, it gives some ideas).

Here is what seems to be a problem: in all your examples, file path is too short to cause a problem (MAX_PATH is defined as 260). Perhaps your observations were incorrect, by one or another weird reason.

<—SA
   
v2
Comments
peoria123 18-Sep-14 17:04pm
   
Thanks for reply..

Is changing Max_Path size to greated than 260 solved problem?

what I can use instead of ShellExecute?
Sergey Alexandrovich Kryukov 18-Sep-14 17:08pm
   
No. This is an OS constant, not changeable; UNC path is claimed to help.
I told you, this Microsoft problem is idiotic and archaic. But not properly fixed... :-(
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100