Solved

Execute file long filenames

Posted on 1998-11-17
17
177 Views
Last Modified: 2010-04-04
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)
0
Comment
Question by:zonk
  • 4
  • 4
  • 3
  • +3
17 Comments
 
LVL 4

Expert Comment

by:erajoj
ID: 1347144
Just enclose it with quotation marks:

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

?
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1347145
I mean:
 
  sPath := '"c:\program files\blab\myapp.exe"';
  DoWhateverYouWant( sPath );

/// John
0
 
LVL 3

Expert Comment

by:Matvey
ID: 1347146
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:Matvey
ID: 1347147
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
 
LVL 17

Expert Comment

by:inthe
ID: 1347148
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
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347149
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
 

Author Comment

by:zonk
ID: 1347150
No, my instruction looks like this:
ExecuteFile ('name of the file.exe','','',1);

I will try shell execute, maybe that works.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1347151
Hello y'all...

ShellExecute() will do the job for sure :)

Cheers,
Viktor
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347152
Zonk

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

uses
Windows, Forms, ..., ShellAPI;
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1347153
yup, that's what I'm talk'n 'bout ;-)

Cheers,
Viktor
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1347154
John, how's everything going around ya??

Vik
0
 
LVL 4

Expert Comment

by:erajoj
ID: 1347155
Still breathing...
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1347156
:)
0
 

Author Comment

by:zonk
ID: 1347157
So who gets the points now?
0
 
LVL 4

Expert Comment

by:BoRiS
ID: 1347158
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
 

Author Comment

by:zonk
ID: 1347159
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
 
LVL 4

Accepted Solution

by:
BoRiS earned 100 total points
ID: 1347160
Zonk

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

Later
BoRiS
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question