29#define WIN32_LEAN_AND_MEAN
30#define WIN32_EXTRA_LEAN
31#define WIN32_NO_STATUS
33#define COM_NO_WINDOWS_H
42#if defined(UNICODE) && !defined(_UNICODE)
62#pragma warning(disable: 4786)
75#define _MAX_DIR _MAX_FNAME
76#define _MAX_EXT _MAX_FNAME
88#define for if (0) {} else for
91#define COUNTOF _countof
93#define COUNTOF(x) (sizeof(x)/sizeof(x[0]))
97#define BUFFER_LEN 2048
102#define LOG(txt) _log_(txt)
106#define LONGLONGARG TEXT("I64")
108#define LONGLONGARG TEXT("L")
114#define _tcsrchr wcsrchr
116#define _tcsrchr strrchr
122#define _stprintf wcsprintf
124#define _stprintf sprintf
128#define U2A(s, d, l) WideCharToMultiByte(CP_ACP, 0, s, -1, d, l, NULL, NULL)
129#define U2nA(s, d, l) WideCharToMultiByte(CP_ACP, 0, s, l, d, l, NULL, NULL)
130#define A2U(s, d, l) MultiByteToWideChar(CP_ACP, 0, s, -1, d, l)
131#define A2nU(s, d, l) MultiByteToWideChar(CP_ACP, 0, s, l, d, l)
140#define _tcsnicmp strncasecmp
141#define _tcsicoll strcasecmp
144#ifndef FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
145#define FILE_ATTRIBUTE_ENCRYPTED 0x00000040
146#define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
147#define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
148#define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
152#define SetDlgCtrlID(hwnd, id) SetWindowLongPtr(hwnd, GWL_ID, id)
153#define SetWindowStyle(hwnd, val) (DWORD)SetWindowLongPtr(hwnd, GWL_STYLE, val)
154#define SetWindowExStyle(h, val) (DWORD)SetWindowLongPtr(hwnd, GWL_EXSTYLE, val)
155#define Window_SetIcon(hwnd, type, hicon) (HICON)SendMessage(hwnd, WM_SETICON, type, (LPARAM)(hicon))
193#if defined(__STDC_WANT_SECURE_LIB__) && defined(_MS_VER)
195#define _stprintf_s1 _stprintf_s
196#define _stprintf_s2 _stprintf_s
200#define strcpy_s(d, l, s) strcpy(d, s)
201#define wcscpy_s(d, l, s) wcscpy(d, s)
202#define wcsncpy_s(d, l, s, n) wcsncpy(d, s, n)
204#if defined(_tcscpy) && !defined(_tcscpy_s)
205#define _tcscpy_s(d, l, s) _tcscpy(d, s)
208#if defined(_tsplitpath) && !defined(_tsplitpath_s)
209#define _tsplitpath_s(f, d,dl, p,pl, n,nl, e,el) _tsplitpath(f, d, p, n, e)
211#define _wsplitpath_s(f, d,dl, p,pl, n,nl, e,el) _wsplitpath(f, d, p, n, e)
212#define _splitpath_s(f, d,dl, p,pl, n,nl, e,el) _splitpath(f, d, p, n, e)
215#define _stprintf_s1(b, l, f, p1) _stprintf(b, f, p1)
216#define _stprintf_s2(b, l, f, p1,p2) _stprintf(b, f, p1,p2)
237#if defined(_MSC_VER) && !defined(_NO_COMUTIL)
251#define launch_fileA launch_file
262struct CommonControlInit
298 operator HWND()
const {
return _hwnd;}
307struct HiddenWindow :
public WindowHandle
345 : _crit_sect(crit_sect)
406 virtual int Run() = 0;
408 bool is_alive()
const {
return _alive;}
425struct ClientRect :
public RECT
432 operator LPRECT() {
return this;}
438struct WindowRect :
public RECT
445 operator LPRECT() {
return this;}
466 operator LPPOINT() {
return this;}
480struct FullScreenParameters
482 FullScreenParameters()
509 operator HDC()
const {
return hdc;}
520 operator HDC() {
return _hdc;}
527struct WindowCanvas :
public Canvas
532 ~WindowCanvas() {
ReleaseDC(_hwnd, _hdc);}
542struct MemCanvas :
public Canvas
564struct BufferCanvas :
public MemCanvas
566 BufferCanvas(
HDC hdc,
int x,
int y,
int w,
int h)
567 : MemCanvas(
hdc), _hdctarg(
hdc),
568 _x(
x), _y(
y), _w(
w), _h(
h),
572 : MemCanvas(
hdc), _hdctarg(
hdc),
583struct BufferedCanvas :
public BufferCanvas
591 ~BufferedCanvas() {
BitBlt(_hdctarg,
_x, _y, _w, _h, _hdc, 0, 0, _mode);}
597struct BufferedPaintCanvas :
public PaintCanvas,
public BufferedCanvas
605 operator HDC() {
return BufferedCanvas::_hdc;}
625 BkMode(
HDC hdc,
int bkmode)
628 ~BkMode() {
SetBkMode(_hdc, _old_bkmode);}
641 ~FontSelection() {
SelectFont(_hdc, _old_hFont);}
649struct BitmapSelection
664 BrushSelection(
HDC hdc, HBRUSH hBrush)
667 ~BrushSelection() {
SelectBrush(_hdc, _old_hBrush);}
690 operator HMENU() {
return _hmenu;}
737 operator long()
const;
738 operator bool()
const;
785 operator BSTR()
const
787 return _p? _p: (
BSTR)
L"";
811 typedef string super;
829 void assign(
const BStr&
s) {
int l =
s.length(); super::assign(
s,
l);}
840 String& operator=(
const BStr&
s) {assign(
s);
return *
this;}
842 String& operator=(
LPCTSTR s) {
if (
s) super::assign(
s);
else erase();
return *
this;}
843 String& operator=(
const super&
s) {super::assign(
s);
return *
this;}
844 void assign(
LPCTSTR s) {super::assign(
s);}
845 void assign(
LPCTSTR s,
int l) {super::assign(
s,
l);}
847 operator LPCTSTR()
const {
return c_str();}
906#define _STRING_DEFINED
909struct FmtString :
public String
940 operator LPCSTR() {
return _str;}
946#define UNC(x) ((LPCWSTR)(x))
950#define ANS(x) ((LPCSTR)(x))
968 operator LPCWSTR() {
return _str;}
982template<
typename FCT>
struct DynamicFct
999 operator bool()
const {
return _fct?
true:
false;}
1007template<
typename FCT>
struct DynamicLoadLibFct
1009 DynamicLoadLibFct(
LPCTSTR moduleName,
UINT ordinal)
1023 ~DynamicLoadLibFct()
1029 operator bool()
const {
return _fct?
true:
false;}
1078 String getStackTrace()
const;
1092#define CONTEXT_OBJ __ctx__._obj
1093#define CONTEXT(c) Context __ctx__(c)
1094#define CURRENT_CONTEXT Context::current()
1095#define OBJ_CONTEXT(c, o) Context __ctx__(c, o)
RTL_CRITICAL_SECTION CritSect
DWORD WINAPI ThreadProc(LPVOID lpParam)
bitset< _Nb > _STLP_CALL operator&(const bitset< _Nb > &__x, const bitset< _Nb > &__y)
complex< _Tp > _STLP_CALL operator*(const _Tp &__x, const complex< _Tp > &__z)
ACPI_SIZE strlen(const char *String)
VOID WaitCursor(BOOL bBegin)
BOOL WINAPI InitCommonControlsEx(const INITCOMMONCONTROLSEX *lpInitCtrls)
__CRT_INLINE void __cdecl ftime(struct timeb *_Tmb)
static const WCHAR empty[]
#define GetProcAddress(x, y)
#define INVALID_HANDLE_VALUE
#define WideCharToMultiByte
#define MultiByteToWideChar
static const WCHAR *const ext[]
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble GLdouble top
GLboolean GLboolean GLboolean b
GLuint GLsizei GLsizei * length
GLubyte GLubyte GLubyte GLubyte w
GLfloat GLfloat GLfloat GLfloat h
_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
_CRTIMP void __cdecl _splitpath(_In_z_ const char *_FullPath, _Pre_maybenull_ _Post_z_ char *_Drive, _Pre_maybenull_ _Post_z_ char *_Dir, _Pre_maybenull_ _Post_z_ char *_Filename, _Pre_maybenull_ _Post_z_ char *_Ext)
_CRTIMP void __cdecl _wsplitpath(_In_z_ const wchar_t *_FullPath, _Pre_maybenull_ _Post_z_ wchar_t *_Drive, _Pre_maybenull_ _Post_z_ wchar_t *_Dir, _Pre_maybenull_ _Post_z_ wchar_t *_Filename, _Pre_maybenull_ _Post_z_ wchar_t *_Ext)
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_In_opt_ PVOID _Out_ BOOLEAN * Stop
struct task_struct * current
BOOL RunDLL(HWND hwnd, LPCTSTR dllname, LPCSTR procname, LPCTSTR cmdline, UINT nCmdShow)
bool SplitFileSysURL(LPCTSTR url, String &dir_out, String &fname_out)
BOOL launch_cpanel(HWND hwnd, LPCTSTR applet)
BOOL launch_file(HWND hwnd, LPCTSTR cmd, UINT nCmdShow, LPCTSTR parameters)
String get_windows_version_str()
int find_window_class(LPCTSTR classname)
void MoveVisible(HWND hwnd)
BOOL RecursiveCreateDirectory(LPCTSTR path_in)
void CenterWindow(HWND hwnd)
BOOL RegSetDWORDValue(HKEY root, LPCTSTR path, LPCTSTR valueName, DWORD value)
DWORD RegGetDWORDValue(HKEY root, LPCTSTR path, LPCTSTR valueName, DWORD def)
BOOL exists_path(LPCTSTR path)
BOOL time_to_filetime(const time_t *t, FILETIME *ftime)
void display_error(HWND hwnd, DWORD error)
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
BSTR WINAPI SysAllocString(LPCOLESTR str)
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
BSTR WINAPI SysAllocStringLen(const OLECHAR *str, unsigned int len)
struct tagINITCOMMONCONTROLSEX INITCOMMONCONTROLSEX
#define ICC_TREEVIEW_CLASSES
#define ICC_PROGRESS_CLASS
#define ICC_LISTVIEW_CLASSES
__crt_unique_heap_ptr< wchar_t > const wstring(_malloc_crt_t(wchar_t, maxsize))
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
void WINAPI VariantInit(VARIANTARG *pVarg)
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
VOID WINAPI InitializeCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
struct tagPOINT * LPPOINT
#define SelectFont(hdc, hfont)
#define SelectBitmap(hdc, hbm)
#define SelectBrush(hdc, hbr)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
HMENU WINAPI CreatePopupMenu(void)
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)
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
BOOL WINAPI TrackPopupMenuEx(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _In_ HWND, _In_opt_ LPTPMPARAMS)
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
HDC WINAPI GetDC(_In_opt_ HWND)
BOOL WINAPI DestroyMenu(_In_ HMENU)
BOOL WINAPI TrackPopupMenu(_In_ HMENU, _In_ UINT, _In_ int, _In_ int, _Reserved_ int, _In_ HWND, _Reserved_ LPCRECT)
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)