About EXE file delivery parameter method

xiaoxiao2021-03-06  63

About the EXE file delivery parameter method Yesterday, the colleague asked, how did the EXE file in Delphi convey parameters? Because the hand is installed Delphi, Powerbuilder is the following: 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 'Then 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.

转载请注明原文地址:https://www.9cbs.com/read-86594.html

New Post(0)