About EXE file delivery parameter method
Yesterday, my colleague asked, how did the exe file in Delphi convey parameters?
Because the hand is installed Delphi, Powerbuilder
The following is the code:
Delphi:
The following is the program code: procedure tform1.form1.form; var i: integer; begin for i: = 1 to paramcount do begin if lowercase (Paramstr (i)) = 'Beep' Then Application.MessageBox ('Demo ',' Beep ', IDOK ELSE IF LowerCase (Paramstr (i)) =' exit 'the Application.Terminate; end; end;
Powerbuilder:
The following is program code: string ls_cmd, ls_arg [] integer i, li_argcnt // get the arguments and strup blanks // from start and end of stringls_cmd = trim (CommandParm ()) li_argcnt = 1do while len (ls_cmd)> 0 / / Find the first blanki = POS (ls_cmd, ") // if no blacks (only one argument), // set i to point to the Hypothetical character // after the end of the stringif i = 0 THEN i = LEN ( LS_CMD) 1 // Assign THE arg to the argument array.// Number of Chars copied is one less Than a // position of the space Found with posls_arg [li_argcnt] = left (ls_cmd, i - 1) // increment the Argument Count for the next loopli_argcnt = li_argcnt 1 // Remove The Argument from the string // So the next argument becomes firstls_cmd = replace (ls_cmd, 1, i, ") loop
use:
* .exe beep exit
================================= joecom 2004-11-20