我正在尝试将原生sdk移植到Windows RT并帮助我,我想实现缺少的函数来模拟注册表访问,所以我创建了一个静态库(File-> New-> Project ... - >静态库(Metro Style应用程序),我已经声明了这样的功能:
// 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?
答案 0 :(得分:1)
如果您在类型上使用ABI前缀,那么您指的是低级C ++类型。低级别类型旨在与WRL一起使用,不能使用像^运算符那样的C ++ / CX扩展。
使用ComPtr localSettings。
答案 1 :(得分:0)
好的,有人告诉我添加In Librarian-&gt; General-&gt; Additional Dependencies:%(Additional Dependencies),我删除了ABI :: namespace。现在它起作用了; - )