ReactOS 0.4.16-dev-106-g10b08aa
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)
 
static INT_PTR CALLBACK NothingDlgProc (HWND hDlg, UINT uMsg, WPARAM, LPARAM)
 
VOID EmulateDialogReposition (HWND hwnd)
 
VOID ShowPopupMenuEx (HWND hwnd, HWND hwndOwner, UINT MenuID, UINT DefaultItem, POINT *Point)
 
BOOL StartProcess (const CStringW &Path, BOOL Wait)
 
BOOL GetStorageDirectory (CStringW &Directory)
 
VOID InitLogs ()
 
VOID FreeLogs ()
 
BOOL WriteLogMessage (WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
 
BOOL GetInstalledVersion_WowUser (CStringW *szVersionResult, const CStringW &szRegName, BOOL IsUserKey, REGSAM keyWow)
 
BOOL GetInstalledVersion (CStringW *pszVersion, const CStringW &szRegName)
 
BOOL IsSystem64Bit ()
 
INT GetSystemColorDepth ()
 
void UnixTimeToFileTime (DWORD dwUnixTime, LPFILETIME pFileTime)
 
HRESULT RegKeyHasValues (HKEY hKey, LPCWSTR Path, REGSAM wowsam)
 
LPCWSTR GetRegString (CRegKey &Key, LPCWSTR Name, CStringW &Value)
 
bool ExpandEnvStrings (CStringW &Str)
 
BOOL SearchPatternMatch (LPCWSTR szHaystack, LPCWSTR szNeedle)
 
BOOL DeleteDirectoryTree (LPCWSTR Dir, HWND hwnd)
 
UINT CreateDirectoryTree (LPCWSTR Dir)
 
CStringW SplitFileAndDirectory (LPCWSTR FullPath, CStringW *pDir)
 
HRESULT GetSpecialPath (UINT csidl, CStringW &Path, HWND hwnd)
 
HRESULT GetKnownPath (REFKNOWNFOLDERID kfid, CStringW &Path, DWORD Flags)
 
HRESULT GetProgramFilesPath (CStringW &Path, BOOL PerUser, HWND hwnd)
 

Variables

static HANDLE hLog = NULL
 

Function Documentation

◆ CopyTextToClipboard()

VOID CopyTextToClipboard ( LPCWSTR  lpszText)

Definition at line 16 of file misc.cpp.

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

Referenced by CAppInfoDisplay::OnCommand().

◆ CreateDirectoryTree()

UINT CreateDirectoryTree ( LPCWSTR  Dir)

Definition at line 459 of file misc.cpp.

460{
462 return err == ERROR_ALREADY_EXISTS ? 0 : err;
463}
#define ERROR_ALREADY_EXISTS
Definition: disk.h:80
unsigned int UINT
Definition: ndis.h:50
#define err(...)
int WINAPI SHCreateDirectory(HWND hWnd, LPCWSTR path)
Definition: shlfileop.cpp:848

Referenced by ExtractAndInstallThread(), ExtractFilesFromZip(), and InstallFiles().

◆ DeleteDirectoryTree()

BOOL DeleteDirectoryTree ( LPCWSTR  Dir,
HWND  hwnd 
)

Definition at line 446 of file misc.cpp.

447{
448 CStringW from(Dir);
449 UINT cch = from.GetLength();
450 from.Append(L"00");
451 LPWSTR p = from.GetBuffer();
452 p[cch] = p[cch + 1] = L'\0'; // Double null-terminate
454 SHFILEOPSTRUCT shfos = { hwnd, FO_DELETE, p, NULL, (FILEOP_FLAGS)fof };
455 return SHFileOperationW(&shfos);
456}
GLfloat GLfloat p
Definition: glext.h:8902
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
#define L(x)
Definition: ntvdm.h:50
#define FO_DELETE
Definition: shellapi.h:138
#define FOF_NOERRORUI
Definition: shellapi.h:151
WORD FILEOP_FLAGS
Definition: shellapi.h:213
#define FOF_NOCONFIRMATION
Definition: shellapi.h:145
#define FOF_SILENT
Definition: shellapi.h:143
int WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
Definition: shlfileop.cpp:1988
CardRegion * from
Definition: spigame.cpp:19
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by ExtractAndInstallThread(), and UninstallThread().

◆ EmulateDialogReposition()

VOID EmulateDialogReposition ( HWND  hwnd)

Definition at line 49 of file misc.cpp.

50{
51 static const DWORD DlgTmpl[] = { WS_POPUP | WS_CAPTION | WS_SYSMENU, 0, 0, 0, 0, 0 };
53 if (hDlg)
54 {
55 RECT r;
57 if (SetWindowPos(hDlg, hDlg, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE))
58 {
59 SendMessage(hDlg, DM_REPOSITION, 0, 0);
60 if (GetWindowRect(hDlg, &r))
61 SetWindowPos(hwnd, hwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, SWP_NOZORDER | SWP_NOACTIVATE);
62 }
63 SendMessage(hDlg, WM_CLOSE, 0, 0);
64 }
65}
static INT_PTR CALLBACK NothingDlgProc(HWND hDlg, UINT uMsg, WPARAM, LPARAM)
Definition: misc.cpp:43
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WS_CAPTION
Definition: pedump.c:624
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_POPUP
Definition: pedump.c:616
#define WM_CLOSE
Definition: winuser.h:1624
#define SWP_NOACTIVATE
Definition: winuser.h:1245
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SendMessage
Definition: winuser.h:5855
#define CreateDialogIndirectW(h, t, w, f)
Definition: winuser.h:4286
#define SWP_NOZORDER
Definition: winuser.h:1250
#define DM_REPOSITION
Definition: winuser.h:2103

Referenced by CMainWindow::ProcessWindowMessage().

◆ ExpandEnvStrings()

bool ExpandEnvStrings ( CStringW Str)

Definition at line 420 of file misc.cpp.

421{
424 if (cch)
425 {
426 if (ExpandEnvironmentStringsW(Str, buf.GetBuffer(cch), cch) == cch)
427 {
428 buf.ReleaseBuffer(cch - 1);
429 Str = buf;
430 return true;
431 }
432 }
433 return false;
434}
DWORD WINAPI ExpandEnvironmentStringsW(IN LPCWSTR lpSrc, IN LPWSTR lpDst, IN DWORD nSize)
Definition: environ.c:519
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751

Referenced by ExtractAndInstallThread().

◆ FreeLogs()

VOID FreeLogs ( )

Definition at line 243 of file misc.cpp.

244{
245 if (hLog)
246 {
248 }
249}
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 ( CStringW pszVersion,
const CStringW szRegName 
)

Definition at line 305 of file misc.cpp.

306{
307 return (
308 !szRegName.IsEmpty() && (GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_32KEY) ||
309 GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_32KEY) ||
310 GetInstalledVersion_WowUser(pszVersion, szRegName, TRUE, KEY_WOW64_64KEY) ||
311 GetInstalledVersion_WowUser(pszVersion, szRegName, FALSE, KEY_WOW64_64KEY)));
312}
BOOL GetInstalledVersion_WowUser(CStringW *szVersionResult, const CStringW &szRegName, BOOL IsUserKey, REGSAM keyWow)
Definition: misc.cpp:268
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define KEY_WOW64_32KEY
Definition: cmtypes.h:45
#define KEY_WOW64_64KEY
Definition: cmtypes.h:46

