Mega Search
23.2 Million


Sign Up

Make a donation  
mciSendCommand lpstrElementName length...  
News Group: embarcadero.public.delphi.nativeapi

Hi,

I have been using "mciSendCommand" for years to record and play wav 
files.

I now have a user that stores the files in really long paths. The path 
that exposed the problem was > 90 characters.

When the path is so long, mciSendCommand gives an error on opening to 
play the wav:

MCIERR_FILENAME_REQUIRED

The filename is invalid. Make sure the filename is no longer than eight 
characters, followed by a period and an extension.

The filename is not longer than eight characters and it does have a 
period and an extension.

I created a test path structure, no illegal or odd characters and 
reproduced the problem. Shorten the path and the file plays fine.

I have not been able to locate any reference to a limit to the 
lpstrElementName length.

Ideas?

Thanks for your time,

Mark

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 23-Jan-2015, at 7:52 AM EST
From: Mark Marks
 
Re: mciSendCommand lpstrElementName length...  
News Group: embarcadero.public.delphi.nativeapi
Mark Marks wrote:

> Not much code. Just create a long path like: 
> 
> C:\Users\Admin\Desktop\Test project\some project folder\Program\HMI 
> Programs\just to make a really long folder path\v 80

For me on windiows 8.1 the following combination worked (I have tested
it with MCI_STATUS_LENGTH):


{code}
s1:='C:\Users\Public\Documents\Test project\some project
folder\Program\HMI Programs\just to make a really long folder path\v
80\gtr-nylon22.wav';

 openParams.lpstrElementName:=PChar(ExtractShortPathName(s1));
{code}

when I tried to use: without ExtractShortPathName I also got the error
from your original post.

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 23-Jan-2015, at 2:27 PM EST
From: Lajos Juhasz
 
Re: mciSendCommand lpstrElementName length...  
News Group: embarcadero.public.delphi.nativeapi
Hello,

Thanks for the response. 

The path does have spaces.
The first thing I tried was to wrap the string in quotes, no joy.

I used ExtractShortPathName to shorten the path and it works.

Not much code. Just create a long path like: 

C:\Users\Admin\Desktop\Test project\some project folder\Program\HMI 
Programs\just to make a really long folder path\v 80


var
 flags:integer;
 error:longint;
begin
 flags:=MCI_OPEN_ELEMENT or MCI_OPEN_TYPE;
 openParams.lpstrDeviceType:='WaveAudio';
// openParams.lpstrElementName:=PChar(s1);
 openParams.lpstrElementName:=PChar(ExtractShortPathName(s1));
 openParams.lpstrAlias:='';
 error:=mciSendCommand(0,MCI_OPEN,flags,longword(@openParams));
 if (error <> 0) then
  ShowError(error);
 wDeviceID:=openParams.wDeviceID;
end;

Ciao,

Mark

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 23-Jan-2015, at 8:57 AM EST
From: Mark Marks
 
Re: mciSendCommand lpstrElementName length...  
News Group: embarcadero.public.delphi.nativeapi
Mark Marks wrote:

> mciSendCommand

Please send a test case so we can test the problem. Google returned the
following link:

https://social.msdn.microsoft.com/Forums/en-US/7f171aac-6f01-4c9f-a291-061f9058a27c/mcisendstring-long-pathfile-names?forum=Vsexpressvcs

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 23-Jan-2015, at 8:39 AM EST
From: Lajos Juhasz