FlatWhatson
Programmer
Could somebody please tell me why this code works:
Where [ipaddress] is an IP address (obviously!).
But when i use a 'PAnsiChar' string-like variable (PAnsiChar is the type that it wants you to use when using the WinExec command) constructed with text from an edit box it doesn't work (ie. Delphi likes it but when running the code does nothing, just like if you had have said WinExec('fred', SW_Show); or something):
I know that somehow the string that I am creating is wrong somewhere, but I can't for the life of me see where!
Any help would be greatly appreciated.
Code:
WinExec('ping [ipaddress]', SW_SHOW);
Where [ipaddress] is an IP address (obviously!).
But when i use a 'PAnsiChar' string-like variable (PAnsiChar is the type that it wants you to use when using the WinExec command) constructed with text from an edit box it doesn't work (ie. Delphi likes it but when running the code does nothing, just like if you had have said WinExec('fred', SW_Show); or something):
Code:
var PingCommand : string;
DOSCommand : PAnsiChar;
procedure TToolbox_Form.Ping_ButtonClick(Sender: TObject);
begin
PingCommand := 'ping ' + PingIP_Edit.Text;
DOSCommand := addr(PingCommand);
WinExec(DOSCommand, SW_Show);
end;
I know that somehow the string that I am creating is wrong somewhere, but I can't for the life of me see where!
Any help would be greatly appreciated.