Referenced by CAvailableApplicationInfo::InsertVersionInfo().

◆ GetInstalledVersion_WowUser()

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

Definition at line 268 of file misc.cpp.

269{
270 BOOL bHasSucceded = FALSE;
273 CStringW szPath = CStringW(L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\") + szRegName;
274
275 if (key.Open(IsUserKey ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE, szPath.GetString(), keyWow | KEY_READ) !=
277 {
278 return FALSE;
279 }
280
281 if (szVersionResult != NULL)
282 {
283 ULONG dwSize = MAX_PATH * sizeof(WCHAR);
284
285 if (key.QueryStringValue(L"DisplayVersion", szVersion.GetBuffer(MAX_PATH), &dwSize) == ERROR_SUCCESS)
286 {
287 szVersion.ReleaseBuffer();
288 *szVersionResult = szVersion;
289 bHasSucceded = TRUE;
290 }
291 else
292 {
293 szVersion.ReleaseBuffer();
294 }
295 }
296 else
297 {
298 bHasSucceded = TRUE;
299 }
300
301 return bHasSucceded;
302}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define MAX_PATH
Definition: compat.h:34
unsigned int BOOL
Definition: ntddk_ex.h:94
LPCWSTR szPath
Definition: env.c:37
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
static LPCWSTR szVersion
Definition: asmcache.c:748
CAtlStringW CStringW
Definition: atlstr.h:130
#define KEY_READ
Definition: nt_native.h:1023
Definition: copy.c:22
uint32_t ULONG
Definition: typedefs.h:59
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11

Referenced by GetInstalledVersion().

◆ GetKnownPath()

HRESULT GetKnownPath ( REFKNOWNFOLDERID  kfid,
CStringW Path,
DWORD  Flags 
)

Definition at line 487 of file misc.cpp.

488{
489 PWSTR p;
490 FARPROC f = GetProcAddress(LoadLibraryW(L"SHELL32"), "SHGetKnownFolderPath");
491 if (!f)
494 if (FAILED(hr))
495 return hr;
496 Path = p;
498 return hr;
499}
PRTL_UNICODE_STRING_BUFFER Path
int(* FARPROC)()
Definition: compat.h:36
#define GetProcAddress(x, y)
Definition: compat.h:753
#define LoadLibraryW(x)
Definition: compat.h:747
GLfloat f
Definition: glext.h:7540
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
#define FAILED(hr)
Definition: intsafe.h:51
#define f
Definition: ke_i.h:83
KNOWNFOLDERID * REFKNOWNFOLDERID
Definition: shtypes.idl:147
uint16_t * PWSTR
Definition: typedefs.h:56
PVOID HANDLE
Definition: typedefs.h:73
#define WINAPI
Definition: msvc.h:6
#define HRESULT_FROM_WIN32(x)
Definition: winerror.h:92
#define ERROR_OLD_WIN_VERSION
Definition: winerror.h:672
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by GetProgramFilesPath().

◆ GetProgramFilesPath()

HRESULT GetProgramFilesPath ( CStringW Path,
BOOL  PerUser,
HWND  hwnd 
)

Definition at line 502 of file misc.cpp.

503{
504 if (!PerUser)
506
507 HRESULT hr = GetKnownPath(FOLDERID_UserProgramFiles, Path);
508 if (FAILED(hr))
509 {
511 // Use the correct path on NT6 (on NT5 the path becomes a bit long)
512 if (SUCCEEDED(hr) && LOBYTE(GetVersion()) >= 6)
513 {
514 Path = BuildPath(Path, L"Programs"); // Should not be localized
515 }
516 }
517 return hr;
518}
static CStringW BuildPath(const T &Base, LPCWSTR Append)
Definition: misc.h:93
HRESULT GetKnownPath(REFKNOWNFOLDERID kfid, CStringW &Path, DWORD Flags)
Definition: misc.cpp:487
HRESULT GetSpecialPath(UINT csidl, CStringW &Path, HWND hwnd)
Definition: misc.cpp:478
#define LOBYTE(W)
Definition: jmemdos.c:487
DWORD WINAPI GetVersion()
Definition: redirtest.c:5
#define CSIDL_PROGRAM_FILES
Definition: shlobj.h:2210
#define CSIDL_LOCAL_APPDATA
Definition: shlobj.h:2200

Referenced by ExtractAndInstallThread().

◆ GetRegString()

LPCWSTR GetRegString ( CRegKey Key,
LPCWSTR  Name,
CStringW Value 
)

Definition at line 397 of file misc.cpp.

398{
399 for (;;)
400 {
401 ULONG cb = 0, cch;
402 ULONG err = Key.QueryValue(Name, NULL, NULL, &cb);
403 if (err)
404 break;
405 cch = cb / sizeof(WCHAR);
406 LPWSTR p = Value.GetBuffer(cch + 1);
407 p[cch] = UNICODE_NULL;
408 err = Key.QueryValue(Name, NULL, (BYTE*)p, &cb);
409 if (err == ERROR_MORE_DATA)
410 continue;
411 if (err)
412 break;
413 Value.ReleaseBuffer();
414 return Value.GetString();
415 }
416 return NULL;
417}
#define ERROR_MORE_DATA
Definition: dderror.h:13
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
#define UNICODE_NULL
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
unsigned char BYTE
Definition: xxhash.c:193

Referenced by GetLocalizedSMFolderName(), and UninstallThread().

◆ GetSpecialPath()

HRESULT GetSpecialPath ( UINT  csidl,
CStringW Path,
HWND  hwnd 
)

Definition at line 478 of file misc.cpp.

479{
480 if (!SHGetSpecialFolderPathW(hwnd, Path.GetBuffer(MAX_PATH), csidl, TRUE))
481 return E_FAIL;
482 Path.ReleaseBuffer();
483 return S_OK;
484}
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI SHGetSpecialFolderPathW(HWND hwndOwner, LPWSTR szPath, int nFolder, BOOL bCreate)
Definition: shellpath.c:3092
#define S_OK
Definition: intsafe.h:52

Referenced by CreateShortcut(), and GetProgramFilesPath().

◆ GetStorageDirectory()

BOOL GetStorageDirectory ( CStringW Directory)

Definition at line 170 of file misc.cpp.

171{
172 static CStringW CachedDirectory;
173 static BOOL CachedDirectoryInitialized = FALSE;
174
175 if (!CachedDirectoryInitialized)
176 {
177 LPWSTR DirectoryStr = CachedDirectory.GetBuffer(MAX_PATH);
178 BOOL bHasPath = SHGetSpecialFolderPathW(NULL, DirectoryStr, CSIDL_LOCAL_APPDATA, TRUE);
179 if (bHasPath)
180 {
181 PathAppendW(DirectoryStr, RAPPS_NAME);
182 }
183 CachedDirectory.ReleaseBuffer();
184
185 if (bHasPath)
186 {
187 if (!CreateDirectoryW(CachedDirectory, NULL) && GetLastError() != ERROR_ALREADY_EXISTS)
188 {
189 CachedDirectory.Empty();
190 }
191 }
192 else
193 {
194 CachedDirectory.Empty();
195 }
196
197 CachedDirectoryInitialized = TRUE;
198 }
199
200 Directory = CachedDirectory;
201 return !Directory.IsEmpty();
202}
#define RAPPS_NAME
Definition: defines.h:34
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:387
void Empty() noexcept
Definition: atlsimpstr.h:253
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
#define PathAppendW
Definition: pathcch.h:309
base for all directory entries
Definition: entries.h:138
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by ParseCmdAndExecute(), CAppInfoDisplay::ProcessWindowMessage(), and CDownloadManager::ThreadFunc().

◆ GetSystemColorDepth()

INT GetSystemColorDepth ( )

Definition at line 328 of file misc.cpp.

329{
330 DEVMODEW pDevMode;
331 INT ColorDepth;
332
333 pDevMode.dmSize = sizeof(pDevMode);
334 pDevMode.dmDriverExtra = 0;
335
337 {
338 /* TODO: Error message */
339 return ILC_COLOR;
340 }
341
342 switch (pDevMode.dmBitsPerPel)
343 {
344 case 32:
345 ColorDepth = ILC_COLOR32;
346 break;
347 case 24:
348 ColorDepth = ILC_COLOR24;
349 break;
350 case 16:
351 ColorDepth = ILC_COLOR16;
352 break;
353 case 8:
354 ColorDepth = ILC_COLOR8;
355 break;
356 case 4:
357 ColorDepth = ILC_COLOR4;
358 break;
359 default:
360 ColorDepth = ILC_COLOR;
361 break;
362 }
363
364 return ColorDepth;
365}
#define ILC_COLOR4
Definition: commctrl.h:354
#define ILC_COLOR16
Definition: commctrl.h:356
#define ILC_COLOR8
Definition: commctrl.h:355
#define ILC_COLOR32
Definition: commctrl.h:358
#define ILC_COLOR24
Definition: commctrl.h:357
#define ILC_COLOR
Definition: commctrl.h:352
DWORD dmBitsPerPel
Definition: wingdi.h:1647
WORD dmDriverExtra
Definition: wingdi.h:1621
WORD dmSize
Definition: wingdi.h:1620
int32_t INT
Definition: typedefs.h:58
BOOL WINAPI EnumDisplaySettingsW(LPCWSTR lpszDeviceName, DWORD iModeNum, LPDEVMODEW lpDevMode)
Definition: display.c:408
#define ENUM_CURRENT_SETTINGS
Definition: winuser.h:179

Referenced by ApplicationPageWndProc(), CMainToolbar::InitImageList(), and CAppsListView::SetDisplayAppType().

◆ InitLogs()

VOID InitLogs ( )

Definition at line 205 of file misc.cpp.

206{
208 {
209 return;
210 }
211
213 DWORD dwCategoryNum = 1;
214 DWORD dwDisp, dwData;
216
217 if (key.Create(
219 L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\ReactOS Application Manager", REG_NONE,
221 {
222 return;
223 }
224
226 {
227 return;
228 }
229
231
232 if ((key.SetStringValue(L"EventMessageFile", szPath, REG_EXPAND_SZ) == ERROR_SUCCESS) &&
233 (key.SetStringValue(L"CategoryMessageFile", szPath, REG_EXPAND_SZ) == ERROR_SUCCESS) &&
234 (key.SetDWORDValue(L"TypesSupported", dwData) == ERROR_SUCCESS) &&
235 (key.SetDWORDValue(L"CategoryCount", dwCategoryNum) == ERROR_SUCCESS))
236
237 {
238 hLog = RegisterEventSourceW(NULL, L"ReactOS Application Manager");
239 }
240}
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:21
HANDLE WINAPI RegisterEventSourceW(IN LPCWSTR lpUNCServerName, IN LPCWSTR lpSourceName)
Definition: eventlog.c:1295
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
static HANDLE ULONG_PTR dwData
Definition: file.c:35
#define REG_OPTION_NON_VOLATILE
Definition: nt_native.h:1057
#define KEY_WRITE
Definition: nt_native.h:1031
#define REG_NONE
Definition: nt_native.h:1492
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define _countof(array)
Definition: sndvol32.h:70
BOOL bLogEnabled
Definition: settings.h:9
#define EVENTLOG_ERROR_TYPE
Definition: winnt_old.h:2834
#define EVENTLOG_INFORMATION_TYPE
Definition: winnt_old.h:2836
#define EVENTLOG_WARNING_TYPE
Definition: winnt_old.h:2835

Referenced by wmain(), and wWinMain().

◆ IsSystem64Bit()

BOOL IsSystem64Bit ( )

Definition at line 315 of file misc.cpp.

316{
317#ifdef _WIN64
318 return TRUE;
319#else
320 static UINT cache = 0;
321 if (!cache)
322 cache = 1 + (IsOS(OS_WOW6432) != FALSE);
323 return cache - 1;
324#endif
325}
BOOL WINAPI IsOS(DWORD feature)
Definition: ordinal.c:4107
#define OS_WOW6432
Definition: shlwapi.h:2048
Definition: cache.c:49

Referenced by CAppDB::EnumInstalledRootKey(), and ExtractAndInstallThread().

◆ NothingDlgProc()

static INT_PTR CALLBACK NothingDlgProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  ,
LPARAM   
)
static

Definition at line 43 of file misc.cpp.

44{
45 return uMsg == WM_CLOSE ? DestroyWindow(hDlg) : FALSE;
46}
BOOL WINAPI DestroyWindow(_In_ HWND)

Referenced by EmulateDialogReposition().

◆ RegKeyHasValues()

HRESULT RegKeyHasValues ( HKEY  hKey,
LPCWSTR  Path,
REGSAM  wowsam 
)

Definition at line 379 of file misc.cpp.

380{
381 CRegKey key;
382 LONG err = key.Open(hKey, Path, KEY_QUERY_VALUE | wowsam);
383 if (err == ERROR_SUCCESS)
384 {
385 WCHAR name[1];
386 DWORD cchname = _countof(name), cbsize = 0;
387 err = RegEnumValueW(key, 0, name, &cchname, NULL, NULL, NULL, &cbsize);
389 return S_FALSE;
390 if (err == ERROR_MORE_DATA)
392 }
393 return HRESULT_FROM_WIN32(err);
394}
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
FxAutoRegKey hKey
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
long LONG
Definition: pedump.c:60
Definition: name.c:39
#define S_FALSE
Definition: winerror.h:2357

Referenced by UninstallThread().

◆ SearchPatternMatch()

BOOL SearchPatternMatch ( LPCWSTR  szHaystack,
LPCWSTR  szNeedle 
)

Definition at line 437 of file misc.cpp.

438{
439 if (!*szNeedle)
440 return TRUE;
441 /* TODO: Improve pattern search beyond a simple case-insensitive substring search. */
442 return StrStrIW(szHaystack, szNeedle) != NULL;
443}
LPWSTR WINAPI StrStrIW(LPCWSTR lpszStr, LPCWSTR lpszSearch)
Definition: string.c:380

Referenced by CMainWindow::AddApplicationsToView(), HandleFindCommand(), and SearchForAppWithDisplayName().

◆ ShowPopupMenuEx()

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

Definition at line 68 of file misc.cpp.

69{
70 HMENU hMenu = NULL;
71 HMENU hPopupMenu;
72 MENUITEMINFO ItemInfo;
73 POINT pt;
74
75 if (MenuID)
76 {
77 hMenu = LoadMenuW(hInst, MAKEINTRESOURCEW(MenuID));
78 hPopupMenu = GetSubMenu(hMenu, 0);
79 }
80 else
81 {
82 hPopupMenu = GetMenu(hwnd);
83 }
84
85 ZeroMemory(&ItemInfo, sizeof(ItemInfo));
86 ItemInfo.cbSize = sizeof(ItemInfo);
87 ItemInfo.fMask = MIIM_STATE;
88
89 GetMenuItemInfoW(hPopupMenu, DefaultItem, FALSE, &ItemInfo);
90
91 if (!(ItemInfo.fState & MFS_GRAYED))
92 {
93 SetMenuDefaultItem(hPopupMenu, DefaultItem, FALSE);
94 }
95
96 if (!Point)
97 {
99 }
100
102 TrackPopupMenu(hPopupMenu, 0, Point->x, Point->y, 0, hwndOwner, NULL);
103
104 if (hMenu)
105 {
106 DestroyMenu(hMenu);
107 }
108}
#define pt(x, y)
Definition: drawing.c:79
HINSTANCE hInst
Definition: dxdiag.c:13
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define ZeroMemory
Definition: winbase.h:1712
BOOL WINAPI SetMenuDefaultItem(_In_ HMENU, _In_ UINT, _In_ UINT)
BOOL WINAPI SetForegroundWindow(_In_ HWND)
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2722
#define MIIM_STATE
Definition: winuser.h:724
HMENU WINAPI GetSubMenu(_In_ HMENU, _In_ int)
#define MFS_GRAYED
Definition: winuser.h:754
BOOL WINAPI DestroyMenu(_In_ HMENU)
BOOL WINAPI GetMenuItemInfoW(_In_ HMENU, _In_ UINT, _In_ BOOL, _Inout_ LPMENUITEMINFOW)
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HMENU WINAPI LoadMenuW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
HMENU WINAPI GetMenu(_In_ HWND)

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

◆ SplitFileAndDirectory()

CStringW SplitFileAndDirectory ( LPCWSTR  FullPath,
CStringW pDir 
)

Definition at line 466 of file misc.cpp.

467{
468 CPathW dir = FullPath;
469 //int win = dir.ReverseFind(L'\\'), nix = dir.ReverseFind(L'/'), sep = max(win, nix);
470 int sep = dir.FindFileName();
471 CStringW file = dir.m_strPath.Mid(sep);
472 if (pDir)
473 *pDir = sep == -1 ? L"" : dir.m_strPath.Left(sep - 1);
474 return file;
475}
unsigned int dir
Definition: maze.c:112
Definition: fci.c:127

Referenced by CreateShortcut(), ExtractAndInstallThread(), ExtractFilesFromCab(), ExtractFilesFromZip(), InstallFiles(), and UninstallThread().

◆ StartProcess()

BOOL StartProcess ( const CStringW Path,
BOOL  Wait 
)

Definition at line 111 of file misc.cpp.

112{
114 STARTUPINFOW si;
115 DWORD dwRet;
116 MSG msg;
117
118 ZeroMemory(&si, sizeof(si));
119 si.cb = sizeof(si);
121 si.wShowWindow = SW_SHOW;
122
123 // The Unicode version of CreateProcess can modify the contents of this string.
124 CStringW Tmp = Path;
125 BOOL fSuccess = CreateProcessW(NULL, Tmp.GetBuffer(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
126 Tmp.ReleaseBuffer();
127 if (!fSuccess)
128 {
129 return FALSE;
130 }
131
132 CloseHandle(pi.hThread);
133
134 if (Wait)
135 {
137 }
138
139 while (Wait)
140 {
141 dwRet = MsgWaitForMultipleObjects(1, &pi.hProcess, FALSE, INFINITE, QS_ALLEVENTS);
142 if (dwRet == WAIT_OBJECT_0 + 1)
143 {
144 while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE))
145 {
148 }
149 }
150 else
151 {
152 if (dwRet == WAIT_OBJECT_0 || dwRet == WAIT_FAILED)
153 break;
154 }
155 }
156
157 CloseHandle(pi.hProcess);
158
159 if (Wait)
160 {
164 }
165
166 return TRUE;
167}
#define msg(x)
Definition: auth_time.c:54
#define CloseHandle
Definition: compat.h:739
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:4598
#define INFINITE
Definition: serial.h:102
HWND hMainWnd
Definition: magnifier.c:32
static refpint_t pi[]
Definition: server.c:96
DWORD cb
Definition: winbase.h:852
DWORD dwFlags
Definition: winbase.h:863
WORD wShowWindow
Definition: winbase.h:864
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170
#define STARTF_USESHOWWINDOW
Definition: winbase.h:491
#define WAIT_OBJECT_0
Definition: winbase.h:406
#define WAIT_FAILED
Definition: winbase.h:413
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define QS_ALLEVENTS
Definition: winuser.h:905
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
HWND WINAPI SetFocus(_In_opt_ HWND)
BOOL WINAPI PeekMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT, _In_ UINT)
#define PM_REMOVE
Definition: winuser.h:1199
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
LRESULT WINAPI DispatchMessageW(_In_ const MSG *)
#define SW_SHOW
Definition: winuser.h:778

Referenced by CInstalledApplicationInfo::UninstallApplication().

◆ UnixTimeToFileTime()

void UnixTimeToFileTime ( DWORD  dwUnixTime,
LPFILETIME  pFileTime 
)

Definition at line 368 of file misc.cpp.

369{
370 // Note that LONGLONG is a 64-bit value
371 LONGLONG ll;
372
373 ll = Int32x32To64(dwUnixTime, 10000000) + 116444736000000000;
374 pFileTime->dwLowDateTime = (DWORD)ll;
375 pFileTime->dwHighDateTime = ll >> 32;
376}
w ll
Definition: byte_order.h:167
#define DWORD
Definition: nt_native.h:44
#define Int32x32To64(a, b)
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
int64_t LONGLONG
Definition: typedefs.h:68

Referenced by CInstalledApplicationInfo::RetrieveInstallDate().

◆ WriteLogMessage()

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

Definition at line 252 of file misc.cpp.

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

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

Variable Documentation

◆ hLog