[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

CD-ROM to know where flash file is

Hello -

I have a Delphi 6 app where I have added Flash's OCX to it. There is a property that askes for a Moive URL - pointing to the file. If I pre-qualify the path, like e:\demo\intro.sfw, the file loads just fine when my app runs. But since the Delphi app will end up on on a CD-ROM, there is no way to hard code the path in, since I won't know the drive letter of the cd-rom for each system.

What's the best method to handle this? Here's the code I have now, but shellexecute opens it in a separte window instead of within the app:

procedure TForm1.Button2Click(Sender: TObject);
begin
temppath := 'E:\demo\intro.swf';
if(ShellExecute(HInstance, 'Open', temppath , '', '', SW_SHOWNORMAL)= ERROR_FILE_NOT_FOUND)
then
      begin
      MessageDlg('Unable to file: SWF.' + chr(13) +
      'Please launch it from the Disk Location.', mtWarning,[mbOk],0);
     end;
end;




Thanks

RB
0
routerboy309
Asked:
routerboy309
  • 4
  • 2
  • 2
  • +1
1 Solution
 
Mohammed NasmanSoftware DeveloperCommented:
Hello

  Don't hard code the drive name, you can use  ExtractFileDir(Application.ExeName) to return the current path then add ur file path to it like:

ShowMessage(ExtractFileDir(Application.ExeName) + '\demo\intro.swf')

or you can check for the cd rom from the drives in ur pc like

procedure TForm1.Button1Click(Sender: TObject);
var
  x,
  DrvType   : Integer;
  DrvLetter,
  DrvString : String;
begin
  for x := Ord('A') to Ord('Z') do
  begin
    DrvLetter := Chr(x)+':\';
    DrvType := GetDriveType(pChar(DrvLetter));
    case DrvType of
      0,1               : DrvString := '';
      DRIVE_REMOVABLE      : DrvString := 'Removable';
      DRIVE_FIXED     : DrvString := 'Fixed';
      DRIVE_REMOTE     : DrvString := 'Network';
      DRIVE_CDROM     : DrvString := 'CD-ROM';
      DRIVE_RAMDISK     : DrvString := 'RAM disk';
    end;
    if DrvString <> '' then
      Listbox1.Items.Add(DrvLetter + ' = ' + DrvString);
  end;
end;

0
 
routerboy309Author Commented:
Using ExtractFileDir(Application.ExeName) + '\intro.swf'; did the trick!

Thanks -

RB

0
 
AloneCommented:
Use relational paths instead of absolute - you may not need to learn about the CD-ROM (or any other drive) letter
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
routerboy309Author Commented:
Thanks to all -

RB
0
 
Mohammed NasmanSoftware DeveloperCommented:
Hello routerboy309

  How did you accept Alone comment as answer?, I gave you the answer and it's worked with you?
0
 
routerboy309Author Commented:
Thats a good question. I must of clicked wrong. Let me send an email to EE and get that corrected.

Alone - can you understand my error?

I'll keep you posted.

RB
0
 
AloneCommented:
OK
0
 
MoondancerCommented:
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?qid=20283999  Points for mnasman awaiting comments to correct this.

Moondancer - EE Moderator
0
 
routerboy309Author Commented:
Thanks Moondancer.

RB
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now