Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Launch an AVI 2

Status
Not open for further replies.

Semose

Programmer
Sep 23, 2003
4
CA
Can anyone tell me how to launch an AVI in Delphi in the computer's default player? What I want to do is make a program to put on all my video clip CDs that lists them all in a GUI and then after the user selects which they want to play, it plays in their default media player (windows media player, divx, etc.).

Thanks in advance!
 
I think you just need to execute the file. Either use shellexecute, or include the file fmxutils.pas (mine is at C:\Program Files\Borland\Delphi6\Demos\Doc\Filmanex) and call executefile().

Brian
"There are 2 kinds of people in the world, those that divide people into two groups and those that don't. I belong to the second group." - tag line I stole
 
We have a program for users to view scanned documents. It goes through a specific directory looking to see if any documents exist and if they do, displays a list of them. When the user double-clicks a document name, it opens up the file in the default viewer. Here's the code to open the document:

Code:
procedure TForm_Main.SGrid_DocsDblClick(Sender: TObject);
var
  RetVal: THandle;
  strTemp: string;
begin
  strTemp:= StringReplace(strDocPath + '/' + sListPath[SGrid_Docs.Row],
    '/', '\', [rfReplaceAll]);

  StatusBar1.SimpleText:= 'Opening ' + sListPath[SGrid_Docs.Row];
  Screen.Cursor:= crHourGlass;

  if FileExists(strTemp)
  then
    begin
      RetVal:=  ShellExecute(Handle, 'open',
        PChar(strTemp), nil, nil,
        SW_SHOWNORMAL);
    end
  else
    begin
      showmessage(strDocPath + '/' + sListPath[SGrid_Docs.Row] +
        ' not found [procedure ListBoxDblClick]');
      Screen.Cursor:= crDefault;
      Exit;
    end;

  if RetVal > 32    // no error
  then StatusBar1.SimpleText:= 'Double click to open document'
  else
    begin
      Windows.Beep(200, 500);
      StatusBar1.SimpleText:= IntToStr(RetVal) + ' ' + strDocPath + '/' +
        sListPath[SGrid_Docs.Row];
      if RetVal = SE_ERR_NOASSOC
      then StatusBar1.SimpleText:=
        'No file type associated with ' +
        ExtractFileName(strDocPath + '/' + sListPath[SGrid_Docs.Row]);
    end;

  Screen.Cursor:= crDefault;
end;

HTH



Leslie
 
Thanks much! Both of those suggestions will help me a lot! I'll try them out in class in a few hours.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top