WindowsAppSDK-Samples
WindowsAppSDK-Samples copied to clipboard
how to register WindowsApp runtime classes?
I have following code, it's the short version of the sample squares, it compiled, but failed with 80040154(REGDB_E_CLASSNOTREG) which means the runtime classes of WindowsApp is not registered. I've installed WindowsAppSDK 1.3 from this link. It seems that the installer did not register it. So, my question is how to register it manually?
#include <winrt/base.h>
#include <winrt/Microsoft.UI.Windowing.h>
#include <winrt/Microsoft.UI.Dispatching.h>
#include <windows.h>
#pragma comment(lib, "windowsapp")
using namespace winrt;
using namespace Microsoft::UI::Windowing;
using namespace Microsoft::UI::Dispatching;
/*
cl /nologo /EHsc /Zi /std:c++latest /Iapiexp/winui3 winui3.cpp /link /subsystem:console /debug
*/
int WinMain(HINSTANCE,HINSTANCE,PSTR,int) {
winrt::init_apartment(winrt::apartment_type::single_threaded);
try {
auto appWindow = AppWindow::Create();
appWindow.Title(L"Squares");
appWindow.Show();
auto ctl = DispatcherQueueController::CreateOnCurrentThread();
auto queue = ctl.DispatcherQueue();
queue.RunEventLoop();
} catch(hresult_error e) {
printf("winui3 0x%x\n",int32_t(e.code()));
}
}
int main() {
return WinMain(nullptr,nullptr,nullptr,0);
}