[go: up one dir, main page]

Menu

[r1]: / Helpers.h  Maximize  Restore  History

Download this file

85 lines (68 with data), 2.9 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef HELPERS_H
#define HELPERS_H
//#define WIN32_MEAN_AND_LEAN
#include <windows.h>
#define COUNT(ar) (sizeof(ar)/sizeof(*(ar)))
//#define CreateStdThread(proc, lParam) CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) proc, lParam, 0, NULL)
#define CreateRunningThread(proc, lParam, id) CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) proc, lParam, 0, id)
#define CreateSuspendedThread(proc, lParam, id) CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) proc, lParam, CREATE_SUSPENDED, id)
#define CharToUnicode(lpUnicode, lpChar, lenSrc) \
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpChar, lenSrc+1,lpUnicode ,lenSrc+1)
#define UnicodeToChar(lpChar, lpUnicode, lenSrc) \
WideCharToMultiByte(CP_ACP, 0, lpUnicode ,lenSrc+1, lpChar, lenSrc+1, NULL, NULL)
/*
#define CharToUnicodeZ(lpUnicode, lpChar) \
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpChar, -1,lpUnicode ,1000)
#define UnicodeToCharZ(lpChar, lpUnicode) \
WideCharToMultiByte(CP_ACP, 0, lpUnicode ,-1, lpChar, 1000, NULL, NULL)
*/
//#define DeletePtr(ptr) if(ptr){delete ptr; ptr = NULL;}
#define DeletePtr(ptr) {delete ptr; ptr = NULL;}
//#define ReNew(
BOOL CreateDirRecursive(LPCTSTR lpDir);
int StrFormat(LPTSTR out, LPCTSTR format, ...);
#define GetHinstance ((HINSTANCE) GetModuleHandle(NULL))
//#define StrCopy(dst,src) for(int _idx=0; (dst[_idx]=src[_idx])!=0;_idx++)
//#define StrNCopy(dst,src,ln) for(int _idx=0; (dst[_idx]=src[_idx])!=0 && _idx<(ln);_idx++)
/*
#define StrCopy(dst,src) \
__asm{ \
LEA ESI, src \
LEA EDI, dst \
CLD \
REPNZ MOVS EDI,ESI \
}
#define StrNCopy(dst,src,ln) for(int _idx=0; (dst[_idx]=src[_idx])!=0 && _idx<(ln);_idx++)
*/
// prevent including SHLWAPI
#define NO_SHLWAPI_STRFCNS
#ifdef _INC_SHLWAPI
#pragma message("SHLWAPI included before HELPERS. Function prototype conflict possible")
#undef StrDup
#undef StrCmp
#undef StrNCmp
#endif
LPSTR StrCopy(LPSTR dst, LPCSTR src);
LPWSTR StrCopy(LPWSTR dst, LPCWSTR src);
LPSTR StrNCopy(LPSTR dst,LPCSTR src,DWORD ln);
LPWSTR StrNCopy(LPWSTR dst,LPCWSTR src,DWORD ln);
/*
void StrNCopy(LPSTR dst,LPCSTR src,DWORD ln);
void StrNCopy(LPWSTR dst,LPCWSTR src,DWORD ln);
*/
DWORD StrLen(LPCSTR str);
DWORD StrLen(LPCWSTR str);
LPSTR StrDup(LPCSTR str);
LPWSTR StrDup(LPCWSTR str);
int StrNCmp(LPCSTR str1, LPCSTR str2, DWORD len);
int StrNCmp(LPCWSTR str1, LPCWSTR str2, DWORD len);
int StrCmp(LPCSTR str1, LPCSTR str2);
int StrCmp(LPCWSTR str1, LPCWSTR str2);
LPTSTR StrChar(LPCTSTR str,TCHAR chr);
LPTSTR StrRChar(LPCTSTR str,TCHAR chr);
#define REMAKE_IPADDRESS(ip) ( (((ip) & 0xFF)<<24) | (((ip) & 0xFF00)<<8) | (((ip)>>8) & 0xFF00) | (((ip)>>24)& 0xFF))
// include only if user has included SHLOBJ.H
//#ifdef _SHLOBJ_H_
//STDAPI SHGetTargetFolderPath(LPCITEMIDLIST pidlFolder, LPWSTR pszPath, UINT cchPath);
//#endif
#endif