ReactOS  0.4.15-dev-3453-gff89651
misc.cpp File Reference
#include "rapps.h"
#include "misc.h"
Include dependency graph for misc.cpp:

Go to the source code of this file.

Functions

VOID CopyTextToClipboard (LPCWSTR lpszText)
 
VOID ShowPopupMenuEx (HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem)
 
BOOL StartProcess (const ATL::CStringW &Path, BOOL Wait)
 
BOOL GetStorageDirectory (ATL::CStringW &Directory)
 
VOID InitLogs ()
 
VOID FreeLogs ()
 
BOOL WriteLogMessage (WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
 
BOOL GetInstalledVersion_WowUser (ATL::CStringW *szVersionResult, const ATL::CStringW &szRegName, BOOL IsUserKey, REGSAM keyWow)
 
BOOL GetInstalledVersion (ATL::CStringW *pszVersion, const ATL::CStringW &szRegName)
 
BOOL PathAppendNoDirEscapeW (LPWSTR pszPath, LPCWSTR pszMore)
 
BOOL IsSystem64Bit ()
 
INT GetSystemColorDepth ()
 
void UnixTimeToFileTime (DWORD dwUnixTime, LPFILETIME pFileTime)
 
BOOL SearchPatternMatch (LPCWSTR szHaystack, LPCWSTR szNeedle)
 

Variables

static HANDLE hLog = NULL
 
static BOOL bIsSys64ResultCached = FALSE
 
static BOOL bIsSys64Result = FALSE
 

Function Documentation

◆ CopyTextToClipboard()

VOID CopyTextToClipboard ( LPCWSTR  lpszText)

Definition at line 18 of file misc.cpp.

19 {
20  if (!OpenClipboard(NULL))
21  {
22  return;
23  }
24 
25  HRESULT hr;
26  HGLOBAL ClipBuffer;
27  LPWSTR Buffer;
29 
31  cchBuffer = wcslen(lpszText) + 1;
32  ClipBuffer = GlobalAlloc(GMEM_DDESHARE, cchBuffer * sizeof(WCHAR));
33 
34  Buffer = (PWCHAR) GlobalLock(ClipBuffer);
35  hr = StringCchCopyW(Buffer, cchBuffer, lpszText);
36  GlobalUnlock(ClipBuffer);
37 
38  if (SUCCEEDED(hr))
39  SetClipboardData(CF_UNICODETEXT, ClipBuffer);
40 
42 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
HRESULT hr
Definition: shlfolder.c:183
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
uint16_t * PWCHAR
Definition: typedefs.h:56
HANDLE WINAPI SetClipboardData(_In_ UINT, _In_opt_ HANDLE)
if SUCCEEDED(hr)
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
static DWORD cchBuffer
Definition: fusion.c:85
#define CF_UNICODETEXT
Definition: constants.h:408
Definition: bufpool.h:45
BOOL WINAPI EmptyClipboard(void)
Definition: ntwrapper.h:190
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI CloseClipboard(void)
Definition: ntwrapper.h:178
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define NULL
Definition: types.h:112
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define GMEM_DDESHARE
Definition: winbase.h:295
BOOL WINAPI OpenClipboard(_In_opt_ HWND)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CAppInfoDisplay::OnCommand().

◆ FreeLogs()

VOID FreeLogs ( )

Definition at line 219 of file misc.cpp.

220 {
221  if (hLog)
222  {
224  }
225 }
static HANDLE hLog
Definition: misc.cpp:13
BOOL WINAPI DeregisterEventSource(IN HANDLE hEventLog)
Definition: eventlog.c:473

Referenced by CMainWindow::ProcessWindowMessage(), and wmain().

◆ GetInstalledVersion()

BOOL GetInstalledVersion ( ATL::CStringW pszVersion,
const ATL::CStringW szRegName 
)

Definition at line 287 of file misc.cpp.

288 {
289  return (!szRegName.IsEmpty()
290  && (GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_32KEY)
291  || GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_32KEY)
292  || GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_64KEY)
293  || GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_64KEY)));
294 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46
bool IsEmpty() const
Definition: atlsimpstr.h:379
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
BOOL GetInstalledVersion_WowUser(ATL::CStringW *szVersionResult, const ATL::CStringW &szRegName, BOOL IsUserKey, REGSAM keyWow)
Definition: misc.cpp:244

