ReactOS  0.4.15-dev-2961-gecb0c09
misc.h File Reference
#include <windef.h>
#include <atlstr.h>
Include dependency graph for misc.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CConfigParser
 
class  CLocalPtr< T >
 

Macros

#define EPOCH_DIFF   116444736000000000
 
#define RATE_DIFF   10000000
 

Functions

INT GetWindowWidth (HWND hwnd)
 
INT GetWindowHeight (HWND hwnd)
 
INT GetClientWindowWidth (HWND hwnd)
 
INT GetClientWindowHeight (HWND hwnd)
 
VOID CopyTextToClipboard (LPCWSTR lpszText)
 
VOID ShowPopupMenuEx (HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem)
 
VOID ShowPopupMenu (HWND hwnd, UINT MenuID, UINT DefaultItem)
 
BOOL StartProcess (ATL::CStringW &Path, BOOL Wait)
 
BOOL StartProcess (LPWSTR lpPath, BOOL Wait)
 
BOOL GetStorageDirectory (ATL::CStringW &lpDirectory)
 
VOID InitLogs ()
 
VOID FreeLogs ()
 
BOOL WriteLogMessage (WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
 
BOOL GetInstalledVersion (ATL::CStringW *pszVersion, const ATL::CStringW &szRegName)
 
BOOL ExtractFilesFromCab (const ATL::CStringW &szCabName, const ATL::CStringW &szCabDir, const ATL::CStringW &szOutputDir)
 
BOOL PathAppendNoDirEscapeW (LPWSTR pszPath, LPCWSTR pszMore)
 
BOOL IsSystem64Bit ()
 
INT GetSystemColorDepth ()
 
void UnixTimeToFileTime (DWORD dwUnixTime, LPFILETIME pFileTime)
 
BOOL SearchPatternMatch (LPCWSTR szHaystack, LPCWSTR szNeedle)
 

Macro Definition Documentation

◆ EPOCH_DIFF

#define EPOCH_DIFF   116444736000000000

Definition at line 6 of file misc.h.

◆ RATE_DIFF

#define RATE_DIFF   10000000

Definition at line 7 of file misc.h.

Function Documentation

◆ CopyTextToClipboard()

VOID CopyTextToClipboard ( LPCWSTR  lpszText)

Definition at line 50 of file misc.cpp.

51 {
52  if (!OpenClipboard(NULL))
53  {
54  return;
55  }
56 
57  HRESULT hr;
58  HGLOBAL ClipBuffer;
59  LPWSTR Buffer;
61 
63  cchBuffer = wcslen(lpszText) + 1;
64  ClipBuffer = GlobalAlloc(GMEM_DDESHARE, cchBuffer * sizeof(WCHAR));
65 
66  Buffer = (PWCHAR) GlobalLock(ClipBuffer);
67  hr = StringCchCopyW(Buffer, cchBuffer, lpszText);
68  GlobalUnlock(ClipBuffer);
69 
70  if (SUCCEEDED(hr))
71  SetClipboardData(CF_UNICODETEXT, ClipBuffer);
72 
74 }
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().

◆ ExtractFilesFromCab()

BOOL ExtractFilesFromCab ( const ATL::CStringW szCabName,
const ATL::CStringW szCabDir,
const ATL::CStringW szOutputDir 
)

Definition at line 281 of file cabinet.cpp.

284 {
285  HINSTANCE hCabinetDll;
286  HFDI ExtractHandler;
287  ERF ExtractErrors;
288  ATL::CStringA szCabNameUTF8, szCabDirUTF8, szOutputDirUTF8;
289  fnFDICreate pfnFDICreate;
290  fnFDICopy pfnFDICopy;
291  fnFDIDestroy pfnFDIDestroy;
292  BOOL bResult;
293 
294  // Load cabinet.dll and extract needed functions
295  hCabinetDll = LoadLibraryW(L"cabinet.dll");
296 
297  if (!hCabinetDll)
298  {
299  return FALSE;
300  }
301 
302  pfnFDICreate = (fnFDICreate) GetProcAddress(hCabinetDll, "FDICreate");
303  pfnFDICopy = (fnFDICopy) GetProcAddress(hCabinetDll, "FDICopy");
304  pfnFDIDestroy = (fnFDIDestroy) GetProcAddress(hCabinetDll, "FDIDestroy");
305 
306  if (!pfnFDICreate || !pfnFDICopy || !pfnFDIDestroy)
307  {
308  FreeLibrary(hCabinetDll);
309  return FALSE;
310  }
311 
312  // Create FDI context
313  ExtractHandler = pfnFDICreate(fnMemAlloc,
314  fnMemFree,
315  fnFileOpen,
316  fnFileRead,
317  fnFileWrite,
318  fnFileClose,
319  fnFileSeek,
320  cpuUNKNOWN,
321  &ExtractErrors);
322 
323  if (!ExtractHandler)
324  {
325  FreeLibrary(hCabinetDll);
326  return FALSE;
327  }
328 
329  // Create output dir
330  bResult = CreateDirectoryW(szOutputDir, NULL);
331 
332  if (bResult || GetLastError() == ERROR_ALREADY_EXISTS)
333  {
334  // Convert wide strings to UTF-8
335  bResult = WideToMultiByte(szCabName, szCabNameUTF8, CP_UTF8);
336  bResult &= WideToMultiByte(szCabDir, szCabDirUTF8, CP_UTF8);
337  bResult &= WideToMultiByte(szOutputDir, szOutputDirUTF8, CP_UTF8);
338  }
339 
340  // Perform extraction
341  if (bResult)
342  {
343  // Add a slash to cab name as required by the api
344  szCabNameUTF8 = "\\" + szCabNameUTF8;
345 
346  bResult = pfnFDICopy(ExtractHandler,
347  (LPSTR) szCabNameUTF8.GetString(),
348  (LPSTR) szCabDirUTF8.GetString(),
349  0,
350  fnNotify,
351  NULL,
352  (void FAR *) szOutputDirUTF8.GetString());
353  }
354 
355  pfnFDIDestroy(ExtractHandler);
356  FreeLibrary(hCabinetDll);
357  return bResult;
358 }
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
BOOL(* fnFDIDestroy)(HFDI)
Definition: cabinet.cpp:275
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
char * LPSTR
Definition: xmlstorage.h:182
#define CP_UTF8
Definition: nls.h:20
#define cpuUNKNOWN
Definition: fdi.h:269
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
HFDI(* fnFDICreate)(PFNALLOC, PFNFREE, PFNOPEN, PFNREAD, PFNWRITE, PFNCLOSE, PFNSEEK, int, PERF)
Definition: cabinet.cpp:257
Definition: fci.h:44
#define LoadLibraryW(x)
Definition: compat.h:606
BOOL WideToMultiByte(const CStringW &szSource, CStringA &szDest, UINT Codepage)
Definition: cabinet.cpp:25
#define FreeLibrary(x)
Definition: compat.h:607
PCXSTR GetString() const
Definition: atlsimpstr.h:361
static const WCHAR L[]
Definition: oid.c:1250
#define NULL
Definition: types.h:112
BOOL(* fnFDICopy)(HFDI, LPSTR, LPSTR, INT, PFNFDINOTIFY, PFNFDIDECRYPT, void FAR *pvUser)
Definition: cabinet.cpp:267
#define GetProcAddress(x, y)
Definition: compat.h:612
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
#define FAR
Definition: zlib.h:34

Referenced by CAvailableApps::UpdateAppsDB().

◆ FreeLogs()

VOID FreeLogs ( )

Definition at line 241 of file misc.cpp.

242 {
243  if (hLog)
244  {
246  }
247 }
static HANDLE hLog
Definition: misc.cpp:13
BOOL WINAPI DeregisterEventSource(IN HANDLE hEventLog)
Definition: eventlog.c:473

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

◆ GetClientWindowHeight()

INT GetClientWindowHeight ( HWND  hwnd)

Definition at line 42 of file misc.cpp.

43 {
44  RECT Rect;
45 
47  return (Rect.bottom - Rect.top);
48 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
struct Rect Rect

◆ GetClientWindowWidth()

INT GetClientWindowWidth ( HWND  hwnd)

Definition at line 34 of file misc.cpp.

35 {
36  RECT Rect;
37 
39  return (Rect.right - Rect.left);
40 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
struct Rect Rect

◆ GetInstalledVersion()

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

Definition at line 310 of file misc.cpp.

311 {
312  return (!szRegName.IsEmpty()
313  && (GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_32KEY)
314  || GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_32KEY)
315  || GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_64KEY)
316  || GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_64KEY)));
317 }
#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:266

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

