本文介绍了用代码创建属性表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我们正在尝试以编程方式"模仿添加属性表时,属性管理器对项目执行的操作.到目前为止,我在创建属性表并将其添加到"InheritedPropertSheet"对话框时遇到了麻烦.

我的第一个想法是将所有配置与VCProject相关联,创建一个属性表,并将其与项目中的每个配置相关联.但是由于我未知的原因,它不起作用.

这是我使用的代码示例:

Hi,

    We are trying to emulate "programmatically" what the property manager does to a project when you add a property sheet. So far, i'm having trouble creating a property sheet and adding it to the "InheritedPropertSheet" of a configuration.

My first idea was to get all the configuration associtated with a VCProject, create a property sheet and associate it with every config in the project. But for reasons unknown to me, it doesn't work. 

Here's a sample of the code I use:

IVCCollection ?? ivc;
VCProject \ vcProj ==(VCProject)prj.Object; //prj是vcproject
//获取项目的配置并创建其中一个属性表
ivc =((IVCCollection)vcProj.Configuration;
VCConfiguration vcConfig =(VCConfiguration)ivc.Item(1);
VCPropertySheet道具=(VCPropertySheet)((VCProjectEngine)vcConfig.VCProjectEngine).CreatePropertySheet(" ProcRunnerSheet' );
//对于项目中的所有配置,关联创建的属性表(props)
用于 (( int i = 1; i< = ivc.count; i ++)
{
vcConfig =(VCConfiguration)ivc.Item(i);
vcConfig.InheritedPropertySheets = props.Name;
}
IVCCollection ivc;  
 
VCProject vcProj = (VCProject)prj.Object; //prj IS a vcproject  
 
//Get the configurations for the project and create a Property Sheet with one of them  
ivc = (IVCCollection)vcProj.Configuration;  
VCConfiguration vcConfig = (VCConfiguration)ivc.Item(1);  
VCPropertySheet props = (VCPropertySheet)((VCProjectEngine)vcConfig.VCProjectEngine).CreatePropertySheet("ProcRunnerSheet");  
 
//For all the configuration in the project, associate the created property sheet(props)  
for (int i = 1; i <= ivc.count; i++)  
{  
  vcConfig = (VCConfiguration)ivc.Item(i);  
  vcConfig.InheritedPropertySheets = props.Name;  

推荐答案


这篇关于用代码创建属性表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 09:05