Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to register WindowsApp runtime classes? #294

Open
oldoldman opened this issue Apr 26, 2023 · 0 comments
Open

how to register WindowsApp runtime classes? #294

oldoldman opened this issue Apr 26, 2023 · 0 comments

Comments

@oldoldman
Copy link

oldoldman commented Apr 26, 2023

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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant