ReactOS  0.4.13-dev-39-g8b6696f
utility.h File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <winuser.h>
#include <tchar.h>
#include <windowsx.h>
#include <commctrl.h>
#include <objbase.h>
#include <assert.h>
#include <stdio.h>
Include dependency graph for utility.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define WIN32_LEAN_AND_MEAN
 
#define WIN32_EXTRA_LEAN
 
#define WIN32_NO_STATUS
 
#define _INC_WINDOWS
 
#define COM_NO_WINDOWS_H
 
#define _MAX_DRIVE   3
 
#define _MAX_FNAME   256
 
#define _MAX_DIR   _MAX_FNAME
 
#define _MAX_EXT   _MAX_FNAME
 
#define _MAX_PATH   260
 
#define W_VER_NT   0
 
#define for   if (0) {} else for
 
#define COUNTOF(x)   (sizeof(x)/sizeof(x[0]))
 
#define BUFFER_LEN   2048
 
#define LOG(txt)   _log_(txt)
 
#define LONGLONGARG   TEXT("L")
 
#define _tcsrchr   strrchr
 
#define _stprintf   sprintf
 
#define U2A(s, d, l)   WideCharToMultiByte(CP_ACP, 0, s, -1, d, l, NULL, NULL)
 
#define U2nA(s, d, l)   WideCharToMultiByte(CP_ACP, 0, s, l, d, l, NULL, NULL)
 
#define A2U(s, d, l)   MultiByteToWideChar(CP_ACP, 0, s, -1, d, l)
 
#define A2nU(s, d, l)   MultiByteToWideChar(CP_ACP, 0, s, l, d, l)
 
#define FILE_ATTRIBUTE_ENCRYPTED   0x00000040
 
#define FILE_ATTRIBUTE_SPARSE_FILE   0x00000200
 
#define FILE_ATTRIBUTE_REPARSE_POINT   0x00000400
 
#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED   0x00002000
 
#define SetDlgCtrlID(hwnd, id)   SetWindowLongPtr(hwnd, GWL_ID, id)
 
#define SetWindowStyle(hwnd, val)   (DWORD)SetWindowLongPtr(hwnd, GWL_STYLE, val)
 
#define SetWindowExStyle(h, val)   (DWORD)SetWindowLongPtr(hwnd, GWL_EXSTYLE, val)
 
#define Window_SetIcon(hwnd, type, hicon)   (HICON)SendMessage(hwnd, WM_SETICON, type, (LPARAM)(hicon))
 
#define strcpy_s(d, l, s)   strcpy(d, s)
 
#define wcscpy_s(d, l, s)   wcscpy(d, s)
 
#define wcsncpy_s(d, l, s, n)   wcsncpy(d, s, n)
 
#define _wsplitpath_s(f, d, dl, p, pl, n, nl, e, el)   _wsplitpath(f, d, p, n, e)
 
#define _splitpath_s(f, d, dl, p, pl, n, nl, e, el)   _splitpath(f, d, p, n, e)
 
#define _stprintf_s1(b, l, f, p1)   _stprintf(b, f, p1)
 
#define _stprintf_s2(b, l, f, p1, p2)   _stprintf(b, f, p1,p2)
 

Functions

void _log_ (LPCTSTR txt)
 
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)
 
int find_window_class (LPCTSTR classname)
 
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)
 

Macro Definition Documentation

◆ _INC_WINDOWS

#define _INC_WINDOWS

Definition at line 32 of file utility.h.

◆ _MAX_DIR

#define _MAX_DIR   _MAX_FNAME

Definition at line 75 of file utility.h.

◆ _MAX_DRIVE

#define _MAX_DRIVE   3

Definition at line 73 of file utility.h.

◆ _MAX_EXT

#define _MAX_EXT   _MAX_FNAME

Definition at line 76 of file utility.h.

◆ _MAX_FNAME

#define _MAX_FNAME   256

Definition at line 74 of file utility.h.

◆ _MAX_PATH

#define _MAX_PATH   260

