Windows XP和Windows 7中的命令行参数不同 [英] Command line arguments differ in Windows XP and Windows 7

查看:158
本文介绍了Windows XP和Windows 7中的命令行参数不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我仍然使用在Microsoft Visual Studio 2008下开发的控制台程序.我最近更改为Windows 7,并发现在使用以下Main调用时会发现该问题:

 公共 静态  void  Main(字符串 [] args)
{
} 


然后发出命令

 C:> myprog -l <​​/pre> 
对于Windows XP,args[0]将给出第一个参数"-l",而在Windows 7中,我在args[0]中看到程序名称myprog.我在代码项目中搜索了这里的问题,但是找不到对此的引用.我不能成为第一个偶然发现它的人,所以谁对此有更多了解?

问候,
Harm

解决方案

您没有指定正在使用的语言,但从上面的内容我认为它是C#.我刚刚在Wndows 7上尝试过,它可以正常工作,第一个参数是"-l".我只能假设是其他原因导致了您的系统上的问题.


如果是这样,您无能为力,只能检查程序使用的是什么操作系统.

我不知道是否还有其他选择.如果是这样,我一定很想看看.

:)


Hello all,

I still use console programs that I develop under Microsoft Visual Studio 2008. I recently changed to Windows 7 and I found that when you use the following Main call:

public static void Main(string[] args)
{
}


And you issue the command

C:>myprog -l


For Windows XP args[0] will give the first parameter "-l", while in Windows 7 I see the program name myprog in args[0]. I have searched the questions here at the code project but I could find no reference to this. I cannot be the first one to stumble on this, so who knows more about it?

Regards,
Harm

解决方案

You do not specify which language you are using but I assume from the above that it is C#. I have just tried this on Wndows 7 and it works correctly, the first parameter is "-l". I can only assume something else is causing this on your system.


If this is so, there is nothing you can do rather than check what Operating system the program is using.

I dont know if there is any other option to this. If so, I would definitely like to see.

:)


这篇关于Windows XP和Windows 7中的命令行参数不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