winmain中的命令行选项与__argv [英] command line options in winmain with __argv

查看:121
本文介绍了winmain中的命令行选项与__argv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将winmain命令行上的内容与if语句进行比较。我收到一个beginers错误,但我没有一个例子可以用来修复它..无法转换为''const int''to''char *''在这一行if(__argv [1] =''file''){};

我很遗憾这个错误,任何帮助都会被破坏

I want to compare what I get on the command line in winmain with an if statement.. I am getting a beginers error but I don''t have an example to use to fix it.. cannot convert from ''const int'' to ''char *'' in this line if (__argv[1] = ''file''){};
I am very lost with this error and any help would be apreaceated

展开 | 选择 < span class =codeDivider> | Wrap | 行号

推荐答案

WinMain()不是main()。


Windows程序和论证中没有命令行必须使用 GetCommandLine()<获取命令行中的nts / a>。


所有argc argv内容仅适用于本地语言控制台应用程序。
WinMain() is not main().

There is no command line in a Windows program and the arguments on the command line have to be fetched using GetCommandLine().

All that argc argv stuff is for native language console applications only.


它似乎编译正常,其中一个if我的工作就是当我寻找一个字符串而不是它抱怨的字符时..是否有一个例子,在另一个地方,我比较我得到的命令???我看到了但不明白如何使用它(没有好例子)
It seems to compile fine and one of the if''s is working it is when I look for a string instead of a charecter it complains.. is there an example of the other somewhere where I compare what I get with your command??? I saw that but didn''t understand how to use it (no good examples)


您可能需要发布修改后的代码。


GetCommandLine()返回一个LPTSTR,如果您使用的是ASCII,则为char *;如果您使用的是Unicode,则为wchar_t *。


已为Unicode重写了各种C函数。如果您的peoject设置为ASCII,则需要ANSI C版本,而对于Unicode,则需要ANSI C宽字符版本。您可以使用TCHAR映射在这两者之间切换(请阅读此内容)。


函数映射是
http://msdn2.microsoft.com/en-us/library/ms860358.aspx
You may need to post your revised code.

GetCommandLine() returns an LPTSTR, which is a char* if you are using ASCII and a wchar_t* if you are using Unicode.

Various C functions have been rewritten for Unicode. When you have your peoject set for ASCII you want the ANSI C version and for Unicode you want the ANSI C wide character version. You switch between these two by using the TCHAR mappings (Please read up on this).

The function mappings are http://msdn2.microsoft.com/en-us/library/ms860358.aspx.


这篇关于winmain中的命令行选项与__argv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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