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.
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 :
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:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.