使用 ATL 的参数类型
我正在尝试使用 ATL 创建一个非托管 COM dll,它镜像我之前创建的 C# dll。然而,当我向接口添加方法时,我遇到了一个问题,并且无法找到解决方案。为了说明这一点,我将包括用 C# 编写的接口:
public unsafe interface IUserIDA
{
[DispId(1)]
void SwitchCriteria(ref double intensity, ref double minMass, ref double maxMass, ref bool selectIntensity, ref long numOfDepCycles);
[DispId(2)]
void ChargeStateParam(ref short minCharge, ref short maxCharge, ref bool doChargeState);
[DispId(3)]
void InclusionList(ref double intensity, ref double theList, ref short numOfItems);
[DispId(4)]
void ExclusionList(ref long exRTWindow, ref double theMassList, ref long theRTList, ref short numOfItems);
[DispId(5)]
void OtherCriteria(ref long smartFilterTime, ref double isoExclusionWin, ref double massTolerance, ref bool isPPM);
[DispId(6)]
void IsotopeMatchParam(ref double theMassList, ref double theAbundanceList, ref short numOfItems, ref double abTolerance, ref double maTolerance);
[DispId(7)]
void InitIDA();
[DispId(8)]
void SurveySpec();
[DispId(9)]
void NextScan(double* selectedMasses, double* SelectedIntensities, long* selectedCharges, int itemCount);
}
当我尝试在我的 ATL 项目(使用 Visual Studio 2008)中重现此内容时,我发现许多数据类型未列出:布尔类型和整数类型。应该使用什么类型?
I am trying to create an unmanaged COM dll using ATL that mirrors a C# dll I previously created. However, when I was adding methods to the interface I came across a problem and have not been able to find a solution. To illustrate I will include the interface written in C#:
public unsafe interface IUserIDA
{
[DispId(1)]
void SwitchCriteria(ref double intensity, ref double minMass, ref double maxMass, ref bool selectIntensity, ref long numOfDepCycles);
[DispId(2)]
void ChargeStateParam(ref short minCharge, ref short maxCharge, ref bool doChargeState);
[DispId(3)]
void InclusionList(ref double intensity, ref double theList, ref short numOfItems);
[DispId(4)]
void ExclusionList(ref long exRTWindow, ref double theMassList, ref long theRTList, ref short numOfItems);
[DispId(5)]
void OtherCriteria(ref long smartFilterTime, ref double isoExclusionWin, ref double massTolerance, ref bool isPPM);
[DispId(6)]
void IsotopeMatchParam(ref double theMassList, ref double theAbundanceList, ref short numOfItems, ref double abTolerance, ref double maTolerance);
[DispId(7)]
void InitIDA();
[DispId(8)]
void SurveySpec();
[DispId(9)]
void NextScan(double* selectedMasses, double* SelectedIntensities, long* selectedCharges, int itemCount);
}
When I tried to reproduce this in my ATL project (using visual studio 2008) I found that a number of the data types were not listed: boolean and integer types. What type should be used?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
C# 中的 boolean 确实是 C++ 中的 bool,你可以这样做。但是,在标准 COM 接口中,您应该使用 BOOL 或 LONG。
整数也是如此。使用长。
@Travis 给了你一个很好的建议。在 Visual Studio 中,打开“类视图”窗口(从“视图”菜单),右键单击您的接口,然后选择“添加”,然后选择“添加方法”或“添加属性”。这将打开一个漂亮的 UI,它将指导您完成 COM 接口的定义。
boolean in c# is indeed bool in C++, and you could go that way. However, in standard COM interfaces you should use BOOL or LONG.
Ditto for integers. Use LONG.
@Travis gave you a good advise. In Visual Studio, open the 'Class View' window (from 'View' menu), right click on your interface, and select Add, and then 'Add Method' or 'Add Property'. That will open a nice UI which will guide you through the definition of the COM interface.