2012-06-17 95 views
1

我想将本机sdk移植到Windows RT并帮助我我想实现缺少的函数来模拟注册表访问,所以我创建了一个Static图书馆(文件 - >新建 - >项目...->静态库(Metro风格应用)和我已经宣布这样的功能:我们可以在静态库里使用C++/Cx(Metro风格)

// WinRT stuff 
#include <windows.storage.h> 
#include <wrl/client.h> 
#include <wrl/wrappers/corewrappers.h> 

using namespace Microsoft::WRL; 
using namespace Microsoft::WRL::Wrappers; 
using namespace ABI::Windows::Storage; 
using namespace ABI::Windows::Foundation; 

LSTATUS 
APIENTRY 
RegOpenKeyExW(
    _In_ HKEY hKey, 
    _In_opt_ LPCWSTR lpSubKey, 
    _In_opt_ DWORD ulOptions, 
    _In_ REGSAM samDesired, 
    _Out_ PHKEY phkResult 
    ) 
{ 
    LSTATUS ret = ERROR_SUCCESS; 

    if (hKey == NULL) 
     return ERROR_INVALID_HANDLE; 
    if (phkResult == NULL) 
     return ERROR_INVALID_PARAMETER; 



    ABI::Windows::Storage::ApplicationDataContainer^ localSettings = 
       ApplicationData::Current->LocalSettings; 

... 
} 

然而,当我尝试编译我得到这个错误:

1>c:\users\joe\documents\visual studio 2012\projects\lib1\lib1\oal.cpp(275): 
    error C3699: '^' : cannot use this indirection on type 
    'ABI::Windows::Storage::ApplicationDataContainer' 

我已经检查并且启用了Windows运行时扩展(/ZW)(这是默认情况下)所以我想知道是否可以在静态库中使用C++/CX?

回答

1

如果您在类型上使用ABI前缀,那么您指的是低级C++类型。低级别类型旨在与WRL一起使用,不能像^运算符那样使用C++/CX扩展。

改为使用ComPtr localSettings。

+0

谢谢,但我不想使用WRL,因为它太详细了,我已经使用ComPtr和COM接口。我想要的是使用C++/Cx。 –

+0

那么你不应该使用ABI ::,这仅仅适用于WRL场景。 #include 也是如此 –

0

好的有人告诉我添加在图书馆员 - >一般 - >附加依赖:%(AdditionalDependencies),我已经删除了ABI ::命名空间。现在它的工作;-)

相关问题