ZenLib
|
00001 /* Copyright (c) MediaArea.net SARL. All Rights Reserved. 00002 * 00003 * Use of this source code is governed by a zlib-style license that can 00004 * be found in the License.txt file in the root of the source tree. 00005 */ 00006 00007 //--------------------------------------------------------------------------- 00008 #ifndef ZenOS_UtilsH 00009 #define ZenOS_UtilsH 00010 //--------------------------------------------------------------------------- 00011 00012 //--------------------------------------------------------------------------- 00013 #include "ZenLib/Ztring.h" 00014 //--------------------------------------------------------------------------- 00015 00016 //--------------------------------------------------------------------------- 00017 #ifdef WINDOWS_UWP 00018 #include <wrl.h> 00019 #include <windows.foundation.h> 00020 #include <windows.storage.h> 00021 #endif 00022 //--------------------------------------------------------------------------- 00023 00024 namespace ZenLib 00025 { 00026 00027 //*************************************************************************** 00028 // OS Information 00029 //*************************************************************************** 00030 00031 //--------------------------------------------------------------------------- 00032 bool IsWin9X (); 00033 // Execute 00034 //*************************************************************************** 00035 00036 void Shell_Execute(const Ztring &ToExecute); 00037 00038 //*************************************************************************** 00039 // Directorues 00040 //*************************************************************************** 00041 00042 Ztring OpenFolder_Show(void* Handle, const Ztring &Title, const Ztring &Caption); 00043 00044 //*************************************************************************** 00045 // WinRT Helpers 00046 //*************************************************************************** 00047 #ifdef WINDOWS_UWP 00048 template <typename T> 00049 inline HRESULT Await(const Microsoft::WRL::ComPtr<T> &Operation) 00050 { 00051 if (!Operation) 00052 return E_POINTER; 00053 00054 Microsoft::WRL::ComPtr<ABI::Windows::Foundation::IAsyncInfo> Info; 00055 HRESULT Result=Operation.As(&Info); 00056 if (FAILED(Result)) 00057 return Result; 00058 00059 ABI::Windows::Foundation::AsyncStatus Status; 00060 while (SUCCEEDED(Result=Info->get_Status(&Status)) && Status==Started) 00061 Sleep(0); //Yield 00062 00063 if (FAILED(Result) || Status!=Completed) { 00064 HRESULT Error_Code; 00065 Result=Info->get_ErrorCode(&Error_Code); 00066 if (FAILED(Result)) 00067 return Result; 00068 return Error_Code; 00069 } 00070 00071 return Result; 00072 } 00073 00074 HRESULT Add_Item_To_FUA(Microsoft::WRL::Wrappers::HStringReference Path, Microsoft::WRL::ComPtr<ABI::Windows::Storage::IStorageItem> &Item); 00075 HRESULT Get_File(Microsoft::WRL::Wrappers::HStringReference File_Name, Microsoft::WRL::ComPtr<ABI::Windows::Storage::IStorageFile> &File); 00076 HRESULT Get_Folder(Microsoft::WRL::Wrappers::HStringReference Folder_Name, Microsoft::WRL::ComPtr<ABI::Windows::Storage::IStorageFolder> &Folder); 00077 #endif 00078 00079 } //namespace ZenLib 00080 #endif