ReactOS 0.4.16-dev-117-g38f21f9
misc.h
Go to the documentation of this file.
1#pragma once
2
3#include <atlstr.h>
4
5#ifdef _M_IX86
6#define CurrentArchitecture L"x86"
7#elif defined(_M_AMD64)
8#define CurrentArchitecture L"amd64"
9#elif defined(_M_ARM)
10#define CurrentArchitecture L"arm"
11#elif defined(_M_ARM64)
12#define CurrentArchitecture L"arm64"
13#elif defined(_M_IA64)
14#define CurrentArchitecture L"ia64"
15#elif defined(_M_PPC)
16#define CurrentArchitecture L"ppc"
17#endif
18
19static inline UINT
21{
22 // Attempt to extract the original Win32 error code from the HRESULT
24 return LOWORD(hr);
25 else
26 return hr >= 0 ? ERROR_SUCCESS : hr;
27}
28
29VOID
31VOID
32ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem, POINT *Point = NULL);
33VOID
35BOOL
37BOOL
39
40VOID
41InitLogs();
42VOID
43FreeLogs();
44BOOL
45WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg);
46BOOL
47GetInstalledVersion(CStringW *pszVersion, const CStringW &szRegName);
48
49typedef struct
50{
56
57static inline BOOL
58NotifyFileExtractCallback(const CStringW &ItemPath, UINT64 UncompressedSize, UINT FileAttributes,
60{
61 EXTRACTCALLBACKINFO eci = { ItemPath, UncompressedSize, FileAttributes };
62 return Callback ? Callback(eci, Cookie) : TRUE;
63}
64
65BOOL
66ExtractFilesFromCab(const CStringW &szCabName, const CStringW &szCabDir, const CStringW &szOutputDir,
68BOOL
69ExtractFilesFromCab(LPCWSTR FullCabPath, const CStringW &szOutputDir,
71
72BOOL
74
75INT
77
78void
79UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime);
80
81BOOL
82SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle);
83
88
89bool
91
92template <class T> static CStringW
93BuildPath(const T &Base, LPCWSTR Append)
94{
96 SIZE_T len = path.GetLength();
97 if (len && path[len - 1] != L'\\' && path[len - 1] != L'/')
98 path += L'\\';
99 while (*Append == L'\\' || *Append == L'/')
100 ++Append;
101 return path + Append;
102}
103
105SplitFileAndDirectory(LPCWSTR FullPath, CStringW *pDir = NULL);
106BOOL
108UINT
116
117template <class T> class CLocalPtr : public CHeapPtr<T, CLocalAllocator>
118{
119};
unsigned long long UINT64
PRTL_UNICODE_STRING_BUFFER Path
HRESULT GetKnownPath(REFKNOWNFOLDERID kfid, CStringW &Path, DWORD Flags=KF_FLAG_CREATE)
Definition: misc.cpp:487
BOOL(CALLBACK * EXTRACTCALLBACK)(const EXTRACTCALLBACKINFO &Info, void *Cookie)
Definition: misc.h:55
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:252
bool ExpandEnvStrings(CStringW &Str)
Definition: misc.cpp:420
HRESULT GetSpecialPath(UINT csidl, CStringW &Path, HWND hwnd=NULL)
Definition: misc.cpp:478
static CStringW BuildPath(const T &Base, LPCWSTR Append)
Definition: misc.h:93
BOOL StartProcess(const CStringW &Path, BOOL Wait)
Definition: misc.cpp:111
BOOL GetStorageDirectory(CStringW &lpDirectory)
Definition: misc.cpp:170
BOOL GetInstalledVersion(CStringW *pszVersion, const CStringW &szRegName)
Definition: misc.cpp:305
VOID EmulateDialogReposition(HWND hwnd)
Definition: misc.cpp:49
BOOL DeleteDirectoryTree(LPCWSTR Dir, HWND hwnd=NULL)
Definition: misc.cpp:446
UINT CreateDirectoryTree(LPCWSTR Dir)
Definition: misc.cpp:459
static BOOL NotifyFileExtractCallback(const CStringW &ItemPath, UINT64 UncompressedSize, UINT FileAttributes, EXTRACTCALLBACK Callback, void *Cookie)
Definition: misc.h:58
HRESULT RegKeyHasValues(HKEY hKey, LPCWSTR Path, REGSAM wowsam=0)
Definition: misc.cpp:379
BOOL ExtractFilesFromCab(const CStringW &szCabName, const CStringW &szCabDir, const CStringW &szOutputDir, EXTRACTCALLBACK Callback=NULL, void *Cookie=NULL)
Definition: cabinet.cpp:250
VOID ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem, POINT *Point=NULL)
Definition: misc.cpp:68
VOID InitLogs()
Definition: misc.cpp:205
VOID FreeLogs()
Definition: misc.cpp:243
static UINT ErrorFromHResult(HRESULT hr)
Definition: misc.h:20
INT GetSystemColorDepth()
Definition: misc.cpp:328
VOID CopyTextToClipboard(LPCWSTR lpszText)
Definition: misc.cpp:16
BOOL SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle)
Definition: misc.cpp:437
LPCWSTR GetRegString(CRegKey &Key, LPCWSTR Name, CStringW &Value)
Definition: misc.cpp:397
HRESULT GetProgramFilesPath(CStringW &Path, BOOL PerUser, HWND hwnd=NULL)
Definition: misc.cpp:502
CStringW SplitFileAndDirectory(LPCWSTR FullPath, CStringW *pDir=NULL)
Definition: misc.cpp:466
BOOL IsSystem64Bit()
Definition: misc.cpp:315
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime)
Definition: misc.cpp:368
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define CALLBACK
Definition: compat.h:35
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG FileAttributes
Definition: fltkernel.h:1236
FxAutoRegKey hKey
GLenum GLsizei len
Definition: glext.h:6722
unsigned int UINT
Definition: ndis.h:50
_In_opt_ ULONG Base
Definition: rtlfuncs.h:2451
#define BOOL
Definition: nt_native.h:43
#define L(x)
Definition: ntvdm.h:50
#define LOWORD(l)
Definition: pedump.c:82
_In_opt_ LPCSTR lpDirectory
Definition: shellapi.h:484
HRESULT hr
Definition: shlfolder.c:183
@ KF_FLAG_CREATE
Definition: shlobj.h:106
const CStringW & ItemPath
Definition: misc.h:51
UINT64 UncompressedSize
Definition: misc.h:52
UINT FileAttributes
Definition: misc.h:53
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int32_t INT
Definition: typedefs.h:58
#define HIWORD(l)
Definition: typedefs.h:247
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
ACCESS_MASK REGSAM
Definition: winreg.h:69
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_opt_ PVOID _Out_ PLARGE_INTEGER Cookie
Definition: cmfuncs.h:14
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185