Board index » delphi » Using Pascal in Windows: Shortcuts & Opening Files

Using Pascal in Windows: Shortcuts & Opening Files

I have two questions which I have found no answers or examples of on the
internet or in turbo Pascal guides. I would be grateful for any help with
these problems.

Question 1 : Is it possible to create shortcuts for programs with turbo
Pascal. I have seen shortcuts with extensions '.lnk' and '.pif', is it
possible to make either of these. This may not be possible because Pascal is
a dos compiler but I am unsure.

Question 2 : Is it possible to open files in turbo Pascal which are windows
files such as notepad. I know that the Exec command can be used to open
msdos files. Is there a way of doing this.

Any help with either of these questions would be appreciated. Thank you for
reading this post.

Andrew.

 

Re:Using Pascal in Windows: Shortcuts & Opening Files


Quote
"Andrew Turing" <bhc.tril...@{*word*269}.net> wrote in message

news:KLBO4.2330$Px3.59749@news2-win.server.ntlworld.com...

Quote
> I have two questions which I have found no answers or examples of on the
> internet or in turbo Pascal guides. I would be grateful for any help with
> these problems.

> Question 2 : Is it possible to open files in turbo Pascal which are
windows
> files such as notepad. I know that the Exec command can be used to open
> msdos files. Is there a way of doing this.

I did not try to open notepad, but this works with starting Outlook Express

 {************************************************}
{                                                }
{ Turbo Exec Demo                                }
{ Copyright (c) 1985,90 by Borland International }
{                                                }
{************************************************}

program ExecDemo;

(*
  Demonstration program that shows how to use the Dos
  unit's Exec procedure to execute DOS commands (including
  running other programs or batch files).

  This program keeps prompting you for a DOS command until
  you enter a blank line.

  When using Exec, make sure you specify a {$M} directive
  so the heap leaves some memory available for the child
  process.
*)

{$M 8192,0,0}           { Leave memory for child process }

uses Dos;
var
  Command: string[127];
begin
{If you enter: "c:\program files\outlook express\msimn.exe"
                    Outlook Express starts - provided that is where OE is
located...
                    and be sure to use the quotation " " marks

                   ... this works for DOS commands and other executable
files
                   depending on the size of the file (and I'm sure other
factors)

Quote
}

  repeat
    Writeln('(press ENTER to stop)');
    write(' Enter DOS command: ');
    ReadLn(Command);
    if Command <> '' then
    begin
      SwapVectors;
      Exec(GetEnv('COMSPEC'), '/C ' + Command);
      SwapVectors;
      if DosError <> 0 then
        WriteLn('Could not execute COMMAND.COM');
      WriteLn;
    end;
  until Command = '';
end.

Bill Vergos
bi...@kennett.net

Re:Using Pascal in Windows: Shortcuts & Opening Files


Back to tell you that YES - Wordpad can be accessed using the procedure
below.  You just have to be sure that you input the correct path to
Wordpad.exe

On my computer the correct input is:
"C:\program files\accessories\wordpad.exe"  (remember to use quotation " "
marks)

Bill Vergos
bi...@kennett.net

Quote

> program ExecDemo;

> {$M 8192,0,0}           { Leave memory for child process }

> uses Dos;
> var
>   Command: string[127];
> begin
>   repeat
>     Writeln('(press ENTER to stop)');
>     write(' Enter DOS command: ');
>     ReadLn(Command);
>     if Command <> '' then
>     begin
>       SwapVectors;
>       Exec(GetEnv('COMSPEC'), '/C ' + Command);
>       SwapVectors;
>       if DosError <> 0 then
>         WriteLn('Could not execute COMMAND.COM');
>       WriteLn;
>     end;
>   until Command = '';
> end.

Re:Using Pascal in Windows: Shortcuts & Opening Files


Quote
Andrew Turing wrote:
> Question 1 : Is it possible to create shortcuts for programs with turbo
> Pascal. I have seen shortcuts with extensions '.lnk' and '.pif', is it
> possible to make either of these. This may not be possible because Pascal is
> a dos compiler but I am unsure.

Of course it is: see www.wotsit.org for details about file formats.

Wolf

Re:Using Pascal in Windows: Shortcuts & Opening Files


Quote
BillV wrote:

> Back to tell you that YES - Wordpad can be accessed using the procedure
> below.  You just have to be sure that you input the correct path to
> Wordpad.exe

> On my computer the correct input is:
> "C:\program files\accessories\wordpad.exe"  (remember to use quotation " "

On some original windows CD (95,98 or NT, can't remember) a program
shortcut.exe exists, which accepts two parameters which creates a
shortcut.

Use the EXEC way (in the other messages in this thread) to create the
link from pascal.

Re:Using Pascal in Windows: Shortcuts & Opening Files


Quote
BillV wrote:

> Back to tell you that YES - Wordpad can be accessed using the procedure
> below.  You just have to be sure that you input the correct path to
> Wordpad.exe

> On my computer the correct input is:
> "C:\program files\accessories\wordpad.exe"  (remember to use quotation " "

On some original windows CD (95,98 or NT, can't remember) a program
shortcut.exe exists, which accepts two parameters which creates a
shortcut.

Use the EXEC way (in the other messages in this thread) to create the
link from pascal.

Other Threads