Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CD-ROM to know where flash file is

Posted on 2002-03-24
9
Medium Priority
?
199 Views
Last Modified: 2010-04-05
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
Comment
Question by:routerboy309
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6892703
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
 

Author Comment

by:routerboy309
ID: 6893109
Using ExtractFileDir(Application.ExeName) + '\intro.swf'; did the trick!

Thanks -

RB

0
 
LVL 1

Accepted Solution

by:
Alone earned 0 total points
ID: 6901876
Use relational paths instead of absolute - you may not need to learn about the CD-ROM (or any other drive) letter
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:routerboy309
ID: 6902895
Thanks to all -

RB
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6906556
Hello routerboy309

  How did you accept Alone comment as answer?, I gave you the answer and it's worked with you?
0
 

Author Comment

by:routerboy309
ID: 6906821
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
 
LVL 1

Expert Comment

by:Alone
ID: 6907692
OK
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6912702
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?qid=20283999  Points for mnasman awaiting comments to correct this.

Moondancer - EE Moderator
0
 

Author Comment

by:routerboy309
ID: 6914338
Thanks Moondancer.

RB
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

722 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