◆ GetStorageDirectory()

BOOL GetStorageDirectory ( ATL::CStringW lpDirectory)

Definition at line 180 of file misc.cpp.

181 {
182  LPWSTR DirectoryStr = Directory.GetBuffer(MAX_PATH);
184  {
185  Directory.ReleaseBuffer();
186  return FALSE;
187  }
188 
189  PathAppendW(DirectoryStr, L"rapps");
190  Directory.ReleaseBuffer();
191 
192  return (CreateDirectoryW(Directory.GetString(), NULL) || GetLastError() == ERROR_ALREADY_EXISTS);
193 }
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 FALSE
Definition: types.h:117
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2039
#define MAX_PATH
Definition: compat.h:34
static const WCHAR L[]
Definition: oid.c:1250
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(), CConfigParser::GetINIFullPath(), and CDownloadManager::ThreadFunc().

◆ GetSystemColorDepth()

INT GetSystemColorDepth ( )

Definition at line 509 of file misc.cpp.

510 {
511  DEVMODEW pDevMode;
512  INT ColorDepth;
513 
514  pDevMode.dmSize = sizeof(pDevMode);
515  pDevMode.dmDriverExtra = 0;
516 
518  {
519  /* TODO: Error message */
520  return ILC_COLOR;
521  }
522 
523  switch (pDevMode.dmBitsPerPel)
524  {
525  case 32: ColorDepth = ILC_COLOR32; break;
526  case 24: ColorDepth = ILC_COLOR24; break;
527  case 16: ColorDepth = ILC_COLOR16; break;
528  case 8: ColorDepth = ILC_COLOR8; break;
529  case 4: ColorDepth = ILC_COLOR4; break;
530  default: ColorDepth = ILC_COLOR; break;
531  }
532 
533  return ColorDepth;
534 }
#define ILC_COLOR16
Definition: commctrl.h:356
WORD dmDriverExtra
Definition: wingdi.h:1620
DWORD dmBitsPerPel
Definition: wingdi.h:1646
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:1619
#define NULL
Definition: types.h:112
#define ILC_COLOR8
Definition: commctrl.h:355

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

◆ GetWindowHeight()

INT GetWindowHeight ( HWND  hwnd)

Definition at line 26 of file misc.cpp.

27 {
28  RECT Rect;
29 
31  return (Rect.bottom - Rect.top);
32 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
struct Rect Rect

◆ GetWindowWidth()

INT GetWindowWidth ( HWND  hwnd)

Definition at line 18 of file misc.cpp.

19 {
20  RECT Rect;
21 
23  return (Rect.right - Rect.left);
24 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
struct Rect Rect

◆ InitLogs()

VOID InitLogs ( )

Definition at line 195 of file misc.cpp.

196 {
198  {
199  return;
200  }
201 
203  DWORD dwCategoryNum = 1;
204  DWORD dwDisp, dwData;
206 
207  if (key.Create(HKEY_LOCAL_MACHINE,
208  L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\ReactOS Application Manager",
210  {
211  return;
212  }
213 
215  {
216  return;
217  }
218 
221 
222  if ((key.SetStringValue(L"EventMessageFile",
223  szPath,
225  && (key.SetStringValue(L"CategoryMessageFile",
226  szPath,
228  && (key.SetDWORDValue(L"TypesSupported",
229  dwData) == ERROR_SUCCESS)
230  && (key.SetDWORDValue(L"CategoryCount",
231  dwCategoryNum) == ERROR_SUCCESS))
232 
233  {
234  hLog = RegisterEventSourceW(NULL, L"ReactOS Application Manager");
235  }
236 
237  key.Close();
238 }
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 EVENTLOG_ERROR_TYPE
Definition: winnt_old.h:2702
#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:2704
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:20
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define EVENTLOG_WARNING_TYPE
Definition: winnt_old.h:2703
#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
static const WCHAR L[]
Definition: oid.c:1250
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 481 of file misc.cpp.

482 {
484  {
485  // just return cached result
486  return bIsSys64Result;
487  }
488 
489  SYSTEM_INFO si;
490  typedef void (WINAPI *LPFN_PGNSI)(LPSYSTEM_INFO);
491  LPFN_PGNSI pGetNativeSystemInfo = (LPFN_PGNSI)GetProcAddress(GetModuleHandle(L"kernel32.dll"), "GetNativeSystemInfo");
492  if (pGetNativeSystemInfo)
493  {
494  pGetNativeSystemInfo(&si);
496  {
498  }
499  }
500  else
501  {
503  }
504 
505  bIsSys64ResultCached = TRUE; // next time calling this function, it will directly return bIsSys64Result
506  return bIsSys64Result;
507 }
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 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
static const WCHAR L[]
Definition: oid.c:1250
#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 434 of file misc.cpp.

435 {
436  WCHAR pszPathBuffer[MAX_PATH]; // buffer to store result
437  WCHAR pszPathCopy[MAX_PATH];
438 
439  if (!PathCanonicalizeW(pszPathCopy, pszPath))
440  {
441  return FALSE;
442  }
443 
444  PathRemoveBackslashW(pszPathCopy);
445 
446  if (StringCchCopyW(pszPathBuffer, _countof(pszPathBuffer), pszPathCopy) != S_OK)
447  {
448  return FALSE;
449  }
450 
451  if (!PathAppendW(pszPathBuffer, pszMore))
452  {
453  return FALSE;
454  }
455 
456  size_t PathLen;
457  if (StringCchLengthW(pszPathCopy, _countof(pszPathCopy), &PathLen) != S_OK)
458  {
459  return FALSE;
460  }
461  int CommonPrefixLen = PathCommonPrefixW(pszPathCopy, pszPathBuffer, NULL);
462 
463  if ((unsigned int)CommonPrefixLen != PathLen)
464  {
465  // pszPathBuffer should be a file/folder under pszPath.
466  // but now common prefix len is smaller than length of pszPathCopy
467  // hacking use ".." ?
468  return FALSE;
469  }
470 
471  if (StringCchCopyW(pszPath, MAX_PATH, pszPathBuffer) != S_OK)
472  {
473  return FALSE;
474  }
475 
476  return TRUE;
477 }
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 546 of file misc.cpp.

547 {
548  if (!*szNeedle)
549  return TRUE;
550  /* TODO: Improve pattern search beyond a simple case-insensitive substring search. */
551  return StrStrIW(szHaystack, szNeedle) != NULL;
552 }
#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().

◆ ShowPopupMenu()

VOID ShowPopupMenu ( HWND  hwnd,
UINT  MenuID,
UINT  DefaultItem 
)

Definition at line 115 of file misc.cpp.

116 {
117  ShowPopupMenuEx(hwnd, hMainWnd, MenuID, DefaultItem);
118 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
VOID ShowPopupMenuEx(HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem)
Definition: misc.cpp:76
HWND hMainWnd
Definition: magnifier.c:32

◆ ShowPopupMenuEx()

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

Definition at line 76 of file misc.cpp.

77 {
78  HMENU hMenu = NULL;
79  HMENU hPopupMenu;
80  MENUITEMINFO ItemInfo;
81  POINT pt;
82 
83  if (MenuID)
84  {
85  hMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(MenuID));
86  hPopupMenu = GetSubMenu(hMenu, 0);
87  }
88  else
89  {
90  hPopupMenu = GetMenu(hwnd);
91  }
92 
93  ZeroMemory(&ItemInfo, sizeof(ItemInfo));
94  ItemInfo.cbSize = sizeof(ItemInfo);
95  ItemInfo.fMask = MIIM_STATE;
96 
97  GetMenuItemInfoW(hPopupMenu, DefaultItem, FALSE, &ItemInfo);
98 
99  if (!(ItemInfo.fState & MFS_GRAYED))
100  {
101  SetMenuDefaultItem(hPopupMenu, DefaultItem, FALSE);
102  }
103 
104  GetCursorPos(&pt);
105 
107  TrackPopupMenu(hPopupMenu, 0, pt.x, pt.y, 0, hwndOwner, NULL);
108 
109  if (hMenu)
110  {
111  DestroyMenu(hMenu);
112  }
113 }
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(), CApplicationView::ProcessWindowMessage(), and ShowPopupMenu().

◆ StartProcess() [1/2]

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

Definition at line 121 of file misc.cpp.

122 {
123  return StartProcess(const_cast<LPWSTR>(Path.GetString()), Wait);;
124 }
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:167
PRTL_UNICODE_STRING_BUFFER Path
BOOL StartProcess(ATL::CStringW &Path, BOOL Wait)
Definition: misc.cpp:121

Referenced by CInstalledApplicationInfo::UninstallApplication().

◆ StartProcess() [2/2]

BOOL StartProcess ( LPWSTR  lpPath,
BOOL  Wait 
)

Definition at line 126 of file misc.cpp.

127 {
129  STARTUPINFOW si;
130  DWORD dwRet;
131  MSG msg;
132 
133  ZeroMemory(&si, sizeof(si));
134  si.cb = sizeof(si);
136  si.wShowWindow = SW_SHOW;
137 
138  if (!CreateProcessW(NULL, lpPath, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
139  {
140  return FALSE;
141  }
142 
143  CloseHandle(pi.hThread);
144 
145  if (Wait)
146  {
148  }
149 
150  while (Wait)
151  {
152  dwRet = MsgWaitForMultipleObjects(1, &pi.hProcess, FALSE, INFINITE, QS_ALLEVENTS);
153  if (dwRet == WAIT_OBJECT_0 + 1)
154  {
155  while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
156  {
159  }
160  }
161  else
162  {
163  if (dwRet == WAIT_OBJECT_0 || dwRet == WAIT_FAILED)
164  break;
165  }
166  }
167 
168  CloseHandle(pi.hProcess);
169 
170  if (Wait)
171  {
175  }
176 
177  return TRUE;
178 }
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)
#define FALSE
Definition: types.h:117
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define QS_ALLEVENTS
Definition: winuser.h:873
#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)
#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:1182
#define INFINITE
Definition: serial.h:102

◆ UnixTimeToFileTime()

void UnixTimeToFileTime ( DWORD  dwUnixTime,
LPFILETIME  pFileTime 
)

Definition at line 536 of file misc.cpp.

537 {
538  // Note that LONGLONG is a 64-bit value
539  LONGLONG ll;
540 
541  ll = Int32x32To64(dwUnixTime, 10000000) + 116444736000000000;
542  pFileTime->dwLowDateTime = (DWORD)ll;
543  pFileTime->dwHighDateTime = ll >> 32;
544 }
#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 CInstalledApps::Enum().

◆ WriteLogMessage()

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

Definition at line 250 of file misc.cpp.

251 {
253  {
254  return TRUE;
255  }
256 
257  if (!ReportEventW(hLog, wType, 0, dwEventID,
258  NULL, 1, 0, &lpMsg, NULL))
259  {
260  return FALSE;
261  }
262 
263  return TRUE;
264 }
#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().