简体   繁体   English

在TEdit(DELPHI)中使用命令运行cmd.exe

[英]Run cmd.exe with command in TEdit (DELPHI)

I have question... I know how to run cmd from Delphi and I also know how to send command there. 我有问题...我知道如何从Delphi运行cmd,也知道如何在其中发送命令。 But problem is that the command is not always the same. 但是问题在于命令并不总是相同的。 I would like to send command which first part is always the same and second will be added from "TEdit1.text". 我想发送命令,该命令的第一部分始终是相同的,第二部分将从“ TEdit1.text”中添加。 Is that possible? 那可能吗? Thank you very much for every answer! 非常感谢您的每一个回答! Villy 维利

You are asking how to concatenate two strings. 您在问如何连接两个字符串。 Use the + operator for that. 为此使用+运算符。 For instance: 例如:

'cmd.exe /c ' + Edit1.Text; 

Based on your comment I think your code should be: 根据您的评论,我认为您的代码应为:

ShellExecute(Handle, 'runas', 'cmd.exe',
  PChar('/c netsh wlan set hostednetwork mode=allow ssid='+Edit1.Text),
  nil, SW_SHOWNORMAL);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM