1
我正在嘗試一些VS2005 IDE宏來修改解決方案中的大量項目(〜80)。我希望設置的一些屬性會將程序化界面暴露給「默認」,但其他許多屬性卻不會。有沒有一種通用的方法來將這些屬性設置爲默認值? (最終意味着從.vcproj文件進行刪除)將VCProject屬性設置爲默認值
簡單的例子,設置一些隨機屬性:
Sub SetSomeProps()
Dim prj As VCProject
Dim cfg As VCConfiguration
Dim toolCompiler As VCCLCompilerTool
Dim toolLinker As VCLinkerTool
Dim EnvPrj As EnvDTE.Project
For Each EnvPrj In DTE.Solution.Projects
prj = EnvPrj.Object
cfg = prj.Configurations.Item(1)
toolLinker = cfg.Tools("VCLinkerTool")
If toolLinker IsNot Nothing Then
' Some tool props that expose a *default* interface'
toolLinker.EnableCOMDATFolding = optFoldingType.optFoldingDefault
toolLinker.OptimizeReferences = optRefType.optReferencesDefault
toolLinker.OptimizeForWindows98 = optWin98Type.optWin98Default
End If
toolCompiler = cfg.Tools("VCCLCompilerTool")
If toolCompiler IsNot Nothing Then
' How to set it to default? (*erase* the property from the .vcproj)'
toolCompiler.CallingConvention = callingConventionOption.callConventionCDecl
toolCompiler.WholeProgramOptimization = False
toolCompiler.Detect64BitPortabilityProblems = False
End If
Next
End Sub
任何意見,將不勝感激。
對於VS2010,[此論壇帖子](http://social.msdn.microsoft.com/Forums/en-IE/vsx/thread/8dff2053-432f-4bdd-b668-3c88960e1409)建議您可以投射工具對象添加到新的[IVCRulePropertyStorage](http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.vcprojectengine.ivcrulepropertystorage.aspx)接口,然後使用其DeleteProperty方法擺脫該屬性。儘管如此,我還是無法自己嘗試。 – 2013-01-22 23:41:08