2 * Copyright 2003, 2004, 2005 Martin Fuchs
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 // Martin Fuchs, 23.07.2003
29 // standard windows headers
30 #define WIN32_LEAN_AND_MEAN
31 #define WIN32_EXTRA_LEAN
40 #include <windowsx.h> // for SelectBrush(), ListBox_SetSel(), SubclassWindow(), ...
46 #include <oleauto.h> // for VARIANT
48 #include <malloc.h> // for alloca()
50 #include <stdlib.h> // for _MAX_DIR, ...
51 #include <stdio.h> // for sprintf()
56 #define _MAX_FNAME 256
57 #define _MAX_DIR _MAX_FNAME
58 #define _MAX_EXT _MAX_FNAME
62 #define W_VER_NT 0 // constant for HIWORD(GetVersion())>>14
70 #define for if (0) {} else for
73 #define COUNTOF _countof
75 #define COUNTOF(x) (sizeof(x)/sizeof(x[0]))
79 #define BUFFER_LEN 2048
82 extern void _log_(LPCTSTR txt
);
84 #define LOG(txt) _log_(txt)
88 #define LONGLONGARG TEXT("I64")
90 #define LONGLONGARG TEXT("L")
96 #define _tcsrchr wcsrchr
98 #define _tcsrchr strrchr
104 #define _stprintf wcsprintf
106 #define _stprintf sprintf
110 #define U2A(s, d, l) WideCharToMultiByte(CP_ACP, 0, s, -1, d, l, NULL, NULL)
111 #define U2nA(s, d, l) WideCharToMultiByte(CP_ACP, 0, s, l, d, l, NULL, NULL)
112 #define A2U(s, d, l) MultiByteToWideChar(CP_ACP, 0, s, -1, d, l)
113 #define A2nU(s, d, l) MultiByteToWideChar(CP_ACP, 0, s, l, d, l)
118 extern void _wsplitpath(const WCHAR
* path
, WCHAR
* drv
, WCHAR
* dir
, WCHAR
* name
, WCHAR
* ext
);
120 extern void _splitpath(const CHAR
* path
, CHAR
* drv
, CHAR
* dir
, CHAR
* name
, CHAR
* ext
);
122 #define _tcsnicmp strncasecmp
123 #define _tcsicoll strcasecmp
126 #ifndef FILE_ATTRIBUTE_NOT_CONTENT_INDEXED
127 #define FILE_ATTRIBUTE_ENCRYPTED 0x00000040
128 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200
129 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
130 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000
134 #define SetDlgCtrlID(hwnd, id) SetWindowLong(hwnd, GWL_ID, id)
135 #define SetWindowStyle(hwnd, val) (DWORD)SetWindowLong(hwnd, GWL_STYLE, val)
136 #define SetWindowExStyle(h, val) (DWORD)SetWindowLong(hwnd, GWL_EXSTYLE, val)
137 #define Window_SetIcon(hwnd, type, hicon) (HICON)SendMessage(hwnd, WM_SETICON, type, (LPARAM)(hicon))
140 // center window in respect to its parent window
141 extern void CenterWindow(HWND hwnd
);
143 // move window into visibility
144 extern void MoveVisible(HWND hwnd
);
146 // display error message
147 extern void display_error(HWND hwnd
, DWORD error
);
149 // convert time_t to WIN32 FILETIME
150 extern BOOL
time_to_filetime(const time_t* t
, FILETIME
* ftime
);
152 // search for windows of a specific classname
153 extern int find_window_class(LPCTSTR classname
);
155 // create a directory with all missing parent directories
156 BOOL
RecursiveCreateDirectory(LPCTSTR path_in
);
158 // read DWORD value from registry
159 DWORD
RegGetDWORDValue(HKEY root
, LPCTSTR path
, LPCTSTR valueName
, DWORD def
);
161 // write DWORD value to registry
162 BOOL
RegSetDWORDValue(HKEY root
, LPCTSTR path
, LPCTSTR valueName
, DWORD value
);
164 // test for existing directory
165 BOOL
exists_path(LPCTSTR path
);
173 // secure CRT functions
174 #ifdef __STDC_WANT_SECURE_LIB__ // for VS 2005: _MSC_VER>=1400
176 #define _stprintf_s1 _stprintf_s
177 #define _stprintf_s2 _stprintf_s
179 #else // __STDC_WANT_SECURE_LIB__
181 #define strcpy_s(d, l, s) strcpy(d, s)
182 #define _tcscpy_s(d, l, s) _tcscpy(d, s)
183 #define wcsncpy_s(d, l, s, n) wcsncpy(d, s, n)
184 #define _stprintf_s1(b, l, f, p1) _stprintf(b, f, p1)
185 #define _stprintf_s2(b, l, f, p1,p2) _stprintf(b, f, p1,p2)
186 #define _tsplitpath_s(f, d,dl, p,pl, n,nl, e,el) _tsplitpath(f, d, p, n, e)
188 #endif // __STDC_WANT_SECURE_LIB__
194 #pragma warning(disable: 4786) // disable warnings about too long debug information symbols
197 // STL headers for strings and streams
210 /* not necessary with correct include file order for comdef.h ("<MS PSDK>\include" path first) */
211 #if _MSC_VER>=1300 // VS.Net
216 #if defined(_MSC_VER) && !defined(_NO_COMUTIL)
218 // COM utility headers
220 using namespace _com_util
;
222 #endif // _MSC_VER && !_NO_COMUTIL
225 // launch a program or document file
226 extern BOOL
launch_file(HWND hwnd
, LPCTSTR cmd
, UINT nCmdShow
=SW_SHOWNORMAL
, LPCTSTR parameters
=NULL
);
228 extern BOOL
launch_fileA(HWND hwnd
, LPSTR cmd
, UINT nCmdShow
=SW_SHOWNORMAL
, LPCSTR parameters
=NULL
);
230 #define launch_fileA launch_file
233 // call an DLL export like rundll32
234 extern BOOL
RunDLL(HWND hwnd
, LPCTSTR dllname
, LPCSTR procname
, LPCTSTR cmdline
, UINT nCmdShow
);
236 // launch control panel applet
237 extern BOOL
launch_cpanel(HWND hwnd
, LPCTSTR applet
);
240 /// initialization of windows common controls
241 struct CommonControlInit
243 CommonControlInit(DWORD flags
=ICC_LISTVIEW_CLASSES
|ICC_TREEVIEW_CLASSES
|ICC_BAR_CLASSES
|ICC_PROGRESS_CLASS
|ICC_COOL_CLASSES
)
245 INITCOMMONCONTROLSEX icc
= {sizeof(INITCOMMONCONTROLSEX
), flags
};
247 InitCommonControlsEx(&icc
);
254 struct WaitCursor
///@todo integrate with WM_SETCURSOR to enable multithreaded background tasks as program launching
258 _old_cursor
= SetCursor(LoadCursor(0, IDC_WAIT
));
263 SetCursor(_old_cursor
);
271 /// base of all structures storing a window handle
274 WindowHandle(HWND hwnd
=0)
277 operator HWND() const {return _hwnd
;}
278 HWND
* operator&() {return &_hwnd
;}
285 /// locally hide a window
286 struct HiddenWindow
: public WindowHandle
288 HiddenWindow(HWND hwnd
)
289 : WindowHandle(IsWindowVisible(hwnd
)? hwnd
: 0)
292 SetWindowPos(_hwnd
, 0, 0, 0, 0, 0, SWP_HIDEWINDOW
|SWP_NOREDRAW
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOZORDER
);
298 SetWindowPos(_hwnd
, 0, 0, 0, 0, 0, SWP_SHOWWINDOW
|SWP_NOMOVE
|SWP_NOSIZE
|SWP_NOZORDER
);
303 /// critical section wrapper
305 struct CritSect
: public CRITICAL_SECTION
309 InitializeCriticalSection(this);
314 DeleteCriticalSection(this);
319 /// Lock protects a code section utilizing a critical section
323 Lock(CritSect
& crit_sect
)
324 : _crit_sect(crit_sect
)
326 EnterCriticalSection(&crit_sect
);
331 LeaveCriticalSection(&_crit_sect
);
335 CritSect
& _crit_sect
;
339 /// Thread base class
347 _hThread
= INVALID_HANDLE_VALUE
;
348 _evtFinish
= CreateEvent(NULL
, TRUE
, FALSE
, NULL
);
355 CloseHandle(_evtFinish
);
356 CloseHandle(_hThread
);
366 _hThread
= CreateThread(NULL
, 0, ThreadProc
, this, 0, NULL
);
372 SetEvent(_evtFinish
);
376 Lock
lock(_crit_sect
);
380 // wait for finishing
381 WaitForSingleObject(_hThread
, INFINITE
);
385 virtual int Run() = 0;
387 bool is_alive() const {return _alive
;}
392 static DWORD WINAPI
ThreadProc(void* para
);
403 /// ClientRect retreives the client area rectangle of a window.
404 struct ClientRect
: public RECT
406 ClientRect(HWND hwnd
)
408 GetClientRect(hwnd
, this);
411 operator LPRECT() {return this;}
413 POINT
& pos() {return *(LPPOINT
)this;}
416 /// ClientRect retreives the window rectangle of a window.
417 struct WindowRect
: public RECT
419 WindowRect(HWND hwnd
)
421 GetWindowRect(hwnd
, this);
424 operator LPRECT() {return this;}
426 POINT
& pos() {return *(LPPOINT
)this;}
429 /// PointL encapsulates the POINT structure into a C++ object.
430 struct Point
: public POINT
432 Point(LONG x_
, LONG y_
)
438 // constructor for being used in processing WM_MOUSEMOVE, WM_LBUTTONDOWN, ... messages
441 x
= GET_X_LPARAM(lparam
);
442 y
= GET_Y_LPARAM(lparam
);
445 operator LPPOINT() {return this;}
449 /// transform coordinates in a RECT from client to screen coordiantes
450 inline void ClientToScreen(HWND hwnd
, RECT
* prect
)
451 {::ClientToScreen(hwnd
,(LPPOINT
)&prect
->left
); ::ClientToScreen(hwnd
,(LPPOINT
)&prect
->right
);}
453 /// transform coordinates in a RECT from screen to client coordiantes
454 inline void ScreenToClient(HWND hwnd
, RECT
* prect
)
455 {::ScreenToClient(hwnd
,(LPPOINT
)&prect
->left
); ::ScreenToClient(hwnd
,(LPPOINT
)&prect
->right
);}
458 /// structure containing information about full screen display of the frame window
459 struct FullScreenParameters
461 FullScreenParameters()
474 /// PaintCanvas is a encapsulation of device contexts managed by BeginPaint()/EndPaint().
475 struct PaintCanvas
: public PAINTSTRUCT
477 PaintCanvas(HWND hwnd
)
480 BeginPaint(hwnd
, this);
485 EndPaint(_hwnd
, this);
488 operator HDC() const {return hdc
;}
494 /// Canvas is a encapsulation of device contexts.
497 Canvas(HDC hdc
) : _hdc(hdc
) {}
499 operator HDC() {return _hdc
;}
505 /// WindowCanvas is a encapsulation of client area device contexts.
506 struct WindowCanvas
: public Canvas
508 WindowCanvas(HWND hwnd
)
509 : Canvas(GetDC(hwnd
)), _hwnd(hwnd
) {}
511 ~WindowCanvas() {ReleaseDC(_hwnd
, _hdc
);}
518 // double buffering classes
520 /// Memory Canvas creates and destroys memory devoce contexts.
521 struct MemCanvas
: public Canvas
524 : Canvas(CreateCompatibleDC(hdc
)) {assert(_hdc
);}
526 ~MemCanvas() {DeleteDC(_hdc
);}
529 /// SelectedBitmap is used to localy select bitmaps into device contexts.
530 struct SelectedBitmap
532 SelectedBitmap(HDC hdc
, HBITMAP hbmp
)
533 : _hdc(hdc
), _old_hbmp(SelectBitmap(hdc
, hbmp
)) {}
535 ~SelectedBitmap() {DeleteObject(SelectBitmap(_hdc
, _old_hbmp
));}
542 /// BufferCanvas manages offscreen bitmaps selected into memory device contexts.
543 struct BufferCanvas
: public MemCanvas
545 BufferCanvas(HDC hdc
, int x
, int y
, int w
, int h
)
546 : MemCanvas(hdc
), _hdctarg(hdc
),
547 _x(x
), _y(y
), _w(w
), _h(h
),
548 _bmp(_hdc
, CreateCompatibleBitmap(hdc
, w
, h
)) {}
550 BufferCanvas(HDC hdc
, const RECT
& rect
)
551 : MemCanvas(hdc
), _hdctarg(hdc
),
552 _x(rect
.left
), _y(rect
.top
), _w(rect
.right
-rect
.left
), _h(rect
.bottom
-rect
.top
),
553 _bmp(_hdc
, CreateCompatibleBitmap(hdc
, _w
, _h
)) {}
561 /// BufferedCanvas enables double buffering for a device context.
562 struct BufferedCanvas
: public BufferCanvas
564 BufferedCanvas(HDC hdc
, int x
, int y
, int w
, int h
, DWORD mode
=SRCCOPY
)
565 : BufferCanvas(hdc
, x
, y
, w
, h
), _mode(mode
) {}
567 BufferedCanvas(HDC hdc
, const RECT
& rect
, DWORD mode
=SRCCOPY
)
568 : BufferCanvas(hdc
, rect
), _mode(mode
) {}
570 ~BufferedCanvas() {BitBlt(_hdctarg
, _x
, _y
, _w
, _h
, _hdc
, 0, 0, _mode
);}
575 /// BufferedPaintCanvas extends PaintCanvas for double buffering.
576 struct BufferedPaintCanvas
: public PaintCanvas
, public BufferedCanvas
578 BufferedPaintCanvas(HWND hwnd
)
580 BufferedCanvas(PAINTSTRUCT::hdc
, 0, 0, rcPaint
.right
, rcPaint
.bottom
)
584 operator HDC() {return BufferedCanvas::_hdc
;}
588 /// TextColor locally selects a text color for drawing.
591 TextColor(HDC hdc
, COLORREF color
)
592 : _hdc(hdc
), _old_color(SetTextColor(hdc
, color
)) {}
594 ~TextColor() {SetTextColor(_hdc
, _old_color
);}
601 /// BkMode locally sets the background mode for drawing.
604 BkMode(HDC hdc
, int bkmode
)
605 : _hdc(hdc
), _old_bkmode(SetBkMode(hdc
, bkmode
)) {}
607 ~BkMode() {SetBkMode(_hdc
, _old_bkmode
);}
611 COLORREF _old_bkmode
;
614 /// FontSelection locally selects a font for drawing.
617 FontSelection(HDC hdc
, HFONT hFont
)
618 : _hdc(hdc
), _old_hFont(SelectFont(hdc
, hFont
)) {}
620 ~FontSelection() {SelectFont(_hdc
, _old_hFont
);}
627 /// BitmapSelection locally selects a bitmap into a device context.
628 struct BitmapSelection
630 BitmapSelection(HDC hdc
, HBITMAP hBmp
)
631 : _hdc(hdc
), _old_hBmp(SelectBitmap(hdc
, hBmp
)) {}
633 ~BitmapSelection() {SelectBitmap(_hdc
, _old_hBmp
);}
640 /// BrushSelection locally selects a brush into a device context.
641 struct BrushSelection
643 BrushSelection(HDC hdc
, HBRUSH hBrush
)
644 : _hdc(hdc
), _old_hBrush(SelectBrush(hdc
, hBrush
)) {}
646 ~BrushSelection() {SelectBrush(_hdc
, _old_hBrush
);}
658 : _hmenu(CreatePopupMenu())
664 operator HMENU() {return _hmenu
;}
666 void Append(UINT id
, LPCTSTR str
, UINT flags
=MF_STRING
)
668 AppendMenu(_hmenu
, flags
, id
, str
);
671 int TrackPopupMenu(HWND hwnd
, const POINT
& pt
, UINT flags
=TPM_LEFTBUTTON
|TPM_RIGHTBUTTON
, LPTPMPARAMS tpm
=NULL
) {
672 return TrackPopupMenuEx(_hmenu
, flags
, pt
.x
, pt
.y
, hwnd
, tpm
);
675 int PopupContextMenu(HWND hwnd
, POINTS pos
, UINT flags
=TPM_LEFTBUTTON
|TPM_RIGHTBUTTON
) {
676 POINT pt
; POINTSTOPOINT(pt
, pos
);
677 return TrackPopupMenuEx(_hmenu
, flags
, pt
.x
, pt
.y
, hwnd
, NULL
);
680 int TrackPopupMenu(HWND hwnd
, POINTS pos
, UINT flags
=TPM_LEFTBUTTON
|TPM_RIGHTBUTTON
) {
681 POINT pt
; POINTSTOPOINT(pt
, pos
);
682 ClientToScreen(hwnd
, &pt
);
683 return TrackPopupMenuEx(_hmenu
, flags
, pt
.x
, pt
.y
, hwnd
, NULL
);
686 int TrackPopupMenuAtCursor(HWND hwnd
, UINT flags
=TPM_LEFTBUTTON
) {
687 POINT pt
; GetCursorPos(&pt
);
688 return TrackPopupMenuEx(_hmenu
, flags
, pt
.x
, pt
.y
, hwnd
, NULL
);
691 int TrackPopupMenuAtPos(HWND hwnd
, DWORD pos
, UINT flags
=TPM_LEFTBUTTON
) {
692 return TrackPopupMenuEx(_hmenu
, flags
, GET_X_LPARAM(pos
), GET_Y_LPARAM(pos
), hwnd
, NULL
);
700 struct Variant
: public VARIANT
702 Variant() {VariantInit(this);}
703 Variant(const VARIANT
& var
);
704 Variant(const VARIANT
* var
);
707 operator long() const;
708 operator bool() const;
709 operator VARIANT_BOOL() const;
710 operator IDispatch
*() const;
723 _p
= SysAllocString(s
);
731 _p
= SysAllocStringLen(b
, MultiByteToWideChar(CP_ACP
, 0, s
, -1, b
, BUFFER_LEN
)-1);
738 _p
= SysAllocString(s
);
741 BStr(const VARIANT
& var
)
753 void assign(const VARIANT
& var
);
755 operator BSTR() const
757 return _p
? _p
: (BSTR
)L
"";
762 return _p
? wcslen(_p
): 0;
770 /// string class for TCHAR strings
779 typedef wstring super
;
781 typedef string super
;
786 String(LPCTSTR s
) {if (s
) super::assign(s
);}
787 String(LPCTSTR s
, int l
) : super(s
, l
) {}
789 String(const super
& other
) : super(other
) {}
790 String(const String
& other
) : super(other
) {}
793 String(LPCSTR s
) {assign(s
);}
794 String(LPCSTR s
, int l
) {assign(s
, l
);}
795 String(const string
& other
) {assign(other
.c_str());}
796 String
& operator=(LPCSTR s
) {assign(s
); return *this;}
797 void assign(LPCSTR s
) {if (s
) {TCHAR b
[BUFFER_LEN
]; super::assign(b
, MultiByteToWideChar(CP_ACP
, 0, s
, -1, b
, BUFFER_LEN
)-1);} else erase();}
798 void assign(LPCSTR s
, int l
) {if (s
) {TCHAR b
[BUFFER_LEN
]; super::assign(b
, MultiByteToWideChar(CP_ACP
, 0, s
, l
, b
, BUFFER_LEN
));} else erase();}
799 void assign(const BStr
& s
) {int l
= s
.length(); super::assign(s
, l
);}
801 String(LPCWSTR s
) {assign(s
);}
802 String(LPCWSTR s
, int l
) {assign(s
, l
);}
803 String(const wstring
& other
) {assign(other
.c_str());}
804 String
& operator=(LPCWSTR s
) {assign(s
); return *this;}
805 void assign(LPCWSTR s
) {if (s
) {char b
[BUFFER_LEN
]; super::assign(b
, WideCharToMultiByte(CP_ACP
, 0, s
, -1, b
, BUFFER_LEN
, 0, 0)-1);} else erase();}
806 void assign(LPCWSTR s
, int l
) {if (s
) {char b
[BUFFER_LEN
]; super::assign(b
, WideCharToMultiByte(CP_ACP
, 0, s
, l
, b
, BUFFER_LEN
, 0, 0));} else erase();}
807 void assign(const BStr
& s
) {int l
= s
.length(); if (l
) {char b
[BUFFER_LEN
]; super::assign(b
, WideCharToMultiByte(CP_ACP
, 0, s
, l
, b
, BUFFER_LEN
, 0, 0));} else erase();}
809 String(const BStr
& s
) {assign(s
);}
810 String
& operator=(const BStr
& s
) {assign(s
); return *this;}
812 String
& operator=(LPCTSTR s
) {if (s
) super::assign(s
); else erase(); return *this;}
813 String
& operator=(const super
& s
) {super::assign(s
); return *this;}
814 void assign(LPCTSTR s
) {super::assign(s
);}
815 void assign(LPCTSTR s
, int l
) {super::assign(s
, l
);}
817 operator LPCTSTR() const {return c_str();}
820 operator string() const {char b
[BUFFER_LEN
]; return string(b
, WideCharToMultiByte(CP_ACP
, 0, c_str(), -1, b
, BUFFER_LEN
, 0, 0)-1);}
822 operator wstring() const {WCHAR b
[BUFFER_LEN
]; return wstring(b
, MultiByteToWideChar(CP_ACP
, 0, c_str(), -1, b
, BUFFER_LEN
)-1);}
825 LPTSTR
str() {return (LPTSTR
)data();} /// return modifyable character string pointer
827 String
& printf(LPCTSTR fmt
, ...)
833 super::assign(b
, _vsntprintf(b
, COUNTOF(b
), fmt
, l
));
839 String
& vprintf(LPCTSTR fmt
, va_list l
)
843 super::assign(b
, _vsntprintf(b
, COUNTOF(b
), fmt
, l
));
848 String
& appendf(LPCTSTR fmt
, ...)
854 super::append(b
, _vsntprintf(b
, COUNTOF(b
), fmt
, l
));
860 String
& vappendf(LPCTSTR fmt
, va_list l
)
864 super::append(b
, _vsntprintf(b
, COUNTOF(b
), fmt
, l
));
876 #define _STRING_DEFINED
879 struct FmtString
: public String
881 FmtString(LPCTSTR fmt
, ...)
898 int l
= wcslen(s
) + 1;
899 _str
= (LPSTR
) malloc(2*l
);
901 if (WideCharToMultiByte(CP_ACP
, 0, s
, -1, _str
, 2*l
, 0, 0) <= 0)
910 operator LPCSTR() {return _str
;}
916 #define UNC(x) ((LPCWSTR)(x))
920 #define ANS(x) ((LPCSTR)(x))
926 int l
= strlen(s
) + 1;
927 _str
= (LPWSTR
) malloc(2*l
);
929 if (_str
&& MultiByteToWideChar(CP_ACP
, 0, s
, -1, _str
, l
) <= 0)
938 operator LPCWSTR() {return _str
;}
947 // determine windows version string
948 String
get_windows_version_str();
951 /// link dynamicly to functions by using GetModuleHandle() and GetProcAddress()
952 template<typename FCT
> struct DynamicFct
954 DynamicFct(LPCTSTR moduleName
, UINT ordinal
)
956 HMODULE hModule
= GetModuleHandle(moduleName
);
958 _fct
= (FCT
) GetProcAddress(hModule
, (LPCSTR
)ordinal
);
961 DynamicFct(LPCTSTR moduleName
, LPCSTR name
)
963 HMODULE hModule
= GetModuleHandle(moduleName
);
965 _fct
= (FCT
) GetProcAddress(hModule
, name
);
968 FCT
operator*() const {return _fct
;}
969 operator bool() const {return _fct
? true: false;}
976 /// link dynamicly to functions by using LoadLibrary() and GetProcAddress()
977 template<typename FCT
> struct DynamicLoadLibFct
979 DynamicLoadLibFct(LPCTSTR moduleName
, UINT ordinal
)
981 _hModule
= LoadLibrary(moduleName
);
983 _fct
= (FCT
) GetProcAddress(_hModule
, (LPCSTR
)ordinal
);
986 DynamicLoadLibFct(LPCTSTR moduleName
, LPCSTR name
)
988 _hModule
= LoadLibrary(moduleName
);
990 _fct
= (FCT
) GetProcAddress(_hModule
, name
);
995 FreeLibrary(_hModule
);
998 FCT
operator*() const {return _fct
;}
999 operator bool() const {return _fct
? true: false;}
1009 Context(const char* ctx
)
1016 Context(const char* ctx
, LPCSTR obj
)
1024 Context(const char* ctx
, LPCWSTR obj
)
1032 Context(const Context
& other
)
1047 String
toString() const;
1048 String
getStackTrace() const;
1053 static Context
& current() {return *s_current
;}
1058 static Context
* s_current
; ///@todo use TLS
1059 static Context s_main
;
1062 #define CONTEXT_OBJ __ctx__._obj
1063 #define CONTEXT(c) Context __ctx__(c)
1064 #define CURRENT_CONTEXT Context::current()
1065 #define OBJ_CONTEXT(c, o) Context __ctx__(c, o)
1068 extern bool SplitFileSysURL(LPCTSTR url
, String
& dir_out
, String
& fname_out
);
1071 #endif // __cplusplus