Board index » delphi » how read txt-file or pdf-file

how read txt-file or pdf-file

How is it possible to start the default program to open a specific text or
pdf-file, only by inputting the filename and path??

I tried winexec but it does nothing. Shellexecute seems too difficult to be
the solution? What is left? Or anyone can give an example of shellexecute?

Many thanks!
Bert

 

Re:how read txt-file or pdf-file


On Sat, 03 Mar 2001 16:33:02 GMT, "User Delphi" <denber...@pandora.be>
wrote:

Quote
>How is it possible to start the default program to open a specific text or
>pdf-file, only by inputting the filename and path??

>I tried winexec but it does nothing. Shellexecute seems too difficult to be
>the solution? What is left? Or anyone can give an example of shellexecute?

If I understand what you're asking for then ShellExecute is precisely
the solution.

WinExec has no knowledge of file associations, so you'd have to look
that up yourself in the Registry to know the correct program to start,
much more complicated that ShellExecute.

So, with regard to ShellExecute, what's so tough about:

  ShellExecute(0, 'OPEN', 'c:\somedir\somefile.txt', '',
    'c:\somedir', SW_SHOWDEFAULT);

????

Stephen Posey
slpo...@concentric.net

Re:how read txt-file or pdf-file


Quote
"Stephen Posey" <slpo...@concentric.net> wrote in message

news:3aa4574a.14808258@news.concentric.net...
Quote
> On Sat, 03 Mar 2001 16:33:02 GMT, "User Delphi" <denber...@pandora.be>
> wrote:

> >How is it possible to start the default program to open a specific text
or
> >pdf-file, only by inputting the filename and path??

> >I tried winexec but it does nothing. Shellexecute seems too difficult to
be
> >the solution? What is left? Or anyone can give an example of
shellexecute?

> If I understand what you're asking for then ShellExecute is precisely
> the solution.

> WinExec has no knowledge of file associations, so you'd have to look
> that up yourself in the Registry to know the correct program to start,
> much more complicated that ShellExecute.

> So, with regard to ShellExecute, what's so tough about:

>   ShellExecute(0, 'OPEN', 'c:\somedir\somefile.txt', '',
>     'c:\somedir', SW_SHOWDEFAULT);

> ????

> Stephen Posey
> slpo...@concentric.net

I got an error while compiling this: string and pchar not compatible. Using
pchar function however it works! I do not really know what ity does, pchar
but it works.

The problem? I found this example on the net
ShellExecute(Handle,'open',
  'c:\windows\notepad.exe','c:\SomeText.txt',
  nil, SW_SHOWNORMAL);

But I really do not know what a handle is (you simply replaced it by 0!!)...
neither the Delphi help is very clear!!

The problem was also to find an example for handle which you simply replace
by

Thanks.

Re:how read txt-file or pdf-file


Quote
> But I really do not know what a handle is (you simply replaced it by

0!!)...

Even you could try that! If you don't know a parameter for a
function/procedure, simply try to use '', 0, nil, or something like
Application.Handle! If it doesn't work, leave a message in this group!
--
uws
MAILTO:  ln.bewfmt.eelretslob@spuorgswen  BACKWARDS!

Other Threads