Board index » delphi » Problem launching programs in Win95 from a Delphi app

Problem launching programs in Win95 from a Delphi app

Hi,

I have written a few programs in Delphi 5 on a Windows 98 machine. One of
the programs launches another program from a given path using
ShellExecute. When I try to execute this from a shared drive on a network,
it works fine on a Win98 system. When I try it on a Win95 machine, it
doesn't launch the program.

I don't have my code with me as I am writing this, but I used code which I
know does the following on my non-networked machine:
1. Load a config file into a memo box.
2. Take a path from the first line of this file, and add a .EXE filename
to this path.
3. Execute this EXE with a command-line parameter.

This program (also written in Delphi 5), does not show up on screen at
all. Can anyone help me? It works fine on Win98, but not on Win95!!!

Thank you very much in advance.

 

Re:Problem launching programs in Win95 from a Delphi app


I don't think ShellExecute is available on a machine Without  Active
Desktop.  Windows 95 didn't have it.  In successive upgrades of IExplorer,
when IE 4.0 was installed, the option was offered "Do you want to Install
Active Desktop".  If you answered in the affirmative, Active Desktop was
installed.  If you do not have the capability to dock Icons on the Taskbar,
you don't have Active Desktop...I made this mistake on a Winnt40 box.  I
uninstalled IExplorer from the machine,which rolls it back to version 3.01
and reinstalled 4.0 with the Active Desktop, then upgraded that to the
current versions... I am sure there is a shortcut to this, but that worked.

Quote
"QS Computing" <postmas...@qscomputing.plus.com> wrote in message

news:fP3ya.21212$9C6.1094376@wards.force9.net...
Quote
> Hi,

> I have written a few programs in Delphi 5 on a Windows 98 machine. One of
> the programs launches another program from a given path using
> ShellExecute. When I try to execute this from a shared drive on a network,
> it works fine on a Win98 system. When I try it on a Win95 machine, it
> doesn't launch the program.

> I don't have my code with me as I am writing this, but I used code which I
> know does the following on my non-networked machine:
> 1. Load a config file into a memo box.
> 2. Take a path from the first line of this file, and add a .EXE filename
> to this path.
> 3. Execute this EXE with a command-line parameter.

> This program (also written in Delphi 5), does not show up on screen at
> all. Can anyone help me? It works fine on Win98, but not on Win95!!!

> Thank you very much in advance.

Re:Problem launching programs in Win95 from a Delphi app


On Mon, 19 May 2003 09:17:22 -0500, "MikeB" <Mi...@USAisMyHome.com>
wrote:

Quote
>I don't think ShellExecute is available on a machine Without  Active
>Desktop.  Windows 95 didn't have it.  In successive upgrades of IExplorer,
>when IE 4.0 was installed, the option was offered "Do you want to Install
>Active Desktop".  If you answered in the affirmative, Active Desktop was
>installed.  

Funny that, my Win 95 has ShellExecute

It is also well documented in the Win32 Programmer's Reference Help
File

Re:Problem launching programs in Win95 from a Delphi app


"QS Computing" <postmas...@qscomputing.plus.com> schrieb im Newsbeitrag
news:fP3ya.21212$9C6.1094376@wards.force9.net...

Quote
> Hi,

> I have written a few programs in Delphi 5 on a Windows 98 machine. One of
> the programs launches another program from a given path using
> ShellExecute. When I try to execute this from a shared drive on a network,
> it works fine on a Win98 system. When I try it on a Win95 machine, it
> doesn't launch the program.

> I don't have my code with me as I am writing this, but I used code which I
> know does the following on my non-networked machine:
> 1. Load a config file into a memo box.
> 2. Take a path from the first line of this file, and add a .EXE filename
> to this path.
> 3. Execute this EXE with a command-line parameter.

> This program (also written in Delphi 5), does not show up on screen at
> all. Can anyone help me? It works fine on Win98, but not on Win95!!!

You have to examine the result code!!!

Return Values of ShellExecute:

If the function succeeds, the return value is the instance handle of the
application that was run, or the handle of a dynamic data exchange (DDE)
server application.
If the function fails, the return value is an error value that is less than
or equal to 32.

hth
Andreas

Re:Problem launching programs in Win95 from a Delphi app


Yeah, it was a brain fart...  Desktop Shell Extensions... Quite a stretch to
ShellExecute ;-)

Quote
"J French" <Bounce_It_je...@iss.u-net.com_.bin> wrote in message

news:3ec8f634.30146786@news.btclick.com...
Quote
> On Mon, 19 May 2003 09:17:22 -0500, "MikeB" <Mi...@USAisMyHome.com>
> wrote:

> >I don't think ShellExecute is available on a machine Without  Active
> >Desktop.  Windows 95 didn't have it.  In successive upgrades of
IExplorer,
> >when IE 4.0 was installed, the option was offered "Do you want to Install
> >Active Desktop".  If you answered in the affirmative, Active Desktop was
> >installed.

