ZenLib
OS_Utils.h
Go to the documentation of this file.
1/* Copyright (c) MediaArea.net SARL. All Rights Reserved.
2 *
3 * Use of this source code is governed by a zlib-style license that can
4 * be found in the License.txt file in the root of the source tree.
5 */
6
7//---------------------------------------------------------------------------
8#ifndef ZenOS_UtilsH
9#define ZenOS_UtilsH
10//---------------------------------------------------------------------------
11
12//---------------------------------------------------------------------------
13#include "ZenLib/Ztring.h"
14//---------------------------------------------------------------------------
15
16//---------------------------------------------------------------------------
17#ifdef WINDOWS_UWP
18#include <wrl.h>
19#include <windows.foundation.h>
20#include <windows.storage.h>
21#endif
22//---------------------------------------------------------------------------
23
24namespace ZenLib
25{
26
27//***************************************************************************
28// OS Information
29//***************************************************************************
30
31//---------------------------------------------------------------------------
32bool IsWin9X ();
33// Execute
34//***************************************************************************
35
36void Shell_Execute(const Ztring &ToExecute);
37
38//***************************************************************************
39// Directorues
40//***************************************************************************
41
42Ztring OpenFolder_Show(void* Handle, const Ztring &Title, const Ztring &Caption);
43
44//***************************************************************************
45// WinRT Helpers
46//***************************************************************************
47#ifdef WINDOWS_UWP
48template <typename T>
49inline HRESULT Await(const Microsoft::WRL::ComPtr<T> &Operation)
50{
51 if (!Operation)
52 return E_POINTER;
53
54 Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IAsyncInfo> Info;
55 HRESULT Result=Operation.As(&Info);
56 if (FAILED(Result))
57 return Result;
58
59 ABI::Windows::Foundation::AsyncStatus Status;
60 while (SUCCEEDED(Result=Info->get_Status(&Status)) && Status==Started)
61 Sleep(0); //Yield
62
63 if (FAILED(Result) || Status!=Completed) {
64 HRESULT Error_Code;
65 Result=Info->get_ErrorCode(&Error_Code);
66 if (FAILED(Result))
67 return Result;
68 return Error_Code;
69 }
70
71 return Result;
72}
73
74HRESULT Add_Item_To_FUA(Microsoft::WRL::Wrappers::HStringReference Path, Microsoft::WRL::ComPtr<ABI::Windows::Storage::IStorageItem> &Item);
75HRESULT Get_File(Microsoft::WRL::Wrappers::HStringReference File_Name, Microsoft::WRL::ComPtr<ABI::Windows::Storage::IStorageFile> &File);
76HRESULT Get_Folder(Microsoft::WRL::Wrappers::HStringReference Folder_Name, Microsoft::WRL::ComPtr<ABI::Windows::Storage::IStorageFolder> &Folder);
77#endif
78
79} //namespace ZenLib
80#endif
String manipulation (based on std::(w)string)
Definition: Ztring.h:50
Definition: BitStream.h:24
Ztring OpenFolder_Show(void *Handle, const Ztring &Title, const Ztring &Caption)
void Shell_Execute(const Ztring &ToExecute)
bool IsWin9X()