diff options
| author | Luke <[email protected]> | 2017-11-28 00:22:11 -0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-11-28 00:22:11 -0800 |
| commit | 79bbbca2f6e37d94fbbbd60d12c5c1e7dde650da (patch) | |
| tree | 793ff943b8b641f95d05401156badd42da4a0f12 /general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/pch.cpp | |
| parent | ed1df9a8b80b154b71b79635e40af75f4f19001c (diff) | |
| parent | 2817004092cee784d4aaf36c045fdb5b0bc09f7e (diff) | |
Merge pull request #1 from Microsoft/master
Updating Local
Diffstat (limited to 'general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/pch.cpp')
| -rw-r--r-- | general/WinHEC 2017 Lab/Toaster Support App/App/CustomCapability/cpp/pch.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
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 <robuffer.h> +#include <wrl\client.h> + +using namespace Microsoft::WRL; +using namespace Windows::Storage::Streams; + +byte* GetArrayFromBuffer(Windows::Storage::Streams::IBuffer^ buffer) +{ + ComPtr<IInspectable> base = reinterpret_cast<IInspectable*>(buffer); + ComPtr<IBufferByteAccess> 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); + })); +} |
