Visual Studio 2008项目系统属性中的宏

来源:互联网 发布:招聘java工程师的要求 编辑:程序博客网 时间:2024/04/29 07:03

Visual Studio 2008

其他版本

更新:2007 年 11 月

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


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

  • 任何界面(VCPlatform、VCProject、VCFile、VCFilter、VCConfiguration、VCFileConfiguration)上的 Name 属性。

  • 任何界面(VCProjectItem 以及所有派生界面)上的 ItemName 属性。

  • 任何界面(VCProjectItem 以及所有派生界面)上的 Kind 属性。

  • 任何界面(VCCLCompilerTool、VCResourceCompilerTool、VCMidlTool)上的 FullIncludePath 属性。

  • 任何界面(所有工具)上的 ToolName 属性。

  • 任何界面(所有工具)上的 ToolPath 属性。

  • VCProject 界面的 ProjectDirectory 和 ProjectFile 属性。

  • VCFile 界面的 Extension 属性。

  • VCFilter 界面的 UniqueIdentifier、CanonicalName 和 Filter 属性。

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

  • VCFileConfiguration

  • VCConfiguration

  • VCPlatform

  • VCProjectEngine

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

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

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

  • 文件位于 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 的位置

环境宏

根据环境

根据环境

根据环境

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