> Funny that, my Win 95 has ShellExecute

> It is also well documented in the Win32 Programmer's Reference Help
> File

Re:Problem launching programs in Win95 from a Delphi app


On Mon, 19 May 2003 12:48:24 -0500, "MikeB" <Mi...@USAisMyHome.com>
wrote:

Quote
>Yeah, it was a brain fart...  Desktop Shell Extensions... Quite a stretch to
>ShellExecute ;-)

We all do it
- I certainly did today

Re:Problem launching programs in Win95 from a Delphi app


I'm sure that I don't have Active Desktop enabled on my Win98 box - but I
still have ShellExecute. Is it worth replacing the ShellExecute with a
WinExec - I can get exactly the same result using both functions on my
Win98 box, although the API reference says not to use WinExec.

Any thoughtson this?

Quote
MikeB wrote:
> I don't think ShellExecute is available on a machine Without  Active
> Desktop.  Windows 95 didn't have it.  In successive upgrades of IExplorer,
> when IE 4.0 was installed, the option was offered "Do you want to Install
> Active Desktop".  If you answered in the affirmative, Active Desktop was
> installed.  If you do not have the capability to dock Icons on the Taskbar,
> you don't have Active Desktop...I made this mistake on a Winnt40 box.  I
> uninstalled IExplorer from the machine,which rolls it back to version 3.01
> and reinstalled 4.0 with the Active Desktop, then upgraded that to the
> current versions... I am sure there is a shortcut to this, but that worked.
> "QS Computing" <postmas...@qscomputing.plus.com> wrote in message
> news:fP3ya.21212$9C6.1094376@wards.force9.net...
> > Hi,

> > I have written a few programs in Delphi 5 on a Windows 98 machine. One of
> > the programs launches another program from a given path using
> > ShellExecute. When I try to execute this from a shared drive on a network,
> > it works fine on a Win98 system. When I try it on a Win95 machine, it
> > doesn't launch the program.

> > I don't have my code with me as I am writing this, but I used code which I
> > know does the following on my non-networked machine:
> > 1. Load a config file into a memo box.
> > 2. Take a path from the first line of this file, and add a .EXE filename
> > to this path.
> > 3. Execute this EXE with a command-line parameter.

> > This program (also written in Delphi 5), does not show up on screen at
> > all. Can anyone help me? It works fine on Win98, but not on Win95!!!

> > Thank you very much in advance.

Re:Problem launching programs in Win95 from a Delphi app


On Tue, 20 May 2003 11:32:30 BST, postmas...@qscomputing.plus.com(QS

Quote
Computing) wrote:
>I'm sure that I don't have Active Desktop enabled on my Win98 box - but I
>still have ShellExecute. Is it worth replacing the ShellExecute with a
>WinExec - I can get exactly the same result using both functions on my
>Win98 box, although the API reference says not to use WinExec.

>Any thoughtson this?

Yes, quit a few thoughts

Mike B was having a 'senile moment' when he wrote that stuff about
Active Desktop
- or just plain drunk

It does not matter - we all{*word*19} up - especially when tired

ShellExecute is what you want, or ShellExecuteEx if you want to be
really trendy - that or CreateProcess

WinExec is just something that has been superceded
- it probably just calls ShellExecute

Your problem with the Win95 machine is almost certainly down to
something else

Have you checked the Error returned from WinExec ?

Re:Problem launching programs in Win95 from a Delphi app


What's the difference between ShellExecute and ShellExecuteEx? And can you
give me some code to use CreateProcess?

Thank you very much.

Quote
J French wrote:
> On Tue, 20 May 2003 11:32:30 BST, postmas...@qscomputing.plus.com(QS
> Computing) wrote:
> >I'm sure that I don't have Active Desktop enabled on my Win98 box - but I
> >still have ShellExecute. Is it worth replacing the ShellExecute with a
> >WinExec - I can get exactly the same result using both functions on my
> >Win98 box, although the API reference says not to use WinExec.

> >Any thoughtson this?
> Yes, quit a few thoughts
> Mike B was having a 'senile moment' when he wrote that stuff about
> Active Desktop
> - or just plain drunk
> It does not matter - we all{*word*19} up - especially when tired
> ShellExecute is what you want, or ShellExecuteEx if you want to be
> really trendy - that or CreateProcess
> WinExec is just something that has been superceded
> - it probably just calls ShellExecute
> Your problem with the Win95 machine is almost certainly down to
> something else
> Have you checked the Error returned from WinExec ?

Re:Problem launching programs in Win95 from a Delphi app


On Tue, 20 May 2003 16:17:43 BST, postmas...@qscomputing.plus.com(QS

Quote
Computing) wrote:
>What's the difference between ShellExecute and ShellExecuteEx? And can you
>give me some code to use CreateProcess?

ShellExecute is an older version that has parameters

ShellExecuteEx passes the parameters in a Structure

You really need to dig round your disk for the Win32 Programmer's
Reference Help File and put a link to it on your Desktop if you are
going to start using APIs in a big way.

