Execute file long filenames

I have a problem using execute file with long filenames, when the filename contains space(s) e.g.
"Long File Name.exe"
It executes properly, but then halts and gives a strange error reading.
(delphi3)
zonkAsked:
Who is Participating?
 
BoRiSConnect With a Mentor Commented:
Zonk

Here you go, just a simple answer, glad I could help...

Later
BoRiS
0
 
erajojCommented:
Just enclose it with quotation marks:

  "c:\program files\blab\myapp.exe"

?
0
 
erajojCommented:
I mean:
 
  sPath := '"c:\program files\blab\myapp.exe"';
  DoWhateverYouWant( sPath );

/// John
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
MatveyCommented:
It is not nessesarily a problem of the quotes or the ShellExecute or whatever at all. I remember I installed one of my projects to "Program files\...", and it ran, but gave a handful of errors in the end. You can try: running the same program from Start/Run, and see if you get the same.
0
 
MatveyCommented:
Oh, just to say that when I installed the project to some simple directory, like "C:\mydir", it ran perfectly. I never got to the root of the problem though. I think it was some db app...
0
 
intheCommented:
hello Zonk,
it is possible you could use the win32 api GetShortPathName to execute files in a long path.it returns the 8:3 dos format name for your long file name/path. like in dos you get progra~1 for program files directory
Barry
0
 
BoRiSCommented:
Zonk

I created a sample project with a lon file name and then created a second that executed the the first I used the shellexecute API and all's well that end's well in both D3 and D4

ShellExecute(Handle, 'open', 'Long File Name.Exe', '', 'C:\program files\testing\longfilename\', SW_SHOWNORMAL);

Does your execute code look like so, maybe post your execute code for us to take a look at.

Later
BoRiS
0
 
zonkAuthor Commented:
No, my instruction looks like this:
ExecuteFile ('name of the file.exe','','',1);

I will try shell execute, maybe that works.
0
 
viktornetCommented:
Hello y'all...

ShellExecute() will do the job for sure :)

Cheers,
Viktor
0
 
BoRiSCommented:
Zonk

If you use the Shell Execute command make sure you add ShellAPI to your uses clause

uses
Windows, Forms, ..., ShellAPI;
0
 
viktornetCommented:
yup, that's what I'm talk'n 'bout ;-)

Cheers,
Viktor
0
 
viktornetCommented:
John, how's everything going around ya??

Vik
0
 
erajojCommented:
Still breathing...
0
 
viktornetCommented:
:)
0
 
zonkAuthor Commented:
So who gets the points now?
0
 
BoRiSCommented:
Zonk

Well did the ShellExecute I gave you work, Then the points are mine, but if one of the other examples worked then the points belong to them...

Later
BoRiS
0
 
zonkAuthor Commented:
Yes the shell execute works nicely.
And I gues Boris was the first to post, so post an answer and I will credit the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.