问题描述
我想更改我的命令行参数,然后调试我的可执行文件。
I want to change my command-line arguments and then debug my executable.
使用默认的Visual Studio UI,这需要我几个曲折的鼠标和键盘操作:
With the default Visual Studio UI, this takes me several tortuous mouse and keyboard actions:
有一种方法可使此常用操作与其他常见操作一样简单例如,搜索所有文件的模式:
Is there a way to make this common action as easy as other common operations, for example, searching all files for a pattern which goes:
例如,是否有一种方法来创建自定义编辑框以允许快速访问调试命令行参数?或者有一个键绑定的方式弹出一个简单的调试对话框,其中args可以输入和调试直接开始?例如
For example, is there an way to create a custom edit box to allow quick access to the debug command-line arguments? Or a way to have a key-binding pop up a simple "debug dialog" where the args can be entered and debugging started directly? e.g.
我使用C ++和Visual Studio 2010 Express。谢谢!
I am using C++ and Visual Studio 2010 Express. Thanks!
推荐答案
下面的宏应该会有帮助。打开工具 - >宏 - >宏资源管理器,然后创建新模块,编辑它,并复制粘贴代码下面。必需的命令是SetCommandArgsProperty。 UI不好,但它工作(VS 2005,我希望这也将工作在VS 2010)。
Macro below should help. Open "Tools->Macros->Macro Explorer", then create new module, edit it, and copy-paste code below. Required command is SetCommandArgsProperty. UI is not nice, but it works (VS 2005, I hope this will also work in VS 2010). Then add any shortcut you like to run this macro.
以下是一些详细信息:
- 查找启动项目
- 选择活动配置并查找名称为CommandArguments的属性
- 使用当前值创建编辑框
-
如果选择确定,请更新属性
- Find startup project
- Select it active configuration and find property with name "CommandArguments"
- Create edit box with the current value in it
Update property if OK is selected
Sub SetCommandArgsProperty()
Dim newVal As Object
newVal = InputValue(GetCommandArgsPropertyValue())
If TypeOf newVal Is String Then
SetCommandArgsProperty(newVal)
End If
End Sub
Function InputValue(ByVal defaultText As String)
Dim frm As New System.Windows.Forms.Form
Dim btn As New System.Windows.Forms.Button
Dim edit As New System.Windows.Forms.TextBox
edit.Text = defaultText
edit.Width = 100
btn.Text = "OK"
btn.DialogResult = System.Windows.Forms.DialogResult.OK
frm.Text = "Input command line properties"
frm.Controls.Add(btn)
btn.Dock = System.Windows.Forms.DockStyle.Bottom
frm.Controls.Add(edit)
edit.Dock = System.Windows.Forms.DockStyle.Top
frm.Height = 80
frm.Width = 300
If frm.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
Return edit.Text
End If
Return System.DBNull.Value
End Function
Function GetCommandArgsProperty() As EnvDTE.Property
Dim solution As Solution
Dim project As Project
Dim sb As SolutionBuild
Dim str As String
Dim cm As ConfigurationManager
Dim config As Configuration
Dim properties As Properties
Dim prop As EnvDTE.Property
solution = DTE.Solution
sb = solution.SolutionBuild
For Each str In sb.StartupProjects
project = solution.Item(str)
cm = project.ConfigurationManager
config = cm.ActiveConfiguration
properties = config.Properties
For Each prop In properties
If prop.Name = "CommandArguments" Then
Return prop
End If
Next
Next
End Function
Function GetCommandArgsPropertyValue()
Return GetCommandArgsProperty().Value
End Function
Sub SetCommandArgsProperty(ByVal value As String)
GetCommandArgsProperty().Value = value
End Sub
这篇关于快速输入命令行参数为Visual Studio调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!