Начиная с Windows 10, версия 1903, добавлена поддержка неупакованных настольных приложений для использования пользовательских компонентов WinRT. См. https://blogs.windows.com/windowsdeveloper/2019/04/30/enhancing-non-packaged-desktop-apps-using-windows-runtime-components/
Существует пример кода C ++, который демонстрирует процедуру: https://github.com/Microsoft/RegFree_WinRT/tree/master/Cpp. Однако в этом образце есть основное приложение win32.
Я попытался добавить файлы NET / WinForms cpp в проект Win32 (включив среду общего языка в Visual Studio для отдельных cpp файлы), и получил "параметры командной строки" clr "и" / await "несовместимы."
Я пытался создать новый проект WinForms, но после этого я не могу понять, как связать объекты WinRT. Я получаю:
1>------ Build started: Project: VideoRecorder, Configuration: Release x64 ------
1>MainForm.obj : MSIL module encountered; incremental linking is disabled for MSIL; performing full link
1>WinRTWrapper.obj : error LNK2028: unresolved token (0A005B23) "extern "C" int __cdecl WINRT_GetRestrictedErrorInfo(void * *)" (?WINRT_GetRestrictedErrorInfo@@$$J0YAHPEAPEAX@Z) referenced in function "private: void __cdecl winrt::hresult_error::originate(struct winrt::hresult,void *)" (?originate@hresult_error@winrt@@$$FAEAAXUhresult@2@PEAX@Z)
1>WinRTWrapper.obj : error LNK2028: unresolved token (0A005B49) "extern "C" int __cdecl WINRT_RoOriginateLanguageException(int,void *,void *)" (?WINRT_RoOriginateLanguageException@@$$J0YAHHPEAX0@Z) referenced in function "private: void __cdecl winrt::hresult_error::originate(struct winrt::hresult,void *)" (?originate@hresult_error@winrt@@$$FAEAAXUhresult@2@PEAX@Z)
1>WinRTWrapper.obj : error LNK2028: unresolved token (0A005B65) "extern "C" int __cdecl MessageBoxW(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBoxW@@$$J0YAHPEAUHWND__@@PEB_W1I@Z) referenced in function "extern "C" int __cdecl wWinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,wchar_t *,int)" (?wWinMain@@$$J0YAHPEAUHINSTANCE__@@0PEA_WH@Z)
1>WinRTWrapper.obj : error LNK2028: unresolved token (0A005BEA) "extern "C" int __cdecl WINRT_WindowsDuplicateString(void *,void * *)" (?WINRT_WindowsDuplicateString@@$$J0YAHPEAXPEAPEAX@Z) referenced in function "void * __cdecl winrt::impl::duplicate_string(void *)" (?duplicate_string@impl@winrt@@$$FYAPEAXPEAX@Z)
1>WinRTWrapper.obj : error LNK2028: unresolved token (0A005BFB) "extern "C" int __cdecl WINRT_WindowsDeleteString(void *)" (?WINRT_WindowsDeleteString@@$$J0YAHPEAX@Z) referenced in function "public: static void __cdecl winrt::impl::hstring_traits::close(void *)" (?close@hstring_traits@impl@winrt@@$$FSAXPEAX@Z)
1>WinRTWrapper.obj : error LNK2028: unresolved token (0A005C4C) "public: __cdecl winrt::WinRTComponent::Class::Class(void)" (??0Class@WinRTComponent@winrt@@$$FQEAA@XZ) referenced in function "extern "C" int __cdecl wWinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,wchar_t *,int)" (?wWinMain@@$$J0YAHPEAUHINSTANCE__@@0PEA_WH@Z)
1>WinRTWrapper.obj : error LNK2028: unresolved token (0A0063E4) "extern "C" int __cdecl WINRT_RoInitialize(unsigned int)" (?WINRT_RoInitialize@@$$J0YAHI@Z) referenced in function "void __cdecl winrt::init_apartment(enum winrt::apartment_type)" (?init_apartment@winrt@@$$FYAXW4apartment_type@1@@Z)
1>WinRTWrapper.obj : error LNK2028: unresolved token (0A00642E) "extern "C" void __cdecl WINRT_SysFreeString(wchar_t *)" (?WINRT_SysFreeString@@$$J0YAXPEA_W@Z) referenced in function "public: static void __cdecl winrt::impl::bstr_traits::close(wchar_t *)" (?close@bstr_traits@impl@winrt@@$$FSAXPEA_W@Z)
1>WinRTWrapper.obj : error LNK2028: unresolved token (0A006472) "extern "C" struct HWND__ * __cdecl GetDesktopWindow(void)" (?GetDesktopWindow@@$$J0YAPEAUHWND__@@XZ) referenced in function "extern "C" int __cdecl wWinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,wchar_t *,int)" (?wWinMain@@$$J0YAHPEAUHINSTANCE__@@0PEA_WH@Z)
1>WinRTWrapper.obj : error LNK2028: unresolved token (0A006497) "extern "C" wchar_t const * __cdecl WINRT_WindowsGetStringRawBuffer(void *,unsigned int *)" (?WINRT_WindowsGetStringRawBuffer@@$$J0YAPEB_WPEAXPEAI@Z) referenced in function "public: wchar_t const * __cdecl winrt::hstring::begin(void)const " (?begin@hstring@winrt@@$$FQEBAPEB_WXZ)
1>WinRTWrapper.obj : error LNK2019: unresolved external symbol "extern "C" int __cdecl WINRT_WindowsDeleteString(void *)" (?WINRT_WindowsDeleteString@@$$J0YAHPEAX@Z) referenced in function "public: static void __cdecl winrt::impl::hstring_traits::close(void *)" (?close@hstring_traits@impl@winrt@@$$FSAXPEAX@Z)
1>WinRTWrapper.obj : error LNK2019: unresolved external symbol "extern "C" void __cdecl WINRT_SysFreeString(wchar_t *)" (?WINRT_SysFreeString@@$$J0YAXPEA_W@Z) referenced in function "public: static void __cdecl winrt::impl::bstr_traits::close(wchar_t *)" (?close@bstr_traits@impl@winrt@@$$FSAXPEA_W@Z)
1>WinRTWrapper.obj : error LNK2019: unresolved external symbol "extern "C" wchar_t const * __cdecl WINRT_WindowsGetStringRawBuffer(void *,unsigned int *)" (?WINRT_WindowsGetStringRawBuffer@@$$J0YAPEB_WPEAXPEAI@Z) referenced in function "public: wchar_t const * __cdecl winrt::hstring::begin(void)const " (?begin@hstring@winrt@@$$FQEBAPEB_WXZ)
1>WinRTWrapper.obj : error LNK2019: unresolved external symbol "extern "C" int __cdecl WINRT_RoOriginateLanguageException(int,void *,void *)" (?WINRT_RoOriginateLanguageException@@$$J0YAHHPEAX0@Z) referenced in function "private: void __cdecl winrt::hresult_error::originate(struct winrt::hresult,void *)" (?originate@hresult_error@winrt@@$$FAEAAXUhresult@2@PEAX@Z)
1>WinRTWrapper.obj : error LNK2019: unresolved external symbol "extern "C" int __cdecl WINRT_GetRestrictedErrorInfo(void * *)" (?WINRT_GetRestrictedErrorInfo@@$$J0YAHPEAPEAX@Z) referenced in function "private: void __cdecl winrt::hresult_error::originate(struct winrt::hresult,void *)" (?originate@hresult_error@winrt@@$$FAEAAXUhresult@2@PEAX@Z)
1>WinRTWrapper.obj : error LNK2019: unresolved external symbol "extern "C" int __cdecl WINRT_RoInitialize(unsigned int)" (?WINRT_RoInitialize@@$$J0YAHI@Z) referenced in function "void __cdecl winrt::init_apartment(enum winrt::apartment_type)" (?init_apartment@winrt@@$$FYAXW4apartment_type@1@@Z)
1>WinRTWrapper.obj : error LNK2019: unresolved external symbol "extern "C" int __cdecl WINRT_WindowsDuplicateString(void *,void * *)" (?WINRT_WindowsDuplicateString@@$$J0YAHPEAXPEAPEAX@Z) referenced in function "void * __cdecl winrt::impl::duplicate_string(void *)" (?duplicate_string@impl@winrt@@$$FYAPEAXPEAX@Z)
1>WinRTWrapper.obj : error LNK2019: unresolved external symbol "public: __cdecl winrt::WinRTComponent::Class::Class(void)" (??0Class@WinRTComponent@winrt@@$$FQEAA@XZ) referenced in function "extern "C" int __cdecl wWinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,wchar_t *,int)" (?wWinMain@@$$J0YAHPEAUHINSTANCE__@@0PEA_WH@Z)
1>WinRTWrapper.obj : error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __cdecl GetDesktopWindow(void)" (?GetDesktopWindow@@$$J0YAPEAUHWND__@@XZ) referenced in function "extern "C" int __cdecl wWinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,wchar_t *,int)" (?wWinMain@@$$J0YAHPEAUHINSTANCE__@@0PEA_WH@Z)
1>WinRTWrapper.obj : error LNK2019: unresolved external symbol "extern "C" int __cdecl MessageBoxW(struct HWND__ *,wchar_t const *,wchar_t const *,unsigned int)" (?MessageBoxW@@$$J0YAHPEAUHWND__@@PEB_W1I@Z) referenced in function "extern "C" int __cdecl wWinMain(struct HINSTANCE__ *,struct HINSTANCE__ *,wchar_t *,int)" (?wWinMain@@$$J0YAHPEAUHINSTANCE__@@0PEA_WH@Z)
1>C:\Users\mgrivich\Downloads\RegFree_WinRT-master\RegFree_WinRT-master\Cpp\x64\Release\VideoRecorder.exe : fatal error LNK1120: 20 unresolved externals
1>Done building project "VideoRecorder.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Также не ясно, как добавить манифест, чтобы я мог запросить разрешение на запись видео.