Board index » delphi » ShellExecute under Win98

ShellExecute under Win98

Hello,
I tested the ShellExecute command under Win2000 and it works, but when
I moved the program with InstallShield kit it does'n appear.
Source code is the following:

  Result := ShellExecute(Application.MainForm.Handle, nil,
    StrPCopy(zFileName, FileName), StrPCopy(zParams, Params),
    StrPCopy(zDir, DefaultDir), ShowCmd);//with showcmd=SW_SHOW
    showMessage('It have to appear the command.com window');

It is something about the "command.com" under Win98 and "cmd.com"
under Win2000.
Thank you,
                Nemecsek Gyorke
                nemec...@personal.ro

 

Re:ShellExecute under Win98


1. I use Application.Handle instead of Application.MainForm.Handle (but both
should work).
2. There is no need for a StrPCopy, an AnsiString is already zero-terminated
(you only need to typecast as PChar).
3. SW_SHOW show the window in its last position (which might be out of
range). Use SW_SHOWNORMAL instead.

Example:

uses
  ShellAPI;

procedure Run(const FileName: String; Parameters: String = ''; Directory:
String = ''; ShowCmd: Integer = SW_SHOWNORMAL);
begin
  if ShellExecute(Application.Handle, 'open', PChar(FileName),
PChar(Parameters), PChar(Directory), ShowCmd) <= 32 then
    RaiseLastWin32Error;
end;

"Nemecsek Gyorke" <romaup...@yahoo.com> schreef in bericht
news:8geolt4p8dcu65vns0c05ond1t1pgu040c@4ax.com...

Quote
> Hello,
> I tested the ShellExecute command under Win2000 and it works, but when
> I moved the program with InstallShield kit it does'n appear.
> Source code is the following:

>   Result := ShellExecute(Application.MainForm.Handle, nil,
>     StrPCopy(zFileName, FileName), StrPCopy(zParams, Params),
>     StrPCopy(zDir, DefaultDir), ShowCmd);//with showcmd=SW_SHOW
>     showMessage('It have to appear the command.com window');

> It is something about the "command.com" under Win98 and "cmd.com"
> under Win2000.
> Thank you,
> Nemecsek Gyorke
> nemec...@personal.ro

Re:ShellExecute under Win98


I find out the error. With your help(and with >
RaiseLastWin32Error;) I get the next error:

"Win 32 Error. Code 31.
A device attached to the sistem is not functioning."

The ShellExecute command contained a *.bat file with
xcopy %1 %2 /s
to copy one folder into another. The path of the directory exists and
the destination folder was only crated.

From you I have a lot of response,
Thank you for all of them,
                        Nemecsek Gyorke
                        nemec...@personal.ro

PS: I will try to reinstall Win98 ...

On Tue, 24 Jul 2001 09:47:33 +0200, "M.H. Avegaart"

Quote
<avega...@NOSPAMmccomm.nl> wrote:
>1. I use Application.Handle instead of Application.MainForm.Handle (but both
>should work).
>2. There is no need for a StrPCopy, an AnsiString is already zero-terminated
>(you only need to typecast as PChar).
>3. SW_SHOW show the window in its last position (which might be out of
>range). Use SW_SHOWNORMAL instead.

>Example:

>uses
>  ShellAPI;

>procedure Run(const FileName: String; Parameters: String = ''; Directory:
>String = ''; ShowCmd: Integer = SW_SHOWNORMAL);
>begin
>  if ShellExecute(Application.Handle, 'open', PChar(FileName),
>PChar(Parameters), PChar(Directory), ShowCmd) <= 32 then
>    RaiseLastWin32Error;
>end;

>"Nemecsek Gyorke" <romaup...@yahoo.com> schreef in bericht
>news:8geolt4p8dcu65vns0c05ond1t1pgu040c@4ax.com...
>> Hello,
>> I tested the ShellExecute command under Win2000 and it works, but when
>> I moved the program with InstallShield kit it does'n appear.
>> Source code is the following:

>>   Result := ShellExecute(Application.MainForm.Handle, nil,
>>     StrPCopy(zFileName, FileName), StrPCopy(zParams, Params),
>>     StrPCopy(zDir, DefaultDir), ShowCmd);//with showcmd=SW_SHOW
>>     showMessage('It have to appear the command.com window');

>> It is something about the "command.com" under Win98 and "cmd.com"
>> under Win2000.
>> Thank you,
>> Nemecsek Gyorke
>> nemec...@personal.ro

Re:ShellExecute under Win98


Why are you using ShellExecute to copy a directory structure ? You can do
that with SHFileOperation.

"Nemecsek Gyorke" <romaup...@yahoo.com> schreef in bericht
news:5m8tltkippt0tm63105vqu18mml5h0lere@4ax.com...