Definition at line 77 of file utility.h.

◆ _splitpath_s

#define _splitpath_s (   f,
  d,
  dl,
  p,
  pl,
  n,
  nl,
  e,
  el 
)    _splitpath(f, d, p, n, e)

Definition at line 212 of file utility.h.

◆ _stprintf

#define _stprintf   sprintf

Definition at line 124 of file utility.h.

◆ _stprintf_s1

#define _stprintf_s1 (   b,
  l,
  f,
  p1 
)    _stprintf(b, f, p1)

Definition at line 215 of file utility.h.

◆ _stprintf_s2

#define _stprintf_s2 (   b,
  l,
  f,
  p1,
  p2 
)    _stprintf(b, f, p1,p2)

Definition at line 216 of file utility.h.

◆ _tcsrchr

#define _tcsrchr   strrchr

Definition at line 116 of file utility.h.

◆ _wsplitpath_s

#define _wsplitpath_s (   f,
  d,
  dl,
  p,
  pl,
  n,
  nl,
  e,
  el 
)    _wsplitpath(f, d, p, n, e)

Definition at line 211 of file utility.h.

◆ A2nU

#define A2nU (   s,
  d,
  l 
)    MultiByteToWideChar(CP_ACP, 0, s, l, d, l)

Definition at line 131 of file utility.h.

◆ A2U

#define A2U (   s,
  d,
  l 
)    MultiByteToWideChar(CP_ACP, 0, s, -1, d, l)

Definition at line 130 of file utility.h.

◆ BUFFER_LEN

#define BUFFER_LEN   2048

Definition at line 97 of file utility.h.

◆ COM_NO_WINDOWS_H

#define COM_NO_WINDOWS_H

Definition at line 33 of file utility.h.

◆ COUNTOF

#define COUNTOF (   x)    (sizeof(x)/sizeof(x[0]))

Definition at line 93 of file utility.h.

◆ FILE_ATTRIBUTE_ENCRYPTED

#define FILE_ATTRIBUTE_ENCRYPTED   0x00000040

Definition at line 145 of file utility.h.

◆ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED

#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED   0x00002000

Definition at line 148 of file utility.h.

◆ FILE_ATTRIBUTE_REPARSE_POINT

#define FILE_ATTRIBUTE_REPARSE_POINT   0x00000400

Definition at line 147 of file utility.h.

◆ FILE_ATTRIBUTE_SPARSE_FILE

#define FILE_ATTRIBUTE_SPARSE_FILE   0x00000200

Definition at line 146 of file utility.h.

◆ for

#define for   if (0) {} else for

Definition at line 88 of file utility.h.

◆ LOG

#define LOG (   txt)    _log_(txt)

Definition at line 102 of file utility.h.

◆ LONGLONGARG

#define LONGLONGARG   TEXT("L")

Definition at line 108 of file utility.h.

◆ SetDlgCtrlID

#define SetDlgCtrlID (   hwnd,
  id 
)    SetWindowLongPtr(hwnd, GWL_ID, id)

Definition at line 152 of file utility.h.

◆ SetWindowExStyle

#define SetWindowExStyle (   h,
  val 
)    (DWORD)SetWindowLongPtr(hwnd, GWL_EXSTYLE, val)

Definition at line 154 of file utility.h.

◆ SetWindowStyle

#define SetWindowStyle (   hwnd,
  val 
)    (DWORD)SetWindowLongPtr(hwnd, GWL_STYLE, val)

Definition at line 153 of file utility.h.

◆ strcpy_s

#define strcpy_s (   d,
  l,
  s 
)    strcpy(d, s)

Definition at line 200 of file utility.h.

◆ U2A

#define U2A (   s,
  d,
  l 
)    WideCharToMultiByte(CP_ACP, 0, s, -1, d, l, NULL, NULL)

Definition at line 128 of file utility.h.

◆ U2nA

#define U2nA (   s,
  d,
  l 
)    WideCharToMultiByte(CP_ACP, 0, s, l, d, l, NULL, NULL)

Definition at line 129 of file utility.h.

