Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/144.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 到ATL的静态链接总是失败_C++_Visual Studio 2010_Com_Mfc_Atl - Fatal编程技术网

C++ 到ATL的静态链接总是失败

C++ 到ATL的静态链接总是失败,c++,visual-studio-2010,com,mfc,atl,C++,Visual Studio 2010,Com,Mfc,Atl,我使用一些ATL函数来创建媒体控件,但似乎只能使用动态链接到ATL选项。当我切换到ATL的静态链接时,我就是无法成功创建控件 我很困惑。有人能帮我吗 这是我的密码: //related headers #include <wmp.h> #include <atlbase.h> #include <atlcom.h> #include <atlhost.h> #include <atlctl.h> //related vars CAxW

我使用一些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;

当静态链接到ATL时,必须使用预处理器:\u ATL\u DLL


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

S|U FAIL==hr//失败标志着没有失败这回事。可能是你失败了。