Solved

CD-ROM to know where flash file is

Posted on 2002-03-24
9
190 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
  • 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
 

Author Comment

by:routerboy309
ID: 6902895
Thanks to all -

RB
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Multiple image collision 13 69
How to define IfThen functions in one common unit? 4 45
Adoquery sql  left join does not work 25 81
RESTRequest Parameter 4 15
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now