Home > Back-end >  Delphi7 shellexecute use problem, rookie
Delphi7 shellexecute use problem, rookie

Time:09-28

This function I now control points, but in Windows can order

ShellExecute (handle, the 'open', 'C: \ Documents and Settings \ \ Administrator \ \ METER reading the ADB, ADB. Exe', 'the ADB push D: \ \ METER. The METER reading DBF sdcard/XFDataBase DBF_Input', ' ', SW_SHOWNORMAL);
Write mean open C: \ Documents and Settings \ \ Administrator \ \ METER reading the ADB ADB. Exe, push and written to the ADB D: \ \ METER. The METER reading DBF sdcard/XFDataBase DBF_Input
?
Why can't compile, add shellapi USES

CodePudding user response:

Really no one, I wipe

CodePudding user response:

Seek advice greatly

CodePudding user response:

 unit Unit1; 

Interface

USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI StdCtrls;

Type
TForm1=class (TForm)
For: TButton;
Procedure Button1Click (Sender: TObject);
Private
{Private declarations}
Public
{Public declarations}
The end;

Var
Form1: TForm1;

Implementation

{$R *. DFM}

Procedure TForm1. Button1Click (Sender: TObject);
The begin
ShellExecute (handle, the 'open', 'C: \ Documents and Settings \ \ Administrator \ \ METER reading the ADB, ADB. Exe', 'the ADB push D: \ \ METER. The METER reading DBF sdcard/XFDataBase DBF_Input', ' ', SW_SHOWNORMAL);
The end;

End.

I built a project, did the compiler allow, and see you this error message is you declare a form process, name is ShellExecute, it is illegal

CodePudding user response:

I just tried to: because I add the function in the type, I want to ask why some functions to add in the type
The other is on the Internet I see inside the function file directory to add pchar, do not add to it

CodePudding user response:

, generally want to see the results, if it is normal and also, sometimes without will compile pass, or garbled words, this is because the Delphi character type (string) and Microsoft's C/VB inconsistent character types, plus mean is indicate the type conversion API is Microsoft products, Delphi just encapsulates.

CodePudding user response:

The type is defined meaning, from the perspective of the code of my hair, from the type... To this end on var; Are defined within the form elements, such as for: TButton; Defines a name for the:, category is TButton; Variable, it belongs to TForm1 class, procedure Button1Click (Sender: TObject); Is the form of a process; If defined in this passage, do not belong to the form element, belongs to the global variables, such as var Form1: TForm1. Is a global variable

CodePudding user response:

1, the String is Delphi String, in order to convert a Windows can identify String, should pass PChar () casting, so as to complete call specifying EXE, open the specified file,
2, still have to join ShellAPI unit, because calling Windows API functions,
3, it is recommended that the following code, clear and understandable,

 var FileNam sParam: string; 
The begin
FileName:='C: \ Documents and Settings \ \ Administrator \ \ meter reading the ADB, ADB. Exe';
SParam:='adb push D: \ \ METER METER reading DBF sdcard/XFDataBase DBF_Input';
Shellexecute (handle, the 'open', pchar (FileName), pchar (sParam), nil, sw_shownormal);
The end;


CodePudding user response:

According to the practice of 7th floor still can only open the exe, but push the adb command don't go in

CodePudding user response:

refer to the eighth floor baidu_25994487 response:
according to the practice of 7th floor still can only open the exe, but push the adb command and did not enter

Can only open the specified file, cannot undertake parameters and commands,

CodePudding user response:

references 9 f yct0605 response:
Quote: refer to the eighth floor baidu_25994487 response:

According to the practice of 7th floor still can only open the exe, but push the adb command and did not enter

Can only open the specified file cannot be parameters and command transfer,

Can't, I in the second pchar there ping IP can be used, but in not colleagues write exe, is the black CMD window

CodePudding user response:

Has a before problem, that is, the adb. Exe, can identify a number of parameters,

CodePudding user response:

Passed the parameters of the other party by Paramter (1) read, each other through TStringList CommText segmentation parsing again again, that may be your problem in the parameter space or command is wrong, the best. Look at the adb exe inside of source code, how to parse the parameters and how to execute,

 
//use the
Var FileNam sParam: string;
The begin
FileName:='C: \ Documents and Settings \ \ Administrator \ \ meter reading the ADB, ADB. Exe';
SParam:='adb push D: \ \ METER METER reading DBF sdcard/XFDataBase DBF_Input';
If Shellexecute (handle, the 'open', pchar (FileName), pchar (sParam), nil, sw_shownormal) & lt; 32 then
The begin
Showmessage (' open XX failed! ');
exit;
The end;
The end;

CodePudding user response:

Make contact with adb. Exe programmers and parameters of the transmission way,
Otherwise their debugging at random, is not come out,

CodePudding user response:

This morning call a procedure, a similar situation, has been resolved, so suggest you:
 var FileNam sParam: string; 
The begin
FileName:='C: \ Documents and Settings \ \ Administrator \ \ meter reading the ADB, ADB. Exe';
SParam:='adb push D: \ \ METER METER reading DBF sdcard/XFDataBase DBF_Input';
WinExec (pchar (FileName + ' '+ sParam), SW_SHOW);
The end;


Try, I wish success,