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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening windows files from delphi 5??

Status
Not open for further replies.

JugZ

Programmer
Nov 14, 2001
1
GB
how do u use delphi 5 to open other programs or files on your computer? are there any specific codes or procedures? please help, send to JVansia@hotmail.com Thanx!
 
To open other programs you have your WinExec function which is part of the Windows API. I think there's also a ShellExec.

I'm not sure how you open files. I'd like to know if there's a direct way to do it. What I usually do is start the program with winexec using the file as an argument.
 
The procedure 'ExecuteFile' usually in Demos/doc/Filemanex
is easier to use than the API Function.
If you want to run another application from a delphi program. you can use it to launch the application and pass it parameters so for example you can run Notepad and make it open a file.
E.g
executefile('C:\windows\notepad.exe','c:\filename.txt','',SW_SHOW);
This will run Notepad and display the file 'filename.txt',
the third parameter is the default folder you can put an empy string as here, last paramer control the sate of the window.

Steve
 
Hi Jugz

ShellExecute is the best method I think because it
allows Windows to choose which file should be opened by
which program. This is how ShellExecute works :

ShellExecute(0, 'open', ' nil, nil, SW_SHOWMAXIMIZED);

This will open my own website in a maximized browser!
Where the ' stands you should
enter your own filename. I suggest you leave the rest
unchanged. although you could play around with the SW_SHOWMAXIMIZED bit. To use ShellExecute, you must
include 'ShellAPI' in your uses list like this:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ShellAPI;

type
TMainForm = class(TForm)

blablablablabla


I hope this helps.

BobbaFet Everyone has a right to my opinion.
E-mail me at cwcon@programmer.net
Be a nice guy 'n press that little ol'
VVV---(this one) for me ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top