WinRT is basically COM, so using WinRT components from C is similar to using COM components from C. As before, you get .idl files for all WinRT components, as well as .h files created from these .idl files. .H files include both C ++ and C declarations (wrapped in #ifdef __cplusplus as needed). You can simply # turn them on and start hacking.
This is not entirely accurate, although, for example, something like this C ++ / CX:
Windows::UI::Xaml::Controls::TextBlock^ tb = ...; tb->Text = "Foo";
which is equivalent to this C ++ vanilla:
Windows::UI::Xaml::Controls::ITextBlock* tb = ...; HSTRING hs; HRESULT hr = WindowsStringCreate(L"Foo", 3, &hs); // check hr for errors hr = tb->set_Text(hs); // check hr for errors tb->Release();
will be written in C as:
__x_Windows_CUI_CXaml_CControls_CITextBlock* tb = ...; HRESULT hr; HSTRING hs; hr = WindowsCreateString(L"Foo", 3, &hs); // check hr for errors hr = __x_Windows_CUI_CXaml_CControls_CITextBlock_put_Text(tb, hs); // check hr for errors IUnknown_Release(tb);
Take a look at "C: \ Program Files (x86) \ Windows Kits \ 8.0 \ Include \ winrt" in the Preview Preview to view the .idl and .h files.
Pavel Minaev Sep 15 '11 at 20:22 2011-09-15 20:22
source share