无法向 MFC ActiveX 添加函数

Can't add function to MFC ActiveX

本文关键字:添加 函数 ActiveX MFC      更新时间:2023-10-16

I'正在尝试使用Visual Studio 2010 c++mfc库创建ActiveX组件mfc_ActiveX。向导完成后,系统编译无错误。

用鼠标右键点击Cmfc_activeXCtrl Add>>添加函数并填写参数表,添加了简单的新方法后,我得到了简单的函数:

int Cmfc_activeXCtrl::Hello(int i)
 {
 return 0;
 }

经过这个过程后,我再也无法编译代码了。我有消息:

Error   85  error MSB8011: Failed to register output. Please try enabling Per-user Redirection or register the component from a command prompt with elevated permissions.   C:Program Files (x86)MSBuildMicrosoft.Cppv4.0Microsoft.CppCommon.targets   744 6   mfc_activeX

86  IntelliSense: #error directive: Please use the /MD switch for _AFXDLL builds    c:program files (x86)microsoft visual studio 10.0vcatlmfcincludeafxver_.h 81  3   

如何避免这些错误?

Visual Studio的运行用户没有运行regsvr32的权限,该用户会在成功生成后尝试注册组件。

您可以通过以管理员身份运行Visual Studio来解决此问题。

关于第二个错误

#错误请使用/MD开关进行_AFXDLL构建

事实上,我不得不切换到另一个/Mx设置,然后切换回来,所以选择是粗体的,IDE似乎没有正确更新。