Skip to content

Instantly share code, notes, and snippets.

@socantre
Created April 14, 2015 14:15
Show Gist options
  • Save socantre/111644880358c39b4998 to your computer and use it in GitHub Desktop.
Save socantre/111644880358c39b4998 to your computer and use it in GitHub Desktop.
small example using windows runtime library in iso c++
//#include <windows.web.http.h>
#include <windows.foundation.h> // ABI::Windows::Foundation::I*
#include <wrl/wrappers/corewrappers.h> //Microsoft::WRL::Wrappers
#include <wrl/client.h> // ComPtr
#include <stdexcept>
int main() {
Microsoft::WRL::Wrappers::RoInitializeWrapper initialize(RO_INIT_MULTITHREADED);
if (FAILED(initialize)) {
throw std::runtime_error("Unable to initialize Windows Runtime.");
}
Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IUriRuntimeClassFactory> uriFactory;
HRESULT hr = ABI::Windows::Foundation::GetActivationFactory(Microsoft::WRL::Wrappers::HStringReference(RuntimeClass_Windows_Foundation_Uri).Get(), &uriFactory);
if (FAILED(hr)) {
throw std::runtime_error("Unable to get activation factory for uri factory.");
}
Microsoft::WRL::Wrappers::HString uriHString;
hr = uriHString.Set(L"http://www.microsoft.com.");
if (FAILED(hr)) {
throw std::runtime_error("Unable to set uri string.");
}
Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IUriRuntimeClass> uri;
hr = uriFactory->CreateUri(uriHString.Get(), &uri);
if (FAILED(hr)) {
throw std::runtime_error("Unable to create uri.");
}
//auto client = ABI::Windows::Web::Http::HttpClient();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment