ReactOS  0.4.14-dev-606-g14ebc0b
utility.cpp File Reference
#include <precomp.h>
#include <time.h>
#include <sstream>
Include dependency graph for utility.cpp:

Go to the source code of this file.

Macros

#define CONTROL_RUNDLL   "Control_RunDLLA"
 

Typedefs

typedef void(WINAPIRUNDLLPROC) (HWND hwnd, HINSTANCE hinst, LPCTSTR cmdline, DWORD nCmdShow)
 

Functions

void CenterWindow (HWND hwnd)
 
void MoveVisible (HWND hwnd)
 
void display_error (HWND hwnd, DWORD error)
 
BOOL time_to_filetime (const time_t *t, FILETIME *ftime)
 
BOOL launch_file (HWND hwnd, LPCTSTR cmd, UINT nCmdShow, LPCTSTR parameters)
 
static BOOL CALLBACK EnumWndProc (HWND hwnd, LPARAM lparam)
 
int find_window_class (LPCTSTR classname)
 
String get_windows_version_str ()
 
BOOL RunDLL (HWND hwnd, LPCTSTR dllname, LPCSTR procname, LPCTSTR cmdline, UINT nCmdShow)
 
BOOL launch_cpanel (HWND hwnd, LPCTSTR applet)
 
BOOL RecursiveCreateDirectory (LPCTSTR path_in)
 
DWORD RegGetDWORDValue (HKEY root, LPCTSTR path, LPCTSTR valueName, DWORD def)
 
BOOL RegSetDWORDValue (HKEY root, LPCTSTR path, LPCTSTR valueName, DWORD value)
 
BOOL exists_path (LPCTSTR path)
 
bool SplitFileSysURL (LPCTSTR url, String &dir_out, String &fname_out)
 

Variables

static int g_foundPrevInstance = 0
 

Macro Definition Documentation

◆ CONTROL_RUNDLL

#define CONTROL_RUNDLL   "Control_RunDLLA"

Definition at line 380 of file utility.cpp.

Typedef Documentation

◆ RUNDLLPROC

typedef void(WINAPI* RUNDLLPROC) (HWND hwnd, HINSTANCE hinst, LPCTSTR cmdline, DWORD nCmdShow)

Definition at line 347 of file utility.cpp.

Function Documentation

◆ CenterWindow()

void CenterWindow ( HWND  hwnd)

Definition at line 49 of file utility.cpp.

50 {
51  RECT rt, prt;
52  GetWindowRect(hwnd, &rt);
53 
54  DWORD style;
55  HWND owner = 0;
56 
57  for(HWND wh=hwnd; (wh=GetWindow(wh,GW_OWNER))!=0; )
59  {owner=wh; break;}
60 
61  if (owner)
62  GetWindowRect(owner, &prt);
63  else
64  SystemParametersInfo(SPI_GETWORKAREA, 0, &prt, 0); //@@ GetDesktopWindow() wäre auch hilfreich.
65 
66  SetWindowPos(hwnd, 0, (prt.left+prt.right+rt.left-rt.right)/2,
67  (prt.top+prt.bottom+rt.top-rt.bottom)/2, 0,0, SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
68 
70 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
void MoveVisible(HWND hwnd)
Definition: utility.cpp:72
#define SystemParametersInfo
Definition: winuser.h:5833
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define SWP_NOZORDER
Definition: winuser.h:1232
LONG right
Definition: windef.h:308
#define GetWindowStyle(hwnd)
Definition: windowsx.h:290
#define WS_MINIMIZE
Definition: pedump.c:622
#define SWP_NOACTIVATE
Definition: winuser.h:1227
unsigned long DWORD
Definition: ntddk_ex.h:95
HWND WINAPI GetWindow(_In_ HWND, _In_ UINT)
#define SWP_NOSIZE
Definition: winuser.h:1230
#define GW_OWNER
Definition: winuser.h:761
LONG bottom
Definition: windef.h:309
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)
Arabic default style
Definition: afstyles.h:93
#define WS_VISIBLE
Definition: pedump.c:620

◆ display_error()

void display_error ( HWND  hwnd,
DWORD  error 
)

Definition at line 98 of file utility.cpp.

99 {
100  PTSTR msg;
101 
104  LOG(FmtString(TEXT("display_error(%#x): %s"), error, msg));
105 
106  SetLastError(0);
107  MessageBox(hwnd, msg, TEXT("ROS Explorer"), MB_OK);
108 
110  MessageBox(0, msg, TEXT("ROS Explorer"), MB_OK);
111  } else {
112  LOG(FmtString(TEXT("Unknown Error %#x"), error));
113 
114  FmtString msg(TEXT("Unknown Error %#x"), error);
115 
116  SetLastError(0);
117  MessageBox(hwnd, msg, TEXT("ROS Explorer"), MB_OK);
118 
120  MessageBox(0, msg, TEXT("ROS Explorer"), MB_OK);
121  }
122 
123  LocalFree(msg);
124 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define error(str)
Definition: mkdosfs.c:1605
#define LANG_NEUTRAL
Definition: nls.h:22
#define SUBLANG_DEFAULT
Definition: nls.h:168
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:400
smooth NULL
Definition: ftsmooth.c:416
CHAR * PTSTR
Definition: xmlstorage.h:191
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:404
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:881
#define SetLastError(x)
Definition: compat.h:417
#define FormatMessage
Definition: winbase.h:3629
#define MessageBox
Definition: winuser.h:5797
#define LOG(txt)
Definition: utility.h:102
#define TEXT(s)
Definition: k32.h:26
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
#define MB_OK
Definition: winuser.h:784
#define msg(x)
Definition: auth_time.c:54
#define MAKELANGID(p, s)
Definition: nls.h:15

Referenced by StartMenu::ActivateEntry(), MainFrameBase::Command(), MDIMainFrame::Command(), ShellEntry::launch_entry(), and launch_file().

◆ EnumWndProc()

static BOOL CALLBACK EnumWndProc ( HWND  hwnd,
LPARAM  lparam 
)
static

Definition at line 222 of file utility.cpp.

223 {
224  TCHAR cls[128];
225 
226  GetClassName(hwnd, cls, 128);
227 
228  if (!lstrcmp(cls, (LPCTSTR)lparam)) {
230  return FALSE;
231  }
232 
233  return TRUE;
234 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
static int g_foundPrevInstance
Definition: utility.cpp:220
static UINT WPARAM LPARAM lparam
Definition: combo.c:716
char TCHAR
Definition: xmlstorage.h:189
#define lstrcmp
Definition: winbase.h:3706
#define GetClassName
Definition: winuser.h:5758

Referenced by find_window_class().

◆ exists_path()

BOOL exists_path ( LPCTSTR  path)

Definition at line 489 of file utility.cpp.

490 {
492 
493  HANDLE hfind = FindFirstFile(path, &fd);
494 
495  if (hfind != INVALID_HANDLE_VALUE) {
496  FindClose(hfind);
497 
498  return TRUE;
499  } else
500  return FALSE;
501 }
#define TRUE
Definition: types.h:120
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
static int fd
Definition: io.c:51
#define FindFirstFile
Definition: winbase.h:3616
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by SplitFileSysURL().

◆ find_window_class()

int find_window_class ( LPCTSTR  classname)

Definition at line 237 of file utility.cpp.

238 {
240 
242  return 1;
243 
244  return 0;
245 }
static int g_foundPrevInstance
Definition: utility.cpp:220
WCHAR classname[128]
Definition: startup.c:15
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC, _In_ LPARAM)
static BOOL CALLBACK EnumWndProc(HWND hwnd, LPARAM lparam)
Definition: utility.cpp:222

◆ get_windows_version_str()

String get_windows_version_str ( )

Definition at line 248 of file utility.cpp.

249 {
251  BOOL osvie_val;
252  String str;
253 
254  if (!(osvie_val = GetVersionEx((OSVERSIONINFO*)&osvi))) {
256 
258  return TEXT("???");
259  }
260 
261  switch(osvi.dwPlatformId) {
263 #ifdef __REACTOS__ // This work around can be removed if ReactOS gets a unique version number.
264  str = TEXT("ReactOS");
265 #else
266  if (osvi.dwMajorVersion <= 4)
267  str = TEXT("Microsoft Windows NT");
268  else if (osvi.dwMajorVersion==5 && osvi.dwMinorVersion==0)
269  str = TEXT("Microsoft Windows 2000");
270  else if (osvi.dwMajorVersion==5 && osvi.dwMinorVersion==1)
271  str = TEXT("Microsoft Windows XP");
272 #endif
273 
274  if (osvie_val) {
275  if (osvi.wProductType == VER_NT_WORKSTATION) {
276  if (osvi.wSuiteMask & VER_SUITE_PERSONAL)
277  str += TEXT(" Personal");
278  else
279  str += TEXT(" Professional");
280  } else if (osvi.wProductType == VER_NT_SERVER) {
281  if (osvi.wSuiteMask & VER_SUITE_DATACENTER)
282  str += TEXT(" DataCenter Server");
283  else if (osvi.wSuiteMask & VER_SUITE_ENTERPRISE)
284  str += TEXT(" Advanced Server");
285  else
286  str += TEXT(" Server");
287  } else if (osvi.wProductType == VER_NT_DOMAIN_CONTROLLER) {
288  str += TEXT(" Domain Controller");
289  }
290  } else {
291  TCHAR type[80];
292  DWORD dwBufLen;
293  HKEY hkey;
294 
295  if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("SYSTEM\\CurrentControlSet\\Control\\ProductOptions"), 0, KEY_QUERY_VALUE, &hkey)) {
296  RegQueryValueEx(hkey, TEXT("ProductType"), NULL, NULL, (LPBYTE)type, &dwBufLen);
297  RegCloseKey(hkey);
298 
299  if (!_tcsicmp(TEXT("WINNT"), type))
300  str += TEXT(" Workstation");
301  else if (!_tcsicmp(TEXT("LANMANNT"), type))
302  str += TEXT(" Server");
303  else if (!_tcsicmp(TEXT("SERVERNT"), type))
304  str += TEXT(" Advanced Server");
305  }
306  }
307  break;
308 
310  if (osvi.dwMajorVersion>4 ||
312  if (osvi.dwMinorVersion == 90)
313  str = TEXT("Microsoft Windows ME");
314  else
315  str = TEXT("Microsoft Windows 98");
316 
317  if (osvi.szCSDVersion[1] == 'A')
318  str += TEXT(" SE");
319  } else {
320  str = TEXT("Microsoft Windows 95");
321 
322  if (osvi.szCSDVersion[1]=='B' || osvi.szCSDVersion[1]=='C')
323  str += TEXT(" OSR2");
324  }
325  break;
326 
327  case VER_PLATFORM_WIN32s:
328  str = TEXT("Microsoft Win32s");
329 
330  default:
331  return TEXT("???");
332  }
333 
334  String vstr;
335 
336  if (osvi.dwMajorVersion <= 4)
337  vstr.printf(TEXT(" Version %d.%d %s Build %d"),
340  else
341  vstr.printf(TEXT(" %s (Build %d)"), osvi.szCSDVersion, osvi.dwBuildNumber&0xFFFF);
342 
343  return str + vstr;
344 }
#define RegQueryValueEx
Definition: winreg.h:524
#define VER_NT_WORKSTATION
#define VER_PLATFORM_WIN32_NT
Definition: rtltypes.h:236
ULONG dwMajorVersion
Definition: rtltypes.h:234
OSVERSIONINFO osvi
Definition: ver.c:28
#define _tcsicmp
Definition: xmlstorage.h:205
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static WCHAR String[]
Definition: stringtable.c:55
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_ DWORD _In_ DWORD dwBufLen
Definition: wincrypt.h:4245
#define VER_SUITE_DATACENTER
#define VER_SUITE_ENTERPRISE
#define VER_SUITE_PERSONAL
#define VER_PLATFORM_WIN32s
Definition: rtltypes.h:234
OSVERSIONINFOA OSVERSIONINFO
Definition: rtltypes.h:289
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
#define VER_NT_DOMAIN_CONTROLLER
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:233
ULONG dwBuildNumber
Definition: rtltypes.h:236
char TCHAR
Definition: xmlstorage.h:189
unsigned long DWORD
Definition: ntddk_ex.h:95
ULONG dwMinorVersion
Definition: rtltypes.h:235
#define RegOpenKeyEx
Definition: winreg.h:520
#define TEXT(s)
Definition: k32.h:26
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
ULONG dwPlatformId
Definition: rtltypes.h:237
#define GetVersionEx
Definition: winbase.h:3686
#define VER_PLATFORM_WIN32_WINDOWS
Definition: rtltypes.h:235
#define VER_NT_SERVER
OSVERSIONINFOEXA OSVERSIONINFOEX
Definition: rtltypes.h:286
CHAR szCSDVersion[128]
Definition: rtltypes.h:238
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by ExplorerAboutDlg::ExplorerAboutDlg().

