怎样使WinExe程序能接受参数?
最好给出示例代码,谢谢! 问题点数:10、回复次数:5Top
1 楼arens2003(arens2003)回复于 2004-05-08 14:38:19 得分 0
?Top
2 楼linaren(JAVA/LINUX...)回复于 2004-05-08 15:15:40 得分 0
main()函数不是可以传参数的吗
取就行了Top
3 楼hbxtlhx(平民百姓-自已动手,丰衣足食)回复于 2004-05-08 15:23:22 得分 10
为什么不用Process来做呢,这个可以传参的,WinEXE是个简单的东西.System.Diagnostics 命名空间Top
4 楼hbxtlhx(平民百姓-自已动手,丰衣足食)回复于 2004-05-08 15:24:24 得分 0
如下一个MSDN的例子:
using System;
using System.Diagnostics;
using System.ComponentModel;
namespace MyProcessSample
{
/// <summary>
/// Shell for the sample.
/// </summary>
public class MyProcess
{
/// <summary>
/// Opens the Internet Explorer application.
/// </summary>
public void OpenApplication(string myFavoritesPath)
{
// Start Internet Explorer. Defaults to the home page.
Process.Start("IExplore.exe");
// Display the contents of the favorites folder in the browser.
Process.Start(myFavoritesPath);
}
/// <summary>
/// Opens urls and .html documents using Internet Explorer.
/// </summary>
public void OpenWithArguments()
{
// url's are not considered documents. They can only be opened
// by passing them as arguments.
Process.Start("IExplore.exe", "www.northwindtraders.com");
// Start a Web page using a browser associated with .html and .asp files.
Process.Start("IExplore.exe", "C:\\myPath\\myFile.htm");
Process.Start("IExplore.exe", "C:\\myPath\\myFile.asp");
}
/// <summary>
/// Uses the ProcessStartInfo class to start new processes, both in a minimized
/// mode.
/// </summary>
public void OpenWithStartInfo()
{
ProcessStartInfo startInfo = new ProcessStartInfo("IExplore.exe");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process.Start(startInfo);
startInfo.Arguments = "www.northwindtraders.com";
Process.Start(startInfo);
}
public static void Main()
{
// Get the path that stores favorite links.
string myFavoritesPath =
Environment.GetFolderPath(Environment.SpecialFolder.Favorites);
MyProcess myProcess = new MyProcess();
myProcess.OpenApplication(myFavoritesPath);
myProcess.OpenWithArguments();
myProcess.OpenWithStartInfo();
}
}
}
Top
5 楼arens2003(arens2003)回复于 2004-05-08 15:36:41 得分 0
谢谢楼上的兄弟
不过我的意思是使我的程序能在被别的程序调用的时候给传入参数的
问题是:我不知道怎样取得别的程序传给我的参数Top