◆ W_VER_NT

#define W_VER_NT   0

Definition at line 80 of file utility.h.

◆ wcscpy_s

#define wcscpy_s (   d,
  l,
  s 
)    wcscpy(d, s)

Definition at line 201 of file utility.h.

◆ wcsncpy_s

#define wcsncpy_s (   d,
  l,
  s,
  n 
)    wcsncpy(d, s, n)

Definition at line 202 of file utility.h.

◆ WIN32_EXTRA_LEAN

#define WIN32_EXTRA_LEAN

Definition at line 30 of file utility.h.

◆ WIN32_LEAN_AND_MEAN

#define WIN32_LEAN_AND_MEAN

Definition at line 29 of file utility.h.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 31 of file utility.h.

◆ Window_SetIcon

#define Window_SetIcon (   hwnd,
  type,
  hicon 
)    (HICON)SendMessage(hwnd, WM_SETICON, type, (LPARAM)(hicon))

Definition at line 155 of file utility.h.

Function Documentation

◆ _log_()

void _log_ ( LPCTSTR  txt)

Definition at line 139 of file explorer.cpp.

140 {
141  FmtString msg(TEXT("%s\n"), txt);
142 
143  if (g_Globals._log)
145 
147 }
#define _fputts
Definition: tchar.h:569
#define OutputDebugString
Definition: winbase.h:3704
ExplorerGlobals g_Globals
Definition: explorer.cpp:52
#define TEXT(s)
Definition: k32.h:26
#define msg(x)
Definition: auth_time.c:54
FILE * _log
Definition: globals.h:280

◆ CenterWindow()

void CenterWindow ( HWND  hwnd)

Definition at line 536 of file livecd.c.

537 {
539  RECT rcParent;
540  RECT rcWindow;
541 
543  if (hWndParent == NULL)
545 
546  GetWindowRect(hWndParent, &rcParent);
547  GetWindowRect(hWnd, &rcWindow);
548 
550  HWND_TOP,
551  ((rcParent.right - rcParent.left) - (rcWindow.right - rcWindow.left)) / 2,
552  ((rcParent.bottom - rcParent.top) - (rcWindow.bottom - rcWindow.top)) / 2,
553  0,
554  0,
555  SWP_NOSIZE);
556 }
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:292
#define HWND_TOP
Definition: winuser.h:1193
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
smooth NULL
Definition: ftsmooth.c:416
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:622
#define SWP_NOSIZE
Definition: winuser.h:1230
HWND WINAPI GetParent(_In_ HWND)
LONG bottom
Definition: windef.h:294
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)

Referenced by LocaleDlgProc(), and StartDlgProc().

◆ 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:409
#define FormatMessage
Definition: winbase.h:3609
#define MessageBox
Definition: winuser.h:5688
#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().

◆ 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:391
static int fd
Definition: io.c:51
#define FindFirstFile
Definition: winbase.h:3596
Definition: services.c:325
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

◆ 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:292
LONG left
Definition: windef.h:291
#define SWP_NOZORDER
Definition: winuser.h:1232
LONG right
Definition: windef.h:293
#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:294
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:391
_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:3596
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
Definition: services.c:325
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
Definition: services.c:325
#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
Definition: services.c:325
#define RegOpenKey
Definition: winreg.h:519
#define REG_DWORD
Definition: sdbapi.c:596
#define RegSetValueEx
Definition: winreg.h:533

◆ 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:871
WORD wDayOfWeek
Definition: winbase.h:872
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:870
WORD wMinute
Definition: winbase.h:875
int tm_mon
Definition: time.h:81
unsigned short WORD
Definition: ntddk_ex.h:93
WORD wSecond
Definition: winbase.h:876
WORD wMilliseconds
Definition: winbase.h:877
Definition: time.h:76
__CRT_INLINE void __cdecl ftime(struct timeb *_Tmb)
Definition: timeb.h:96
WORD wDay
Definition: winbase.h:873
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:148
WORD wHour
Definition: winbase.h:874
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:425