ReactOS 0.4.15-dev-8093-g3285f69
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);
33BOOL
35BOOL
37
38VOID
39InitLogs();
40VOID
41FreeLogs();
42BOOL
43WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg);
44BOOL
45GetInstalledVersion(CStringW *pszVersion, const CStringW &szRegName);
46
47typedef struct
48{
54
55static inline BOOL
56NotifyFileExtractCallback(const CStringW &ItemPath, UINT64 UncompressedSize, UINT FileAttributes,
58{
59 EXTRACTCALLBACKINFO eci = { ItemPath, UncompressedSize, FileAttributes };
60 return Callback ? Callback(eci, Cookie) : TRUE;
61}
62
63BOOL
64ExtractFilesFromCab(const CStringW &szCabName, const CStringW &szCabDir, const CStringW &szOutputDir,
66BOOL
67ExtractFilesFromCab(LPCWSTR FullCabPath, const CStringW &szOutputDir,
69
70BOOL
72
73INT
75
76void
77UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime);
78
79BOOL
80SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle);
81
86
87bool
89
90template <class T> static CStringW
91BuildPath(const T &Base, LPCWSTR Append)
92{
94 SIZE_T len = path.GetLength();
95 if (len && path[len - 1] != L'\\' && path[len - 1] != L'/')
96 path += L'\\';
97 while (*Append == L'\\' || *Append == L'/')
98 ++Append;
99 return path + Append;
100}
101
103SplitFileAndDirectory(LPCWSTR FullPath, CStringW *pDir = NULL);
104BOOL
106UINT
114
115template <class T> class CLocalPtr : public CHeapPtr<T, CLocalAllocator>
116{
117};
unsigned long long UINT64
PRTL_UNICODE_STRING_BUFFER Path
HRESULT GetKnownPath(REFKNOWNFOLDERID kfid, CStringW &Path, DWORD Flags=KF_FLAG_CREATE)
Definition: misc.cpp:459
BOOL(CALLBACK * EXTRACTCALLBACK)(const EXTRACTCALLBACKINFO &Info, void *Cookie)
Definition: misc.h:53
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:224
bool ExpandEnvStrings(CStringW &Str)
Definition: misc.cpp:392
HRESULT GetSpecialPath(UINT csidl, CStringW &Path, HWND hwnd=NULL)
Definition: misc.cpp:450
static CStringW BuildPath(const T &Base, LPCWSTR Append)
Definition: misc.h:91
BOOL StartProcess(const CStringW &Path, BOOL Wait)
Definition: misc.cpp:83
BOOL GetStorageDirectory(CStringW &lpDirectory)
Definition: misc.cpp:142
BOOL GetInstalledVersion(CStringW *pszVersion, const CStringW &szRegName)
Definition: misc.cpp:277
BOOL DeleteDirectoryTree(LPCWSTR Dir, HWND hwnd=NULL)
Definition: misc.cpp:418
UINT CreateDirectoryTree(LPCWSTR Dir)
Definition: misc.cpp:431
static BOOL NotifyFileExtractCallback(const CStringW &ItemPath, UINT64 UncompressedSize, UINT FileAttributes, EXTRACTCALLBACK Callback, void *Cookie)
Definition: misc.h:56
HRESULT RegKeyHasValues(HKEY hKey, LPCWSTR Path, REGSAM wowsam=0)
Definition: misc.cpp:351
BOOL ExtractFilesFromCab(const CStringW &szCabName, const CStringW &szCabDir, const CStringW &szOutputDir, EXTRACTCALLBACK Callback=NULL, void *Cookie=NULL)
Definition: cabinet.cpp:249
VOID InitLogs()
Definition: misc.cpp:177
VOID FreeLogs()
Definition: misc.cpp:215
static UINT ErrorFromHResult(HRESULT hr)
Definition: misc.h:20
INT GetSystemColorDepth()
Definition: misc.cpp:300
VOID CopyTextToClipboard(LPCWSTR lpszText)
Definition: misc.cpp:16
BOOL SearchPatternMatch(LPCWSTR szHaystack, LPCWSTR szNeedle)
Definition: misc.cpp:409
LPCWSTR GetRegString(CRegKey &Key, LPCWSTR Name, CStringW &Value)
Definition: misc.cpp:369
HRESULT GetProgramFilesPath(CStringW &Path, BOOL PerUser, HWND hwnd=NULL)
Definition: misc.cpp:474
CStringW SplitFileAndDirectory(LPCWSTR FullPath, CStringW *pDir=NULL)
Definition: misc.cpp:438
BOOL IsSystem64Bit()
Definition: misc.cpp:287
void UnixTimeToFileTime(DWORD dwUnixTime, LPFILETIME pFileTime)
Definition: misc.cpp:340
VOID ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem)
Definition: misc.cpp:43
#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:2439
#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:49
UINT64 UncompressedSize
Definition: misc.h:50
UINT FileAttributes
Definition: misc.h:51
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