In real software industry, sometimes we need to cooperate with another vendor to improve our product. In this case, I found a case that I need to send a parameter to my vendor application. My application is built under VB .net, while my vendor application is built under C# .Net. So what I did was.
In my VB .Net application, I put below code to call my vendor application. I put the executable file location under settings.
argument = “Servername|DBName|UserID|Password”
System.Diagnostics.Process.Start(My.Settings.exeLoc, argument.Trim())
Then in my vendor application, they need to put this code in form_load event and need to create a method to parse parameter based on delimitier “|” (let’s say if you’d like to send more then 1 parameter).
private void Form1_Load(object sender, EventArgs e)
{
string[] args = Environment.GetCommandLineArgs();
string param=””;
// The first commandline argument is always the executable path itself.
if (args.Length > 1)
{
for (int i = 1; i < args.Length;i++ )
{
param += args[i];
}
this.parse(param);
}
}
Have a nice try.
Leave a Response »