项目系统属性中的宏

Visual Studio 2013 中已弃用 Visual Studio 的外接程序。 你应该升级外接程序到 VS 的扩展包。 有关升级的更多信息,请参见 。常见问题:将外接程序转换为 VSPackage 扩展

本节讨论如何通过脚本和外接程序使用 Visual C++ 项目系统中的对象模型。

宏几乎可以存在于您从对象模型中的任何对象获得的任何字符串属性中。 以下为此规则的例外情况:

当属性返回的值可能包含宏时,请使用范围最适合的属性容器确定它的值。 属性容器按范围由窄到宽的顺序排列如下:

对于有关文件配置的文件或工具,属性容器将是所需配置的 VCFileConfiguration 对象。 对于项目,属性容器应是所需配置的 VCConfiguration 对象。 请使用范围最窄的属性容器的对象,因为所用对象的范围越宽,可以正确扩展的宏就越少。

换句话说,当您从 VCFileConfiguration 移到 VCConfiguration 对象求值时,就会失去所有 $(Input*) 宏的上下文。 当您从 VCConfiguration 移到 VCProjectEngineVCPlatform 对象时,对于不在系统级内的宏就会失去上下文。

下表中的示例演示如何对各种上下文中的宏求值。 当,

  • 文件位于 c:\myidls\stuff.idl 中时

  • 项目位于 c:\Soln\Proj\Proj.vcproj 中时

  • 解决方案位于 c:\Soln\Soln.sln 中时

  • 平台为 Win32 时

  • 中间目录为 DebugInt 时

  • 输出目录为 c:\MyOutputs 时

  • 调试配置时

  • 输出名称为 Game.exe 时

文件配置   

ProjectConfig

VCProjectEngine 和 VCPlatform

InputDir

c:\myidls\

c:\Soln\Proj

不适用

InputName

stuff

Proj

不适用

InputPath

c:\myidls\stuff.idl

c:\Soln\Proj\Proj.vcproj

不适用

InputFileName

stuff.idl

Proj.vcproj

不适用

InputExt

.idl

.vcproj

不适用

IntDir

DebugInt

DebugInt

不适用

OutDir

c:\MyOutputs

c:\MyOutputs

不适用

ProjectDir

c:\Soln\Proj\

c:\Soln\Proj\

不适用

ProjectName

Proj

Proj

不适用

ProjectExt

.vcproj

.vcproj

不适用

TargetDir

c:\MyOutputs\

c:\MyOutputs\

不适用

TargetPath

c:\MyOutputs\Game.exe

c:\MyOutputs\Game.exe

不适用

TargetName

Game

Game

不适用

TargetFileName

Game.exe

Game.exe

不适用

TargetExt

.exe

.exe

不适用

ConfigurationName

调试

调试

不适用

RemoteMachine

在项目级别设置

在项目级别设置

不适用

PlatformName

Win32

Win32

不适用

SolutionDir

c:\Soln

c:\Soln

c:\Soln

SolutionName

Soln

Soln

Soln

SolutionPath

c:\Soln\Soln.sln

c:\Soln\Soln.sln

c:\Soln\Soln.sln

SolutionFileName

Soln.sln

Soln.sln

Soln.sln

SolutionExt

.sln

.sln

.sln

VCInstallDir

<<VC install dir>>\

<<VC install dir>>\

<<VC install dir>>\

VSInstallDir

<<VC install dir>>\

<<VC install dir>>\

<<VC install dir>>\

FrameworkDir

<<COM+ dir>>\

<<COM+ dir>>\

<<COM+ dir>>\

FrameworkVersion

开发环境使用的公共语言运行时版本

开发环境使用的公共语言运行时版本

开发环境使用的公共语言运行时版本

DevEnvDir

devenv.exe 的位置

devenv.exe 的位置

devenv.exe 的位置

环境宏

根据环境

根据环境

根据环境

请注意,您为计算器的源选择的内容会显著改变求值方式,尤其是与文件名密切相关的项。

请参见

其他资源

Visual C++ 扩展性对象模型