提问人:Ertugrul Sahin 提问时间:11/7/2023 最后编辑:stuartdErtugrul Sahin 更新时间:11/7/2023 访问量:27
如何在c中运行新进程时更改默认值#
How can i change a default value while running a new process in c#
问:
我有一个标签链接,稍后我会点击这个链接,这将是一个新过程。我可以做到这一步。我有一个默认的ip值,我想通过运行新进程来更改这个默认值。 例如:
nmsipaddressTextBox.Text = DefaultIp;//1.1.1.1
后来链接单击并启动了不同的进程。
nmsipaddressTextBox.Text = DefaultIp;//2.3.4.5.
我该怎么做?
static class Program {
[STAThread]
static void Main() {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new SNForm());
}
}
public partial class SNForm : Form {
public SNForm() {
InitializeComponent();
this.Size = new Size(1100, 650);
mainPage();
AutoScroll = true;
CenterToScreen();
this.Resize += delegate (object sender, EventArgs e) { FormResize(sender, e, tabControl); };
tbxLinkName.MaxLength = 20;
}
// Connection
public string DefaultIp = "1.1.1.1";
private void mainPage() {
nmsipaddressTextBox.Text = DefaultIp;
}
}
public partial class SNForm : Form
LinkLabel deneme_link = new LinkLabel(); {
public void deneme_link_Click(object sender, LinkLabelLinkClickedEventArgs e) {
SNForm linkform = new SNForm();
string x_ = "2.3.4.5.";
ProcessStartInfo startinfo = new ProcessStartInfo("SN.exe");
startinfo.Arguments = x_;
Process process = new Process();
process.StartInfo = startinfo;
process.Start();
}
}
private void DesignEventsDeviceSpecsPanel() {
deneme_link.LinkClicked += new LinkLabelLinkClickedEventHandler(deneme_link_Click);
}
我试过这个:
main(string[] args)
string argsvalue = args[0];
但是我知道的不多,这些也经常我承担很大的错误。
答: 暂无答案
评论
Environment.GetCommandLineArgs()
Main