From 1a3e88d788fb533d8cbea006e6fb46ff3b16dcec Mon Sep 17 00:00:00 2001 From: Luke Date: Tue, 21 Nov 2017 17:50:07 -0800 Subject: Adding WinHEC Lab Content --- .../App/CustomCapability/cpp/pch.cpp | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/pch.cpp (limited to 'general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/pch.cpp') diff --git a/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/pch.cpp b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/pch.cpp new file mode 100644 index 00000000..b300c4c0 --- /dev/null +++ b/general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/pch.cpp @@ -0,0 +1,60 @@ +//********************************************************* +// +// Copyright (c) Microsoft. All rights reserved. +// This code is licensed under the MIT License (MIT). +// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF +// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY +// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR +// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. +// +//********************************************************* + +// +// pch.cpp +// Include the standard header and generate the precompiled header. +// + +#include "pch.h" +#include "MainPage.xaml.h" + +#include +#include + +using namespace Microsoft::WRL; +using namespace Windows::Storage::Streams; + +byte* GetArrayFromBuffer(Windows::Storage::Streams::IBuffer^ buffer) +{ + ComPtr base = reinterpret_cast(buffer); + ComPtr access; + + auto hr = base.As(&access); + + if (FAILED(hr)) + { + throw Platform::Exception::CreateException(hr); + } + + byte* data; + + hr = access->Buffer(&data); + + if (FAILED(hr)) + { + throw Platform::Exception::CreateException(hr); + } + + // The returned buffer is valid as long as the IBuffer passed in + // remains valid. + return data; +} + +void NotifyStatusMessage(Platform::String^ message, SDKTemplate::NotifyType messageType) +{ + SDKTemplate::MainPage::Current->Dispatcher->RunAsync( + Windows::UI::Core::CoreDispatcherPriority::Normal, + ref new Windows::UI::Core::DispatchedHandler( + [message, messageType]() { + SDKTemplate::MainPage::Current->NotifyUser(message, messageType); + })); +} -- cgit v1.3.1