Quote
> I find out the error. With your help(and with >
> RaiseLastWin32Error;) I get the next error:

> "Win 32 Error. Code 31.
> A device attached to the sistem is not functioning."

> The ShellExecute command contained a *.bat file with
> xcopy %1 %2 /s
> to copy one folder into another. The path of the directory exists and
> the destination folder was only crated.

> From you I have a lot of response,
> Thank you for all of them,
> Nemecsek Gyorke
> nemec...@personal.ro

> PS: I will try to reinstall Win98 ...

> On Tue, 24 Jul 2001 09:47:33 +0200, "M.H. Avegaart"
> <avega...@NOSPAMmccomm.nl> wrote:

> >1. I use Application.Handle instead of Application.MainForm.Handle (but
both
> >should work).
> >2. There is no need for a StrPCopy, an AnsiString is already
zero-terminated
> >(you only need to typecast as PChar).
> >3. SW_SHOW show the window in its last position (which might be out of
> >range). Use SW_SHOWNORMAL instead.

> >Example:

> >uses
> >  ShellAPI;

> >procedure Run(const FileName: String; Parameters: String = ''; Directory:
> >String = ''; ShowCmd: Integer = SW_SHOWNORMAL);
> >begin
> >  if ShellExecute(Application.Handle, 'open', PChar(FileName),
> >PChar(Parameters), PChar(Directory), ShowCmd) <= 32 then
> >    RaiseLastWin32Error;
> >end;

> >"Nemecsek Gyorke" <romaup...@yahoo.com> schreef in bericht
> >news:8geolt4p8dcu65vns0c05ond1t1pgu040c@4ax.com...
> >> Hello,
> >> I tested the ShellExecute command under Win2000 and it works, but when
> >> I moved the program with InstallShield kit it does'n appear.
> >> Source code is the following:

> >>   Result := ShellExecute(Application.MainForm.Handle, nil,
> >>     StrPCopy(zFileName, FileName), StrPCopy(zParams, Params),
> >>     StrPCopy(zDir, DefaultDir), ShowCmd);//with showcmd=SW_SHOW
> >>     showMessage('It have to appear the command.com window');

> >> It is something about the "command.com" under Win98 and "cmd.com"
> >> under Win2000.
> >> Thank you,
> >> Nemecsek Gyorke
> >> nemec...@personal.ro

Re:ShellExecute under Win98


For M.H. Avegaart
        I find the 'SHfileOperation' command in 'Win32 Developers
Reference' help file(Delphi->Help->MS SDK Help Files' but I don't know
how to use(what header to include or unit, and what parameters ).
        The 'ShellExecute' works under WindowsNT but under Win98 isn't
work( I reinstalled Win98).
        I don't know anything about how to use DLL files. I saw in
'comp.lang.pascal.delphi.misc' 2 articles from 21.07.01 and 22.07.01
whit 'DLL' word included in title, but I remain in the same status.
        If you want to help me I will be happy.
        Thank you,
                                Nemecsek
On Wed, 25 Jul 2001 17:18:07 +0200, "M.H. Avegaart"
Quote
<avega...@NOSPAMmccomm.nl> wrote:
>Why are you using ShellExecute to copy a directory structure ? You can do
>that with SHFileOperation.

>"Nemecsek Gyorke" <romaup...@yahoo.com> schreef in bericht
>news:5m8tltkippt0tm63105vqu18mml5h0lere@4ax.com...
>> I find out the error. With your help(and with >
>> RaiseLastWin32Error;) I get the next error:

>> "Win 32 Error. Code 31.
>> A device attached to the sistem is not functioning."

>> The ShellExecute command contained a *.bat file with
>> xcopy %1 %2 /s
>> to copy one folder into another. The path of the directory exists and
>> the destination folder was only crated.

Re:ShellExecute under Win98


Example:

uses
  ShellAPI;

function CopyDirectory(const SrcPath, DstPath: String): Boolean;
var
  FileOp: TSHFileOpStruct;
begin
  FileOp.Wnd := Application.Handle;
  FileOp.wFunc := FO_COPY;
  FileOp.pFrom := PChar(SrcPath + #0);
  FileOp.pTo := PChar(DstPath + #0);
  FileOp.fFlags := FOF_NOCONFIRMATION or FOF_NOCONFIRMMKDIR;
  Result := SHFileOperation(FileOp) = 0;
end;

ps. Add FOF_SILENT to FileOp.fFlags if you don't want a progress dialog.

Quote
"Nemecsek Gyorke" <romaup...@yahoo.com> wrote in message

news:1h3lmtk5givvlc5l35ph2auiuelq0jflhf@4ax.com...
Quote
> For M.H. Avegaart
> I find the 'SHfileOperation' command in 'Win32 Developers
> Reference' help file(Delphi->Help->MS SDK Help Files' but I don't know
> how to use(what header to include or unit, and what parameters ).
> The 'ShellExecute' works under WindowsNT but under Win98 isn't
> work( I reinstalled Win98).
> I don't know anything about how to use DLL files. I saw in
> 'comp.lang.pascal.delphi.misc' 2 articles from 21.07.01 and 22.07.01
> whit 'DLL' word included in title, but I remain in the same status.
> If you want to help me I will be happy.
> Thank you,
> Nemecsek
> On Wed, 25 Jul 2001 17:18:07 +0200, "M.H. Avegaart"
> <avega...@NOSPAMmccomm.nl> wrote:

> >Why are you using ShellExecute to copy a directory structure ? You can do
> >that with SHFileOperation.

> >"Nemecsek Gyorke" <romaup...@yahoo.com> schreef in bericht
> >news:5m8tltkippt0tm63105vqu18mml5h0lere@4ax.com...
> >> I find out the error. With your help(and with >
> >> RaiseLastWin32Error;) I get the next error:

> >> "Win 32 Error. Code 31.
> >> A device attached to the sistem is not functioning."

> >> The ShellExecute command contained a *.bat file with
> >> xcopy %1 %2 /s
> >> to copy one folder into another. The path of the directory exists and
> >> the destination folder was only crated.

Re:ShellExecute under Win98


Thank you again for your response.
I have the errors 'Cannot copy file: Cannot read from the source file
or disc'. Where I have to look for the errors(isn't work on WinNt,
neither on Win98).
Ps: the OS is somwhere wrong ...
                Nemecsek Gyorke

On Fri, 3 Aug 2001 15:28:17 +0200, "M.H. Avegaart"

Quote
<avega...@NOSPAMmccomm.nl> wrote:
>Example:

>uses
>  ShellAPI;

>function CopyDirectory(const SrcPath, DstPath: String): Boolean;
>var
>  FileOp: TSHFileOpStruct;
>begin
>  FileOp.Wnd := Application.Handle;
>  FileOp.wFunc := FO_COPY;
>  FileOp.pFrom := PChar(SrcPath + #0);
>  FileOp.pTo := PChar(DstPath + #0);
>  FileOp.fFlags := FOF_NOCONFIRMATION or FOF_NOCONFIRMMKDIR;
>  Result := SHFileOperation(FileOp) = 0;
>end;

>ps. Add FOF_SILENT to FileOp.fFlags if you don't want a progress dialog.

Re:ShellExecute under Win98


Did the source path end with an backslash ? And the destination path ?

Quote
"Nemecsek Gyorke" <romaup...@yahoo.com> wrote in message

news:h1ilmts028h52ju6sv9fj961tdp01322l4@4ax.com...
Quote
> Thank you again for your response.
> I have the errors 'Cannot copy file: Cannot read from the source file
> or disc'. Where I have to look for the errors(isn't work on WinNt,
> neither on Win98).
> Ps: the OS is somwhere wrong ...
> Nemecsek Gyorke

> On Fri, 3 Aug 2001 15:28:17 +0200, "M.H. Avegaart"
> <avega...@NOSPAMmccomm.nl> wrote:

> >Example:

> >uses
> >  ShellAPI;

> >function CopyDirectory(const SrcPath, DstPath: String): Boolean;
> >var
> >  FileOp: TSHFileOpStruct;
> >begin
> >  FileOp.Wnd := Application.Handle;
> >  FileOp.wFunc := FO_COPY;
> >  FileOp.pFrom := PChar(SrcPath + #0);
> >  FileOp.pTo := PChar(DstPath + #0);
> >  FileOp.fFlags := FOF_NOCONFIRMATION or FOF_NOCONFIRMMKDIR;
> >  Result := SHFileOperation(FileOp) = 0;
> >end;

> >ps. Add FOF_SILENT to FileOp.fFlags if you don't want a progress dialog.

Re:ShellExecute under Win98


Yes it finished with a backslash but it work WITHOUT the backslash.
First I understand that it have to be backslash but I have bad
understand.
With your help I resolved this problem,
THANK YOU,
                Nemecsek Gyorke
                nemec...@personal.ro
On Mon, 6 Aug 2001 10:49:11 +0200, "M.H. Avegaart"
Quote
<avega...@NOSPAMmccomm.nl> wrote:
>Did the source path end with an backslash ? And the destination path ?

>"Nemecsek Gyorke" <romaup...@yahoo.com> wrote in message
>news:h1ilmts028h52ju6sv9fj961tdp01322l4@4ax.com...
>> Thank you again for your response.
>> I have the errors 'Cannot copy file: Cannot read from the source file
>> or disc'. Where I have to look for the errors(isn't work on WinNt,
>> neither on Win98).
>> Ps: the OS is somwhere wrong ...
>> Nemecsek Gyorke

Other Threads