我想将本机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?
谢谢,但我不想使用WRL,因为它太详细了,我已经使用ComPtr和COM接口。我想要的是使用C++/Cx。 –
那么你不应该使用ABI ::,这仅仅适用于WRL场景。 #include也是如此 –