#define _MAX_PATH 260
#endif
+#define W_VER_NT 0 // constant for HIWORD(GetVersion())>>14
+
#ifdef __cplusplus
extern "C" {
// create a directory with all missing parent directories
BOOL RecursiveCreateDirectory(LPCTSTR path_in);
+ // read DWORD value from registry
+DWORD RegGetDWORDValue(HKEY root, LPCTSTR path, LPCTSTR valueName, DWORD def);
+
+ // write DWORD value to registry
+BOOL RegSetDWORDValue(HKEY root, LPCTSTR path, LPCTSTR valueName, DWORD value);
+
+ // test for existing directory
+BOOL exists_path(LPCTSTR path);
+
#ifdef __cplusplus
} // extern "C"
#include <map>
#include <set>
#include <list>
+#include <stack>
#include <vector>
// launch a program or document file
-extern BOOL launch_file(HWND hwnd, LPCTSTR cmd, UINT nCmdShow, LPCTSTR parameters=NULL);
+extern BOOL launch_file(HWND hwnd, LPCTSTR cmd, UINT nCmdShow=SW_SHOWNORMAL, LPCTSTR parameters=NULL);
#ifdef UNICODE
-extern BOOL launch_fileA(HWND hwnd, LPSTR cmd, UINT nCmdShow, LPCSTR parameters=NULL);
+extern BOOL launch_fileA(HWND hwnd, LPSTR cmd, UINT nCmdShow=SW_SHOWNORMAL, LPCSTR parameters=NULL);
#else
#define launch_fileA launch_file
#endif
struct HiddenWindow : public WindowHandle
{
HiddenWindow(HWND hwnd)
- : WindowHandle(hwnd)
+ : WindowHandle(IsWindowVisible(hwnd)? hwnd: 0)
{
- SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW|SWP_NOREDRAW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER);
+ if (_hwnd)
+ SetWindowPos(_hwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW|SWP_NOREDRAW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER);
}
~HiddenWindow()
{
- SetWindowPos(_hwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER);
+ if (_hwnd)
+ SetWindowPos(_hwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW|SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER);
}
};
struct Thread
{
Thread()
- : _alive(false)
+ : _alive(false),
+ _destroy(false)
{
_hThread = INVALID_HANDLE_VALUE;
+ _evtFinish = CreateEvent(NULL, TRUE, FALSE, NULL);
}
virtual ~Thread()
{
Stop();
+ CloseHandle(_evtFinish);
CloseHandle(_hThread);
+
+ if (_destroy)
+ delete this;
}
void Start()
void Stop()
{
+ SetEvent(_evtFinish);
+
if (_alive) {
{
Lock lock(_crit_sect);
static DWORD WINAPI ThreadProc(void* para);
HANDLE _hThread;
+ HANDLE _evtFinish;
bool _alive;
+ bool _destroy;
};
#endif
String() {}
+
String(LPCTSTR s) {if (s) super::assign(s);}
String(LPCTSTR s, int l) : super(s, l) {}
+
String(const super& other) : super(other) {}
String(const String& other) : super(other) {}
operator wstring() const {WCHAR b[BUFFER_LEN]; return wstring(b, MultiByteToWideChar(CP_ACP, 0, c_str(), -1, b, BUFFER_LEN)-1);}
#endif
- void assign_utf8(const char* str)
- {
- TCHAR buffer[BUFFER_LEN];
-
-#ifdef UNICODE
- int l = MultiByteToWideChar(CP_UTF8, 0, str, -1, buffer, BUFFER_LEN) - 1;
-#else
- WCHAR wbuffer[BUFFER_LEN];
-
- int l = MultiByteToWideChar(CP_UTF8, 0, str, -1, wbuffer, BUFFER_LEN) - 1;
- l = WideCharToMultiByte(CP_ACP, 0, wbuffer, l, buffer, BUFFER_LEN, 0, 0);
-#endif
-
- assign(buffer, l);
- }
-
- string get_utf8() const
- {
- char buffer[BUFFER_LEN];
-
-#ifdef UNICODE
- int l = WideCharToMultiByte(CP_UTF8, 0, c_str(), length(), buffer, BUFFER_LEN, 0, 0);
-#else
- WCHAR wbuffer[BUFFER_LEN];
-
- int l = MultiByteToWideChar(CP_ACP, 0, c_str(), length(), wbuffer, BUFFER_LEN);
- l = WideCharToMultiByte(CP_UTF8, 0, wbuffer, l, buffer, BUFFER_LEN, 0, 0);
-#endif
-
- return string(buffer, l);
- }
-
String& printf(LPCTSTR fmt, ...)
{
va_list l;
}
};
+#define _STRING_DEFINED
+
struct FmtString : public String
{
#endif
+ // determine windows version string
+String get_windows_version_str();
+
+
/// link dynamicly to functions by using GetModuleHandle() and GetProcAddress()
template<typename FCT> struct DynamicFct
{
#define CONTEXT_OBJ __ctx__._obj
#define CONTEXT(c) Context __ctx__(c)
#define CURRENT_CONTEXT Context::current()
-#define OBJ_CONTEXT(c, o) Context __ctx__(c, o);
+#define OBJ_CONTEXT(c, o) Context __ctx__(c, o)
+
+
+extern bool SplitFileSysURL(LPCTSTR url, String& dir_out, String& fname_out);
#endif // __cplusplus