【问题标题】:Static link to ATL always fails到 ATL 的静态链接总是失败
【发布时间】:2012-12-19 16:26:31
【问题描述】:

我使用一些 ATL 函数来创建一个媒体控件,但似乎我只能使用动态链接到 ATL 选项。当我切换到 ATL 的静态链接时,我无法成功创建控件。

我很困惑。谁能帮帮我?

这是我的代码:

//related headers
#include <wmp.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlhost.h>
#include <atlctl.h>

//related vars
CAxWindow  m_wndView;  // ActiveX host window class.    CComPtr<IWMPPlayer>  
m_spWMPPlayer;  // Smart pointer to IWMPPlayer interface.

//related function code:
CComPtr<IAxWinHostWindow>  spHost;
HRESULT  hr;
m_wndView.Create(m_hWnd, rect, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
hr = m_wndView.QueryHost(&spHost);
/*
when I switch to "Static Link to ATL" option, I will fail here
E_FAIL == hr;//the failure flag
*/
if(!SUCCEEDED(hr)) return FALSE;

hr = spHost->CreateControl(CComBSTR(_T("{6BF52A52-394A-11d3-B153-00C04F79FAA6}")), m_wndView, 0);
if(!SUCCEEDED(hr)) return FALSE;

hr = m_wndView.QueryControl(&m_spWMPPlayer);
if(!SUCCEEDED(hr)) return FALSE;

【问题讨论】:

  • S_FAIL == hr;//失败标志
  • 没有S_FAIL 这样的东西。可能是E_FAIL

标签: c++ visual-studio-2010 com mfc atl


【解决方案1】:

当静态链接到 ATL 时,你必须使用预处理器:_ATL_DLL,

您可以在此处进行设置:属性页 | C/C++ |预处理器

【讨论】:

    猜你喜欢
    • 2020-11-27
    • 1970-01-01
    • 2014-03-24
    • 2010-09-19
    • 1970-01-01
    • 2019-09-17
    • 1970-01-01
    • 2017-11-05
    相关资源
    最近更新 更多