Referenced by CAvailableApplicationInfo::RetrieveInstalledStatus(), and CAvailableApplicationInfo::RetrieveInstalledVersion().

◆ GetInstalledVersion_WowUser()

BOOL GetInstalledVersion_WowUser ( ATL::CStringW szVersionResult,
const ATL::CStringW szRegName,
BOOL  IsUserKey,
REGSAM  keyWow 
)

Definition at line 244 of file misc.cpp.

248 {
249  BOOL bHasSucceded = FALSE;
252  ATL::CStringW szPath = ATL::CStringW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%ls") + szRegName;
253 
254  if (key.Open(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
255  szPath.GetString(),
256  keyWow | KEY_READ) != ERROR_SUCCESS)
257  {
258  return FALSE;
259  }
260 
261  if (szVersionResult != NULL)
262  {
263  ULONG dwSize = MAX_PATH * sizeof(WCHAR);
264 
265  if (key.QueryStringValue(L"DisplayVersion",
266  szVersion.GetBuffer(MAX_PATH),
267  &dwSize) == ERROR_SUCCESS)
268  {
269  szVersion.ReleaseBuffer();
270  *szVersionResult = szVersion;
271  bHasSucceded = TRUE;
272  }
273  else
274  {
275  szVersion.ReleaseBuffer();
276  }
277  }
278  else
279  {
280  bHasSucceded = TRUE;
281  szVersion.ReleaseBuffer();
282  }
283 
284  return bHasSucceded;
285 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
static LPCWSTR szVersion
Definition: asmcache.c:748
HKEY key
Definition: reg.c:42
LPCWSTR szPath
Definition: env.c:37
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
CAtlStringW CStringW
Definition: atlstr.h:130
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
Definition: path.c:41
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by GetInstalledVersion().

◆ GetStorageDirectory()

BOOL GetStorageDirectory ( ATL::CStringW Directory)

Definition at line 141 of file misc.cpp.

142 {
143  static CStringW CachedDirectory;
144  static BOOL CachedDirectoryInitialized = FALSE;
145 
146  if (!CachedDirectoryInitialized)
147  {
148  LPWSTR DirectoryStr = CachedDirectory.GetBuffer(MAX_PATH);
149  BOOL bHasPath = SHGetSpecialFolderPathW(NULL, DirectoryStr, CSIDL_LOCAL_APPDATA, TRUE);
150  if (bHasPath)
151  {
152  PathAppendW(DirectoryStr, L"rapps");
153  }
154  CachedDirectory.ReleaseBuffer();
155 
156  if (bHasPath)
157  {
158  if (!CreateDirectoryW(CachedDirectory, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
159  {
160  CachedDirectory.Empty();
161  }
162  }
163  else
164  {
165  CachedDirectory.Empty();
166  }
167 
168  CachedDirectoryInitialized = TRUE;
169  }
170 
171  Directory = CachedDirectory;
172  return !Directory.IsEmpty();
173 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define TRUE
Definition: types.h:120
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
#define L(x)
Definition: ntvdm.h:50
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2039
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:2948
#define NULL
Definition: types.h:112
base for all directory entries
Definition: entries.h:138
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by AvailableStrings::AvailableStrings(), GetINIFullPath(), and CDownloadManager::ThreadFunc().

◆ GetSystemColorDepth()

INT GetSystemColorDepth ( )

Definition at line 369 of file misc.cpp.

370 {
371  DEVMODEW pDevMode;
372  INT ColorDepth;
373 
374  pDevMode.dmSize = sizeof(pDevMode);
375  pDevMode.dmDriverExtra = 0;
376 
378  {
379  /* TODO: Error message */
380  return ILC_COLOR;
381  }
382 
383  switch (pDevMode.dmBitsPerPel)
384  {
385  case 32: ColorDepth = ILC_COLOR32; break;
386  case 24: ColorDepth = ILC_COLOR24; break;
387  case 16: ColorDepth = ILC_COLOR16; break;
388  case 8: ColorDepth = ILC_COLOR8; break;
389  case 4: ColorDepth = ILC_COLOR4; break;
390  default: ColorDepth = ILC_COLOR; break;
391  }
392 
393  return ColorDepth;
394 }
#define ILC_COLOR16
Definition: commctrl.h:356
WORD dmDriverExtra
Definition: wingdi.h:1621
DWORD dmBitsPerPel
Definition: wingdi.h:1647
int32_t INT
Definition: typedefs.h:58
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179
#define ILC_COLOR4
Definition: commctrl.h:354
#define ILC_COLOR32
Definition: commctrl.h:358
#define ILC_COLOR
Definition: commctrl.h:352
BOOL WINAPI EnumDisplaySettingsW(LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode)
Definition: display.c:408
#define ILC_COLOR24
Definition: commctrl.h:357
WORD dmSize
Definition: wingdi.h:1620
#define NULL
Definition: types.h:112
#define ILC_COLOR8
Definition: commctrl.h:355

Referenced by CAppsListView::Create(), and CMainToolbar::InitImageList().

◆ InitLogs()

VOID InitLogs ( )

Definition at line 175 of file misc.cpp.

176 {
178  {
179  return;
180  }
181 
183  DWORD dwCategoryNum = 1;
184  DWORD dwDisp, dwData;
186 
187  if (key.Create(HKEY_LOCAL_MACHINE,
188  L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\ReactOS Application Manager",
190  {
191  return;
192  }
193 
195  {
196  return;
197  }
198 
201 
202  if ((key.SetStringValue(L"EventMessageFile",
203  szPath,
205  && (key.SetStringValue(L"CategoryMessageFile",
206  szPath,
208  && (key.SetDWORDValue(L"TypesSupported",
209  dwData) == ERROR_SUCCESS)
210  && (key.SetDWORDValue(L"CategoryCount",
211  dwCategoryNum) == ERROR_SUCCESS))
212 
213  {
214  hLog = RegisterEventSourceW(NULL, L"ReactOS Application Manager");
215  }
216 }
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
#define ERROR_SUCCESS
Definition: deptool.c:10
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define L(x)
Definition: ntvdm.h:50
#define EVENTLOG_ERROR_TYPE
Definition: winnt_old.h:2754
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
#define EVENTLOG_INFORMATION_TYPE
Definition: winnt_old.h:2756
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:20
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define EVENTLOG_WARNING_TYPE
Definition: winnt_old.h:2755
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
static HANDLE hLog
Definition: misc.cpp:13
unsigned long DWORD
Definition: ntddk_ex.h:95
HKEY key
Definition: reg.c:42
BOOL bLogEnabled
Definition: settings.h:9
LPCWSTR szPath
Definition: env.c:37
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define NULL
Definition: types.h:112
#define REG_NONE
Definition: nt_native.h:1492
HANDLE WINAPI RegisterEventSourceW(IN LPCWSTR lpUNCServerName, IN LPCWSTR lpSourceName)
Definition: eventlog.c:1295
Definition: path.c:41
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by wmain(), and wWinMain().

◆ IsSystem64Bit()

BOOL IsSystem64Bit ( )

Definition at line 341 of file misc.cpp.

342 {
344  {
345  // just return cached result
346  return bIsSys64Result;
347  }
348 
349  SYSTEM_INFO si;
350  typedef void (WINAPI *LPFN_PGNSI)(LPSYSTEM_INFO);
351  LPFN_PGNSI pGetNativeSystemInfo = (LPFN_PGNSI)GetProcAddress(GetModuleHandle(L"kernel32.dll"), "GetNativeSystemInfo");
352  if (pGetNativeSystemInfo)
353  {
354  pGetNativeSystemInfo(&si);
356  {
358  }
359  }
360  else
361  {
363  }
364 
365  bIsSys64ResultCached = TRUE; // next time calling this function, it will directly return bIsSys64Result
366  return bIsSys64Result;
367 }
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
static BOOL bIsSys64ResultCached
Definition: misc.cpp:15
#define TRUE
Definition: types.h:120
#define PROCESSOR_ARCHITECTURE_IA64
Definition: ketypes.h:111
#define L(x)
Definition: ntvdm.h:50
#define FALSE
Definition: types.h:117
static BOOL bIsSys64Result
Definition: misc.cpp:16
#define WINAPI
Definition: msvc.h:6
#define PROCESSOR_ARCHITECTURE_AMD64
Definition: ketypes.h:114
#define GetModuleHandle
Definition: winbase.h:3683
struct _SYSTEM_INFO * LPSYSTEM_INFO
WORD wProcessorArchitecture
Definition: winbase.h:1151
#define GetProcAddress(x, y)
Definition: compat.h:612

Referenced by CInstalledApps::Enum().

◆ PathAppendNoDirEscapeW()

BOOL PathAppendNoDirEscapeW ( LPWSTR  pszPath,
LPCWSTR  pszMore 
)

Definition at line 296 of file misc.cpp.

297 {
298  WCHAR pszPathBuffer[MAX_PATH]; // buffer to store result
299  WCHAR pszPathCopy[MAX_PATH];
300 
301  if (!PathCanonicalizeW(pszPathCopy, pszPath))
302  {
303  return FALSE;
304  }
305 
306  PathRemoveBackslashW(pszPathCopy);
307 
308  if (StringCchCopyW(pszPathBuffer, _countof(pszPathBuffer), pszPathCopy) != S_OK)
309  {
310  return FALSE;
311  }
312 
313  if (!PathAppendW(pszPathBuffer, pszMore))
314  {
315  return FALSE;
316  }
317 
318  size_t PathLen;
319  if (StringCchLengthW(pszPathCopy, _countof(pszPathCopy), &PathLen) != S_OK)
320  {
321  return FALSE;
322  }
323  int CommonPrefixLen = PathCommonPrefixW(pszPathCopy, pszPathBuffer, NULL);
324 
325  if ((unsigned int)CommonPrefixLen != PathLen)
326  {
327  // pszPathBuffer should be a file/folder under pszPath.
328  // but now common prefix len is smaller than length of pszPathCopy
329  // hacking use ".." ?
330  return FALSE;
331  }
332 
333  if (StringCchCopyW(pszPath, MAX_PATH, pszPathBuffer) != S_OK)
334  {
335  return FALSE;
336  }
337 
338  return TRUE;
339 }
int WINAPI PathCommonPrefixW(LPCWSTR lpszFile1, LPCWSTR lpszFile2, LPWSTR achPath)
Definition: path.c:2805
BOOL WINAPI PathCanonicalizeW(LPWSTR lpszBuf, LPCWSTR lpszPath)
Definition: path.c:2445
#define TRUE
Definition: types.h:120
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
#define FALSE
Definition: types.h:117
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define MAX_PATH
Definition: compat.h:34
LPWSTR WINAPI PathRemoveBackslashW(LPWSTR lpszPath)
Definition: path.c:867
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
STRSAFEAPI StringCchLengthW(STRSAFE_LPCWSTR psz, size_t cchMax, size_t *pcchLength)
Definition: strsafe.h:842

Referenced by CAvailableApplicationInfo::RetrieveGeneralInfo().

◆ SearchPatternMatch()

BOOL SearchPatternMatch ( LPCWSTR  szHaystack,
LPCWSTR  szNeedle 
)

Definition at line 406 of file misc.cpp.

407 {
408  if (!*szNeedle)
409  return TRUE;
410  /* TODO: Improve pattern search beyond a simple case-insensitive substring search. */
411  return StrStrIW(szHaystack, szNeedle) != NULL;
412 }
#define TRUE
Definition: types.h:120
LPWSTR WINAPI StrStrIW(LPCWSTR lpszStr, LPCWSTR lpszSearch)
Definition: string.c:384
#define NULL
Definition: types.h:112

Referenced by CmdFindAppEnum(), CMainWindow::EnumAvailableAppProc(), and CMainWindow::EnumInstalledAppProc().

◆ ShowPopupMenuEx()

VOID ShowPopupMenuEx ( HWND  hwnd,
HWND  hwndOwner,
UINT  MenuID,
UINT  DefaultItem 
)

Definition at line 44 of file misc.cpp.

45 {
46  HMENU hMenu = NULL;
47  HMENU hPopupMenu;
48  MENUITEMINFO ItemInfo;
49  POINT pt;
50 
51  if (MenuID)
52  {
53  hMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(MenuID));
54  hPopupMenu = GetSubMenu(hMenu, 0);
55  }
56  else
57  {
58  hPopupMenu = GetMenu(hwnd);
59  }
60 
61  ZeroMemory(&ItemInfo, sizeof(ItemInfo));
62  ItemInfo.cbSize = sizeof(ItemInfo);
63  ItemInfo.fMask = MIIM_STATE;
64 
65  GetMenuItemInfoW(hPopupMenu, DefaultItem, FALSE, &ItemInfo);
66 
67  if (!(ItemInfo.fState & MFS_GRAYED))
68  {
69  SetMenuDefaultItem(hPopupMenu, DefaultItem, FALSE);
70  }
71 
72  GetCursorPos(&pt);
73 
75  TrackPopupMenu(hPopupMenu, 0, pt.x, pt.y, 0, hwndOwner, NULL);
76 
77  if (hMenu)
78  {
79  DestroyMenu(hMenu);
80  }
81 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define pt(x, y)
Definition: drawing.c:79
#define ZeroMemory
Definition: winbase.h:1664
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
#define FALSE
Definition: types.h:117
#define MIIM_STATE
Definition: winuser.h:716
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
#define MFS_GRAYED
Definition: winuser.h:746
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
BOOL WINAPI DestroyMenu(_In_ HMENU)
HINSTANCE hInst
Definition: dxdiag.c:13
#define NULL
Definition: types.h:112
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)

Referenced by CAppInfoDisplay::OnLink(), and CApplicationView::ProcessWindowMessage().

◆ StartProcess()

BOOL StartProcess ( const ATL::CStringW Path,
BOOL  Wait 
)

Definition at line 83 of file misc.cpp.

84 {
86  STARTUPINFOW si;
87  DWORD dwRet;
88  MSG msg;
89 
90  ZeroMemory(&si, sizeof(si));
91  si.cb = sizeof(si);
93  si.wShowWindow = SW_SHOW;
94 
95  // The Unicode version of CreateProcess can modify the contents of this string.
96  CStringW Tmp = Path;
97  BOOL fSuccess = CreateProcessW(NULL, Tmp.GetBuffer(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
98  Tmp.ReleaseBuffer();
99  if (!fSuccess)
100  {
101  return FALSE;
102  }
103 
104  CloseHandle(pi.hThread);
105 
106  if (Wait)
107  {
109  }
110 
111  while (Wait)
112  {
113  dwRet = MsgWaitForMultipleObjects(1, &pi.hProcess, FALSE, INFINITE, QS_ALLEVENTS);
114  if (dwRet == WAIT_OBJECT_0 + 1)
115  {
116  while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
117  {
120  }
121  }
122  else
123  {
124  if (dwRet == WAIT_OBJECT_0 || dwRet == WAIT_FAILED)
125  break;
126  }
127  }
128 
129  CloseHandle(pi.hProcess);
130 
131  if (Wait)
132  {
136  }
137 
138  return TRUE;
139 }
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define CloseHandle
Definition: compat.h:598
#define TRUE
Definition: types.h:120
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define ZeroMemory
Definition: winbase.h:1664
HWND WINAPI SetFocus(_In_opt_ HWND)
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:372
#define FALSE
Definition: types.h:117
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
unsigned int BOOL
Definition: ntddk_ex.h:94
#define QS_ALLEVENTS
Definition: winuser.h:896
#define STARTF_USESHOWWINDOW
Definition: winbase.h:488
#define SW_SHOW
Definition: winuser.h:769
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessW(LPCWSTR lpApplicationName, LPWSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCWSTR lpCurrentDirectory, LPSTARTUPINFOW lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
Definition: proc.c:4594
#define WAIT_OBJECT_0
Definition: winbase.h:403
DWORD cb
Definition: winbase.h:846
static refpint_t pi[]
Definition: server.c:96
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WAIT_FAILED
Definition: winbase.h:410
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
HWND hMainWnd
Definition: magnifier.c:32
WORD wShowWindow
Definition: winbase.h:858
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
PRTL_UNICODE_STRING_BUFFER Path
#define NULL
Definition: types.h:112
#define msg(x)
Definition: auth_time.c:54
BOOL WINAPI SetForegroundWindow(_In_ HWND)
DWORD dwFlags
Definition: winbase.h:857
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1186
#define INFINITE
Definition: serial.h:102

Referenced by CInstalledApplicationInfo::UninstallApplication().

◆ UnixTimeToFileTime()

void UnixTimeToFileTime ( DWORD  dwUnixTime,
LPFILETIME  pFileTime 
)

Definition at line 396 of file misc.cpp.

397 {
398  // Note that LONGLONG is a 64-bit value
399  LONGLONG ll;
400 
401  ll = Int32x32To64(dwUnixTime, 10000000) + 116444736000000000;
402  pFileTime->dwLowDateTime = (DWORD)ll;
403  pFileTime->dwHighDateTime = ll >> 32;
404 }
#define DWORD
Definition: nt_native.h:44
DWORD dwHighDateTime
Definition: mapidefs.h:66
int64_t LONGLONG
Definition: typedefs.h:68
w ll
Definition: byte_order.h:166
#define Int32x32To64(a, b)
DWORD dwLowDateTime
Definition: mapidefs.h:65

Referenced by CInstalledApplicationInfo::EnsureDetailsLoaded().

◆ WriteLogMessage()

BOOL WriteLogMessage ( WORD  wType,
DWORD  dwEventID,
LPCWSTR  lpMsg 
)

Definition at line 228 of file misc.cpp.

229 {
231  {
232  return TRUE;
233  }
234 
235  if (!ReportEventW(hLog, wType, 0, dwEventID,
236  NULL, 1, 0, &lpMsg, NULL))
237  {
238  return FALSE;
239  }
240 
241  return TRUE;
242 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:20
static HANDLE hLog
Definition: misc.cpp:13
BOOL WINAPI ReportEventW(IN HANDLE hEventLog, IN WORD wType, IN WORD wCategory, IN DWORD dwEventID, IN PSID lpUserSid, IN WORD wNumStrings, IN DWORD dwDataSize, IN LPCWSTR *lpStrings, IN LPVOID lpRawData)
Definition: eventlog.c:1516
BOOL bLogEnabled
Definition: settings.h:9
#define NULL
Definition: types.h:112

Referenced by CDownloadManager::ThreadFunc(), and CInstalledApplicationInfo::UninstallApplication().

Variable Documentation

◆ bIsSys64Result

BOOL bIsSys64Result = FALSE
static

Definition at line 16 of file misc.cpp.

Referenced by IsSystem64Bit().

◆ bIsSys64ResultCached

BOOL bIsSys64ResultCached = FALSE
static

Definition at line 15 of file misc.cpp.

Referenced by IsSystem64Bit().

◆ hLog