Here is an example of using CreateProcess :-

procedure TForm1.Button1Click(Sender: TObject);
Const
  FileName = 'notepad.exe';
  CmdLine = 'c:\autoexec.bat';
var
  SUInfo: TStartupInfo;
  ProcInfo: TProcessInformation;
  S: string;
  Result :LongBool;
begin
  { Enclose Command in quotes to take care of
    long filenames with spaces. }
  S := '"' + Filename + '" "' + CmdLine + '"';

  // Zap SUInfo
  FillChar(SUInfo, SizeOf(SUInfo), #0);
  // Fill in basic info
  SUInfo.cb := SizeOf(SUInfo);
  SUInfo.dwFlags := STARTF_USESHOWWINDOW;
  SUInfo.wShowWindow := SW_SHOWNORMAL;

  Result := CreateProcess(NIL,
                          PChar( S ),  // "file" "command"
                          NIL, NIL, FALSE,
                          CREATE_NEW_CONSOLE or
                          NORMAL_PRIORITY_CLASS, NIL,
                          PChar(ExtractFilePath(CmdLine)),
                          SUInfo,
                          ProcInfo);
  // If we had an Error
  If Integer(Result) = 0 Then
     Begin
       ShowMessage( 'Error: ' + IntToStr(GetLastError) );
       Exit;
     End;

  // For fun, lets wait until the target App is closed
  WaitForSingleObject(ProcInfo.hProcess, INFINITE);
  //
  ShowMessage( 'I Got Back' );
end;

Re:Problem launching programs in Win95 from a Delphi app


That CreateProcess code is great - I'll try it out this evening and see if
I can get it to work properly. Can someone give me the code for
ShellExecuteEx as well?

Thank you.

Quote
J French wrote:
> On Tue, 20 May 2003 16:17:43 BST, postmas...@qscomputing.plus.com(QS
> Computing) wrote:
> >What's the difference between ShellExecute and ShellExecuteEx? And can you
> >give me some code to use CreateProcess?

> ShellExecute is an older version that has parameters
> ShellExecuteEx passes the parameters in a Structure
> You really need to dig round your disk for the Win32 Programmer's
> Reference Help File and put a link to it on your Desktop if you are
> going to start using APIs in a big way.
> Here is an example of using CreateProcess :-
> procedure TForm1.Button1Click(Sender: TObject);
> Const
>   FileName = 'notepad.exe';
>   CmdLine = 'c:\autoexec.bat';
> var
>   SUInfo: TStartupInfo;
>   ProcInfo: TProcessInformation;
>   S: string;
>   Result :LongBool;
> begin
>   { Enclose Command in quotes to take care of
>     long filenames with spaces. }
>   S := '"' + Filename + '" "' + CmdLine + '"';
>   // Zap SUInfo
>   FillChar(SUInfo, SizeOf(SUInfo), #0);
>   // Fill in basic info
>   SUInfo.cb := SizeOf(SUInfo);
>   SUInfo.dwFlags := STARTF_USESHOWWINDOW;
>   SUInfo.wShowWindow := SW_SHOWNORMAL;
>   Result := CreateProcess(NIL,
>                           PChar( S ),  // "file" "command"
>                           NIL, NIL, FALSE,
>                           CREATE_NEW_CONSOLE or
>                           NORMAL_PRIORITY_CLASS, NIL,
>                           PChar(ExtractFilePath(CmdLine)),
>                           SUInfo,
>                           ProcInfo);
>   // If we had an Error
>   If Integer(Result) = 0 Then
>      Begin
>        ShowMessage( 'Error: ' + IntToStr(GetLastError) );
>        Exit;
>      End;
>   // For fun, lets wait until the target App is closed
>   WaitForSingleObject(ProcInfo.hProcess, INFINITE);
>   //
>   ShowMessage( 'I Got Back' );
> end;

Re:Problem launching programs in Win95 from a Delphi app


On Wed, 21 May 2003 11:22:43 BST, postmas...@qscomputing.plus.com(QS

Quote
Computing) wrote:
>That CreateProcess code is great - I'll try it out this evening and see if
>I can get it to work properly. Can someone give me the code for
>ShellExecuteEx as well?

>Thank you.

Uses ShellAPI;
procedure TForm1.Button1Click(Sender: TObject);
Var
  SI :SHELLEXECUTEINFO;
  Ret :LongBool;
begin
  FillChar( SI, SizeOf(SI), 0 );
  SI.cbSize := SizeOf( SI );
  //
  SI.Wnd := Self.Handle;
  SI.nShow := 0; // say SW_MAXIMIZE if lpFile is an EXE;
  //
  SI.lpVerb := 'open';
  SI.lpFile := 'c:\download\links.htm';

  Ret := ShellExecuteEx( @SI );
  If Integer(Ret) = 0 Then
     Begin
       ShowMessage( 'Error:' + IntToStr(GetLastError) );
       Exit;
     End;

end;

Other Threads