Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171#pragma once
#include <atlstr.h>#include "appinfo.h"
#ifdef _M_IX86#define CurrentArchitecture L"x86"#elif defined(_M_AMD64)#define CurrentArchitecture L"amd64"#elif defined(_M_ARM)#define CurrentArchitecture L"arm"#elif defined(_M_ARM64)#define CurrentArchitecture L"arm64"#elif defined(_M_IA64)#define CurrentArchitecture L"ia64"#elif defined(_M_PPC)#define CurrentArchitecture L"ppc"#endif
static inline HRESULTHResultFromWin32(UINT Error){ return HRESULT_FROM_WIN32(Error);}
static inline UINTErrorFromHResult(HRESULT hr){ // Attempt to extract the original Win32 error code from the HRESULT if (HIWORD(hr) == HIWORD(HRESULT_FROM_WIN32(!0))) return LOWORD(hr); else return hr >= 0 ? ERROR_SUCCESS : hr;}
UINTErrorBox(HWND hOwner, UINT Error = GetLastError());
VOIDCopyTextToClipboard(LPCWSTR lpszText);VOIDShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem, POINT *Point = NULL);VOIDEmulateDialogReposition(HWND hwnd);UINTClassifyFile(PCWSTR Path);BOOLOpensWithExplorer(PCWSTR Path);BOOLStartProcess(const CStringW &Path, BOOL Wait);BOOLGetStorageDirectory(CStringW &lpDirectory);
VOIDInitLogs();VOIDFreeLogs();BOOLWriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg);BOOLGetInstalledVersion(CStringW *pszVersion, const CStringW &szRegName);
typedef struct{ const CStringW &ItemPath; UINT64 UncompressedSize; UINT FileAttributes;} EXTRACTCALLBACKINFO;typedef BOOL (CALLBACK*EXTRACTCALLBACK)(const EXTRACTCALLBACKINFO &Info, void *Cookie);
static inline BOOLNotifyFileExtractCallback(const CStringW &ItemPath, UINT64 UncompressedSize, UINT FileAttributes, EXTRACTCALLBACK Callback, void *Cookie){ EXTRACTCALLBACKINFO eci = { ItemPath, UncompressedSize, FileAttributes }; return Callback ? Callback(eci, Cookie) : TRUE;}
BOOLExtractFilesFromCab(const CStringW &szCabName, const CStringW &szCabDir, const CStringW &szOutputDir, EXTRACTCALLBACK Callback = NULL, void *Cookie = NULL);BOOLExtractFilesFromCab(LPCWSTR FullCabPath, const CStringW &szOutputDir, EXTRACTCALLBACK Callback = NULL, void *Cookie = NULL);
BOOLIsSystem64Bit();ULONGGetNTVersion();
INTGetSystemColorDepth();
voidUnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime);
BOOLSearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle);
HRESULTRegKeyHasValues(HKEY hKey, LPCWSTR Path, REGSAM wowsam = 0);LPCWSTRGetRegString(CRegKey &Key, LPCWSTR Name, CStringW &Value);
boolExpandEnvStrings(CStringW &Str);
template <class T> static CStringWBuildPath(const T &Base, LPCWSTR Append){ CStringW path = Base; SIZE_T len = path.GetLength(); if (len && path[len - 1] != L'\\' && path[len - 1] != L'/') path += L'\\'; while (*Append == L'\\' || *Append == L'/') ++Append; return path + Append;}
CStringWSplitFileAndDirectory(LPCWSTR FullPath, CStringW *pDir = NULL);BOOLDeleteDirectoryTree(LPCWSTR Dir, HWND hwnd = NULL);UINTCreateDirectoryTree(LPCWSTR Dir);HRESULTGetSpecialPath(UINT csidl, CStringW &Path, HWND hwnd = NULL);HRESULTGetKnownPath(REFKNOWNFOLDERID kfid, CStringW &Path, DWORD Flags = KF_FLAG_CREATE);HRESULTGetProgramFilesPath(CStringW &Path, BOOL PerUser, HWND hwnd = NULL);
template <class T> class CLocalPtr : public CHeapPtr<T, CLocalAllocator>{};
struct CScopedMutex{ HANDLE m_hMutex;
CScopedMutex(LPCWSTR Name, UINT Timeout = INFINITE, BOOL InitialOwner = FALSE) { m_hMutex = CreateMutexW(NULL, InitialOwner, Name); if (m_hMutex && !InitialOwner) { DWORD wait = WaitForSingleObject(m_hMutex, Timeout); if (wait != WAIT_OBJECT_0 && wait != WAIT_ABANDONED) { CloseHandle(m_hMutex); m_hMutex = NULL; } } } ~CScopedMutex() { if (m_hMutex) { ReleaseMutex(m_hMutex); CloseHandle(m_hMutex); } }
bool Acquired() const { return m_hMutex != NULL; }};
InstallerTypeGuessInstallerType(LPCWSTR Installer, UINT &ExtraInfo);
BOOLGetSilentInstallParameters(InstallerType InstallerType, UINT ExtraInfo, LPCWSTR Installer, CStringW &Parameters);