◆ launch_cpanel()

BOOL launch_cpanel ( HWND  hwnd,
LPCTSTR  applet 
)

Definition at line 383 of file utility.cpp.

384 {
385  TCHAR parameters[MAX_PATH];
386 
387  _tcscpy(parameters, TEXT("shell32.dll,Control_RunDLL "));
388  _tcscat(parameters, applet);
389 
390  return ((INT_PTR)ShellExecute(hwnd, TEXT("open"), TEXT("rundll32.exe"), parameters, NULL, SW_SHOWDEFAULT) > 32);
391 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define SW_SHOWDEFAULT
Definition: winuser.h:774
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
int32_t INT_PTR
Definition: typedefs.h:62
#define ShellExecute
Definition: shellapi.h:689
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
#define MAX_PATH
Definition: compat.h:26
#define TEXT(s)
Definition: k32.h:26
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8

Referenced by DesktopBar::Command(), NotifyArea::Command(), and ClockWindow::WndProc().

◆ launch_file()

BOOL launch_file ( HWND  hwnd,
LPCTSTR  cmd,
UINT  nCmdShow,
LPCTSTR  parameters 
)

Definition at line 189 of file utility.cpp.

190 {
191  CONTEXT("launch_file()");
192 
193  HINSTANCE hinst = ShellExecute(hwnd, NULL/*operation*/, cmd, parameters, NULL/*dir*/, nCmdShow);
194 
195  if ((INT_PTR)hinst <= 32) {
197  return FALSE;
198  }
199 
200  return TRUE;
201 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
Definition: ftp_var.h:139
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
int32_t INT_PTR
Definition: typedefs.h:62
struct _CONTEXT CONTEXT
#define ShellExecute
Definition: shellapi.h:689
smooth NULL
Definition: ftsmooth.c:416
void display_error(HWND hwnd, DWORD error)
Definition: utility.cpp:98
static HINSTANCE hinst
Definition: edit.c:551

Referenced by MainFrameBase::Command(), DesktopBar::Command(), StartMenuHandler::Command(), FavoritesMenu::Command(), Entry::launch_entry(), and DesktopBar::WndProc().

◆ MoveVisible()

void MoveVisible ( HWND  hwnd)

Definition at line 72 of file utility.cpp.

73 {
74  RECT rc;
75  GetWindowRect(hwnd, &rc);
76  int left=rc.left, top=rc.top;
77 
78  int xmax = GetSystemMetrics(SM_CXSCREEN);
79  int ymax = GetSystemMetrics(SM_CYSCREEN);
80 
81  if (rc.left < 0)
82  rc.left = 0;
83  else if (rc.right > xmax)
84  if ((rc.left-=rc.right-xmax) < 0)
85  rc.left = 0;
86 
87  if (rc.top < 0)
88  rc.top = 0;
89  else if (rc.bottom > ymax)
90  if ((rc.top-=rc.bottom-ymax) < 0)
91  rc.top = 0;
92 
93  if (rc.left!=left || rc.top!=top)
95 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define SWP_NOZORDER
Definition: winuser.h:1232
LONG right
Definition: windef.h:308
#define SM_CXSCREEN
Definition: winuser.h:949
#define SM_CYSCREEN
Definition: winuser.h:950
#define SWP_NOACTIVATE
Definition: winuser.h:1227
int WINAPI GetSystemMetrics(_In_ int)
GLint left
Definition: glext.h:7726
#define SWP_NOSIZE
Definition: winuser.h:1230
LONG bottom
Definition: windef.h:309
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)
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859

Referenced by CenterWindow(), StartMenu::Create(), and ResizeManager::Resize().

◆ RecursiveCreateDirectory()

BOOL RecursiveCreateDirectory ( LPCTSTR  path_in)

Definition at line 394 of file utility.cpp.

395 {
396  TCHAR path[MAX_PATH], hole_path[MAX_PATH];
397 
398  _tcscpy(hole_path, path_in);
399 
400  int drv_len = 0;
401  LPCTSTR d;
402 
403  for(d=hole_path; *d && *d!='/' && *d!='\\'; ++d) {
404  ++drv_len;
405 
406  if (*d == ':')
407  break;
408  }
409 
410  LPTSTR dir = hole_path + drv_len;
411 
412  int l;
413  LPTSTR p = hole_path + (l=_tcslen(hole_path));
414 
415  while(--p>=hole_path && (*p=='/' || *p=='\\'))
416  *p = '\0';
417 
418  WIN32_FIND_DATA w32fd;
419 
420  HANDLE hFind = FindFirstFile(hole_path, &w32fd);
421 
422  if (hFind == INVALID_HANDLE_VALUE) {
423  _tcsncpy(path, hole_path, drv_len);
424  int i = drv_len;
425 
426  for(p=dir; *p=='/'||*p=='\\'; p++)
427  path[i++] = *p++;
428 
429  for(; i<l; i++) {
430  memcpy(path, hole_path, i*sizeof(TCHAR));
431 
432  for(; hole_path[i] && hole_path[i]!='/' && hole_path[i]!='\\'; i++)
433  path[i] = hole_path[i];
434 
435  path[i] = '\0';
436 
437  hFind = FindFirstFile(path, &w32fd);
438 
439  if (hFind != INVALID_HANDLE_VALUE)
440  FindClose(hFind);
441  else {
442  LOG(FmtString(TEXT("CreateDirectory(\"%s\")"), path));
443 
444  if (!CreateDirectory(path, 0))
445  return FALSE;
446  }
447  }
448  } else
449  FindClose(hFind);
450 
451  return TRUE;
452 }
#define TRUE
Definition: types.h:120
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
_TCHAR * _tcsncpy(_TCHAR *dst, const _TCHAR *src, size_t n)
Definition: tcsncpy.h:9
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
_TCHAR * _tcscpy(_TCHAR *to, const _TCHAR *from)
Definition: tcscpy.h:8
CHAR * LPTSTR
Definition: xmlstorage.h:192
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
unsigned int dir
Definition: maze.c:112
#define FindFirstFile
Definition: winbase.h:3616
r l[0]
Definition: byte_order.h:167
char TCHAR
Definition: xmlstorage.h:189
#define d
Definition: ke_i.h:81
#define MAX_PATH
Definition: compat.h:26
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define LOG(txt)
Definition: utility.h:102
#define TEXT(s)
Definition: k32.h:26
GLfloat GLfloat p
Definition: glext.h:8902
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by QuickLaunchBar::AddShortcuts(), and ExplorerGlobals::write_persistent().

◆ RegGetDWORDValue()

DWORD RegGetDWORDValue ( HKEY  root,
LPCTSTR  path,
LPCTSTR  valueName,
DWORD  def 
)

Definition at line 455 of file utility.cpp.

456 {
457  HKEY hkey;
458  DWORD ret;
459 
460  if (!RegOpenKey(root, path, &hkey)) {
461  DWORD len = sizeof(ret);
462 
463  if (RegQueryValueEx(hkey, valueName, 0, NULL, (LPBYTE)&ret, &len))
464  ret = def;
465 
466  RegCloseKey(hkey);
467 
468  return ret;
469  } else
470  return def;
471 }
#define RegQueryValueEx
Definition: winreg.h:524
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum GLsizei len
Definition: glext.h:6722
#define RegOpenKey
Definition: winreg.h:519

◆ RegSetDWORDValue()

BOOL RegSetDWORDValue ( HKEY  root,
LPCTSTR  path,
LPCTSTR  valueName,
DWORD  value 
)

Definition at line 474 of file utility.cpp.

475 {
476  HKEY hkey;
477  BOOL ret = FALSE;
478 
479  if (!RegOpenKey(root, path, &hkey)) {
480  ret = RegSetValueEx(hkey, valueName, 0, REG_DWORD, (LPBYTE)&value, sizeof(value));
481 
482  RegCloseKey(hkey);
483  }
484 
485  return ret;
486 }
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
int ret
#define RegOpenKey
Definition: winreg.h:519
#define REG_DWORD
Definition: sdbapi.c:596
#define RegSetValueEx
Definition: winreg.h:533

◆ RunDLL()

BOOL RunDLL ( HWND  hwnd,
LPCTSTR  dllname,
LPCSTR  procname,
LPCTSTR  cmdline,
UINT  nCmdShow 
)

Definition at line 349 of file utility.cpp.

350 {
351  HMODULE hmod = LoadLibrary(dllname);
352  if (!hmod)
353  return FALSE;
354 
355 /*TODO
356  <Windows NT/2000>
357  It is possible to create a Unicode version of the function.
358  Rundll32 first tries to find a function named EntryPointW.
359  If it cannot find this function, it tries EntryPointA, then EntryPoint.
360  To create a DLL that supports ANSI on Windows 95/98/Me and Unicode otherwise,
361  export two functions: EntryPointW and EntryPoint.
362 */
364  if (!proc) {
365  FreeLibrary(hmod);
366  return FALSE;
367  }
368 
369  proc(hwnd, hmod, cmdline, nCmdShow);
370 
371  FreeLibrary(hmod);
372 
373  return TRUE;
374 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
void(WINAPI * RUNDLLPROC)(HWND hwnd, HINSTANCE hinst, LPCTSTR cmdline, DWORD nCmdShow)
Definition: utility.cpp:347
#define TRUE
Definition: types.h:120
#define LoadLibrary
Definition: winbase.h:3696
static HANDLE proc()
Definition: pdb.c:32
TCHAR * cmdline
Definition: stretchblt.cpp:32
#define FreeLibrary(x)
Definition: compat.h:413
static PEXPLICIT_ACCESSW *static HMODULE hmod
Definition: security.c:141
#define GetProcAddress(x, y)
Definition: compat.h:418

◆ SplitFileSysURL()

bool SplitFileSysURL ( LPCTSTR  url,
String dir_out,
String fname_out 
)

Definition at line 504 of file utility.cpp.

505 {
506  if (!_tcsnicmp(url, TEXT("file://"), 7)) {
507  url += 7;
508 
509  // remove third slash in front of drive characters
510  if (*url == '/')
511  ++url;
512  }
513 
514  if (exists_path(url)) {
516 
517  // convert slashes to back slashes
519 
521  fname_out.erase();
522  else {
524 
525  _tsplitpath_s(path, drv, COUNTOF(drv), dir, COUNTOF(dir), fname, COUNTOF(fname), ext, COUNTOF(ext));
526  _stprintf(path, TEXT("%s%s"), drv, dir);
527 
528  fname_out.printf(TEXT("%s%s"), fname, ext);
529  }
530 
531  dir_out = path;
532 
533  return true;
534  } else
535  return false;
536 }
#define _tsplitpath_s
Definition: tchar.h:687
GLsizei const GLchar ** path
Definition: glext.h:7234
BOOL exists_path(LPCTSTR path)
Definition: utility.cpp:489
#define _MAX_FNAME
Definition: utility.h:74
#define _MAX_DRIVE
Definition: utility.h:73
#define _tcsnicmp
Definition: xmlstorage.h:207
#define _MAX_PATH
Definition: utility.h:77
smooth NULL
Definition: ftsmooth.c:416
char ext[3]
Definition: mkdosfs.c:358
unsigned int dir
Definition: maze.c:112
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
char TCHAR
Definition: xmlstorage.h:189
static const WCHAR url[]
Definition: encode.c:1432
#define GetFullPathName
Definition: winbase.h:3655
#define GetFileAttributes
Definition: winbase.h:3649
#define _MAX_EXT
Definition: utility.h:76
#define _stprintf
Definition: utility.h:124
#define TEXT(s)
Definition: k32.h:26
#define COUNTOF(x)
Definition: utility.h:93
#define _MAX_DIR
Definition: utility.h:75

Referenced by FileChildWindow::jump_to_int(), and MDIShellBrowserChild::jump_to_int().

◆ time_to_filetime()

BOOL time_to_filetime ( const time_t t,
FILETIME ftime 
)

Definition at line 159 of file utility.cpp.

160 {
161 #if defined(__STDC_WANT_SECURE_LIB__) && defined(_MS_VER)
162  SYSTEMTIME stime;
163  struct tm tm_;
164  struct tm* tm = &tm_;
165 
166  if (gmtime_s(tm, t) != 0)
167  return FALSE;
168 #else
169  struct tm* tm = gmtime(t);
170  SYSTEMTIME stime;
171 
172  if (!tm)
173  return FALSE;
174 #endif
175 
176  stime.wYear = tm->tm_year+1900;
177  stime.wMonth = tm->tm_mon+1;
178  stime.wDayOfWeek = (WORD)-1;
179  stime.wDay = tm->tm_mday;
180  stime.wHour = tm->tm_hour;
181  stime.wMinute = tm->tm_min;
182  stime.wSecond = tm->tm_sec;
183  stime.wMilliseconds = 0;
184 
185  return SystemTimeToFileTime(&stime, ftime);
186 }
int tm_min
Definition: time.h:78
WORD wMonth
Definition: winbase.h:878
WORD wDayOfWeek
Definition: winbase.h:879
int tm_mday
Definition: time.h:80
GLdouble GLdouble t
Definition: gl.h:2047
int tm_year
Definition: time.h:82
WORD wYear
Definition: winbase.h:877
WORD wMinute
Definition: winbase.h:882
int tm_mon
Definition: time.h:81
unsigned short WORD
Definition: ntddk_ex.h:93
WORD wSecond
Definition: winbase.h:883
WORD wMilliseconds
Definition: winbase.h:884
Definition: time.h:76
__CRT_INLINE void __cdecl ftime(struct timeb *_Tmb)
Definition: timeb.h:96
WORD wDay
Definition: winbase.h:880
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:158
WORD wHour
Definition: winbase.h:881
int tm_sec
Definition: time.h:77
int tm_hour
Definition: time.h:79
_CRTIMP struct tm *__cdecl gmtime(const time_t *_Time)
Definition: time.h:423

Variable Documentation

◆ g_foundPrevInstance

int g_foundPrevInstance = 0
static

Definition at line 220 of file utility.cpp.

Referenced by EnumWndProc(), and find_window_class().