Use shellexecute to make ping!

xiaoxiao2021-03-06  78

It is bored today, seeing the article on the 9CBS says that the use of the shellexecute function, how to use Shellexecute this good Dongdong to call cmd.exe this command prompt program and give it a value to it, let it automatically Wait a PING operation?

Key Discovery: First open the MS-DOS window research, enter CMD / in the command prompt character, check the help of the cmd.exe that has been reserved for the M $, has found.

/ / =========================================================================================================================================================================================== =================== Unit unit1;

Interface

Uses Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, stdctrls

TYPE TFORM1 = Class (TFORM) Button1: TButton; Procedure Button1Click (sender: TOBJECT); private {private declarations} end;

Var Form1: TFORM1;

ImplementationUses shellapi; {$ r * .dfm}

Procedure TForm1.Button1Click (Sender: TOBJECT); Begin Shellexecute (Handle, NIL, 'cmd.exe', '/ k ping 127.0.0.1', nil, sw_normal); // ----- This sentence is using parameters / K, ping After IP 127.0.0.1, the cmd.exe window quietly waiting for you ... // shellexecute (Handle, NIL, 'cmd.exe', '/ c ping 127.0.0.1', nil, SW_NORMAL); // ----- This sentence is using parameters / c, and after ping, the cmd.exe window disappears ... End; end. / / ========= ============================================================================================================================================================================================================= ========== Little feeling: M $ developed can generally run the parameters, this is very good ... With different parameters, there will be different final results. This should be worthy of affirmation.

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

New Post(0)