如何使Visual Studio解决方案从命令行运行?

编程入门 行业动态 更新时间:2024-10-24 02:34:46
本文介绍了如何使Visual Studio解决方案从命令行运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个Visual Studio应用程序,可以从ini文件中读取IP地址和端口号,并在该套接字上发送数据. 我必须从命令行运行该程序.现在,我打开Visual Studio并通过单击debug运行该程序.如何从命令行运行该程序. 我如何将解决方案转换为命令行?

I have an visual studio application that reads the ip address and port no from an ini file and send the data on that socket. I have to run the program from command line.Right now i open the visual studio and run the program by clicking on debug.How to run the program from command line. How do i convert the solution into the command line?

推荐答案

只需打开控制台"Cmd.exe"并导航至您的输出文件夹.在那里启动exe.因此,如果您的exe文件名为"Test.exe"并且位于C:\ Temp中,则只需执行 Just open the console "Cmd.exe" and navigate to your output folder. There just start the exe. So, if your exe is called "Test.exe" and lies in C:\Temp, just execute C:\Temp\Test.exe

您需要使用 Environment GetCommandLineArgs 函数来访问参数.您需要检查应用程序的入口点.在那里,您需要获取并处理您的参数. 如果缺少参数,还需要指定适当的异常或其他消息. 像这样 Hi, You need to use Environment GetCommandLineArgs function to access your parameters. you need to check what is the entry point of your application. there you need to get and process your parameters. You also need to specify appropriate exception or further message if parameter are missing. Something like, using namespace System; int main() { Console::WriteLine(); // Invoke this sample with an arbitrary set of command line arguments. array<String^>^arguments = Environment::GetCommandLineArgs(); Console::WriteLine( "GetCommandLineArgs: {0}", String::Join( ", ", arguments ) ); }

(来自MSDN的代码) 希望这对您有用, 谢谢 -Amit Gajjar

(Code from MSDN) Hope this works for you, Thanks -Amit Gajjar

更多推荐

如何使Visual Studio解决方案从命令行运行?

本文发布于:2023-11-14 19:18:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1588311.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:命令行   解决方案   Visual   Studio

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!