26 Buffer buf = make_Buffer(CStringA(str).GetLength());
28 copy_b2Buffer(CStringA(str).GetBuffer(), &buf, CStringA(str).GetLength());
36 if (size<0) size = LDATA;
37 Buffer buf = make_Buffer(size);
43 int err = wcstombs_s(&len, (
char*)buf.buf, buf.bufsz, tchar, _TRUNCATE);
45 if (err!=0) clear_Buffer(&buf);
46 else buf.vldsz = (int)Min(len-1, strlen((
char*)buf.buf));
49 copy_s2Buffer(tchar, &buf);
58 if (size<0) size = (int)tcslen(str);
63 Buffer buf = make_Buffer((size+1)*4);
66 int err = wcstombs_s(&len, (
char*)buf.buf, buf.bufsz, str, _TRUNCATE);
67 if (err!=0) clear_Buffer(&buf);
68 else buf.vldsz = (int)Min(len-1, strlen((
char*)buf.buf));
71 Buffer buf = make_Buffer(size);
72 copy_b2Buffer((
char*)str, &buf, size);
82 if (str==NULL)
return buf;
88 size_t size = strlen(str);
91 if (size + 1 > SBUFSZ) {
92 TCHAR tchar_recv[RECVBUFSZ];
93 if (size + 1 > RECVBUFSZ) {
94 size_t ptchar_sz = (size + 1) *
sizeof(TCHAR);
95 TCHAR* ptchar = (TCHAR*)malloc(ptchar_sz);
96 err = mbstowcs_s(&len, ptchar, ptchar_sz, str, size);
97 if (err == 0) buf = ptchar;
101 err = mbstowcs_s(&len, tchar_recv, RECVBUFSZ, str, size);
102 if (err == 0) buf = tchar_recv;
106 err = mbstowcs_s(&len, tchar, SBUFSZ, str, size);
107 if (err == 0) buf = tchar;
138 if (buf==NULL)
return -1;
142 char* mbstr =
ts2mbs(str);
143 copy_s2Buffer(mbstr, buf);
147 cc = copy_s2Buffer((
char*)str, buf);
163 if (buf==NULL)
return -1;
167 char* mbstr =
ts2mbs(str);
168 cat_s2Buffer(mbstr, buf);
172 cc = cat_s2Buffer((
char*)str, buf);
187 Buffer buf = init_Buffer();
188 if (str.IsEmpty())
return buf;
190 buf =
utf8_to_sjis(CStringA(str).GetBuffer(), CStringA(str).GetLength());
199 int len_unic = MultiByteToWideChar(CP_UTF8, 0, (LPCCH)ptr, (
int)len, NULL, 0);
200 wchar_t* buf_unic =
new wchar_t[len_unic];
201 MultiByteToWideChar(CP_UTF8, 0, (LPCCH)ptr, (
int)len + 1, buf_unic, len_unic);
204 int len_sjis = WideCharToMultiByte(CP_THREAD_ACP, 0, buf_unic, -1, NULL, 0, NULL, NULL);
205 Buffer buf_sjis = make_Buffer(len_sjis);
206 WideCharToMultiByte(CP_THREAD_ACP, 0, buf_unic, len_unic, (LPSTR)buf_sjis.buf, len_sjis, NULL, NULL);
210 buf_sjis.vldsz = len_sjis;
218 Buffer buf = init_Buffer();
219 if (str.IsEmpty())
return buf;
221 buf =
sjis_to_utf8(CStringA(str).GetBuffer(), CStringA(str).GetLength());
230 int len_unic = MultiByteToWideChar(CP_THREAD_ACP, 0, (LPCCH)ptr, (
int)len, NULL, 0);
231 wchar_t* buf_unic =
new wchar_t[len_unic];
232 MultiByteToWideChar(CP_THREAD_ACP, 0, (LPCCH)ptr, (
int)len + 1, buf_unic, len_unic);
235 int len_utf8 = WideCharToMultiByte(CP_UTF8, 0, buf_unic, -1, NULL, 0, NULL, NULL);
236 Buffer buf_utf8 = make_Buffer(len_utf8);
237 WideCharToMultiByte(CP_UTF8, 0, buf_unic, len_unic, (LPSTR)buf_utf8.buf, len_utf8, NULL, NULL);
241 buf_utf8.vldsz = len_utf8;
254 return stbuf.st_size;
261 if (fn==NULL)
return FALSE;
264 FILE* fp = tfopen(fn, _T(
"rb"));
270 ret = file_exist((
char*)fn);
279 CString buf = _T(
"");
282 char* mbstr =
ts2mbs(str);
283 char* fn = get_file_name(mbstr);
287 char* fn = get_file_name((
char*)str);
297 CString buf = _T(
"");
300 char* mbstr =
ts2mbs(str);
302 char* pn = get_file_path(mbstr);
308 char* pn = get_file_path((
char*)str);
319 CString buf = _T(
"");
322 char* mbstr =
ts2mbs(str);
323 char* pn = cut_file_extension(mbstr);
328 char* pn = cut_file_extension((
char*)str);
343 WIN32_FIND_DATA FindFileData;
345 CString dirstr = dirn;
347 if (dirstr.Right(1)!=
"\\") dirstr += _T(
"\\*");
348 hFind = FindFirstFile((LPCTSTR)dirstr, &FindFileData);
349 if (hFind!=INVALID_HANDLE_VALUE) {
352 char* fn =
ts2mbs(FindFileData.cFileName);
353 if (strcmp(
".", fn) && strcmp(
"..", fn)) {
355 if (tmp.buf[tmp.vldsz-1]!=
'\\') cat_s2Buffer(
"\\", &tmp);
357 ln = add_tList_node_str(ln, NULL, tmp.buf);
358 if (lp==NULL) lp = ln;
362 }
while (FindNextFile(hFind, &FindFileData));
373 if (lp==NULL)
return NULL;
375 tList* lt = dup_tList(lp);
378 if (lc!=NULL) add_tList_end(lp, lc);
389 char* pathstr = NULL;
390 if (fn!=_T(
"")) pathstr =
ts2mbs(fn);
392 tList* lt = read_index_tList_file(pathstr, cc);
407 sntprintf(fname, LNAME-1, fmt, n);
415 Buffer buf = buffer_key_tList(lt, key, 1);
417 CString ret =
mbs2ts((
char*)buf.buf);
421 return (CString)dflt;
432 _tsetlocale(LC_ALL, (LPCTSTR)locale);
439 _tsetlocale(LC_ALL, locale);
456#pragma comment(lib, "userenv.lib")
457#pragma comment(lib, "imagehlp.lib")
463 DWORD size = (DWORD)LMESG;
465 CString ret = _T(
"");
467 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
468 BOOL rslt = GetUserProfileDirectory(token, dirn, &size);
470 if (rslt && size<=LMESG) ret = dirn;
477 DWORD size = (DWORD)LMESG;
479 CString ret = _T(
"");
481 BOOL rslt = GetDefaultUserProfileDirectory(dirn, &size);
482 if (rslt && size<=LMESG) ret = dirn;
491 if (local) path += _T(
"\\AppData\\Local");
492 else path += _T(
"\\AppData\\Roaming");
494 if (dir!=NULL) path += dir;
495 else path += _T(
"\\");
498 char* mbstr =
ts2mbs(path);
499 MakeSureDirectoryPathExists(mbstr);
502 if (fnm!=NULL) path += fnm;
512 CString ret =
mbs2ts(path);
523 GetModuleFileName(NULL, dirn, (DWORD)LMESG);
525 char* path =
ts2mbs(dirn);
526 int len = (int)strlen(path);
528 for (
int i=1; i<len; i++) {
529 if (path[len-i-1]==
'\\') {
543 GetCurrentDirectory(LMESG, dirn);
547 GetCurrentDirectory(LMESG, dirn);
551 CString folder = dirn;
563 CWinApp* app = AfxGetApp();
565 CWnd* wnd = app->m_pMainWnd;
566 if (wnd!=NULL) wnd->SendMessage(mesg, wparam, lparam);
578 int ret = ::MessageBox(hWnd, msg, ttl, type);
589 if (data.IsEmpty())
return;
591 SaveToClipboard(CStringA(data).GetBuffer(), CStringA(data).GetLength());
597 if (ptr == NULL)
return;
599 HGLOBAL hMem = ::GlobalAlloc(GHND, len);
600 char* pszptr = (
char*)::GlobalLock(hMem);
602 memcpy(pszptr, ptr, len);
605 ::GlobalUnlock(hMem);
607 if (!OpenClipboard(NULL)) {
611 if (!EmptyClipboard()) {
615 if (SetClipboardData(CF_TEXT, hMem) == NULL) {
632 input.type = INPUT_KEYBOARD;
634 input.ki.wScan = MapVirtualKeyW(key, 0);
635 input.ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
638 SendInput(1, &input,
sizeof(INPUT));
641 input.ki.dwFlags |= KEYEVENTF_KEYUP;
642 SendInput(1, &input,
sizeof(INPUT));
673 if (com==NULL)
return TRUE;
676 if (!tcscmp(com, _T(
"UP"))) {
679 else if (!tcscmp(com, _T(
"DOWN"))) {
682 else if (!tcscmp(com, _T(
"RIGHT"))) {
685 else if (!tcscmp(com, _T(
"LEFT"))) {
688 else if (!tcscmp(com, _T(
"NEXT")) || !tcscmp(com, _T(
"TAB"))) {
691 else if (!tcscmp(com, _T(
"BACK"))) {
694 else if (!tcscmp(com, _T(
"ENTER"))) {
697 else if (!tcscmp(com, _T(
"MENU")) || !tcscmp(com, _T(
"ALT"))) {
700 else if (!tcscmp(com, _T(
"ESC"))) {
704 else if (!tcscmp(com, _T(
"CHANGE"))) {
707 else if (!tcscmp(com, _T(
"CLOSE"))) {
753 ci.cbSize =
sizeof(CURSORINFO);
758 while (*table!=NULL) {
759 if (ci.hCursor==LoadCursor(NULL, (LPTSTR)*table))
return *table;
783 unsigned short nm = tm.wSecond*(
unsigned short)1000 + tm.wMilliseconds;
804 unsigned short nm = tm.wSecond*(
unsigned short)1000 + tm.wMilliseconds;
806 if (pm>nm) ret = nm + ((
unsigned short)60000 - pm);
809 if (nt!=NULL) *nt = nm;
821 PROCESS_INFORMATION pinfo;
823 memset(&sinfo, 0,
sizeof(STARTUPINFO));
824 sinfo.cb =
sizeof(STARTUPINFO);
827 CreateProcessA(NULL, (LPSTR)command, NULL, NULL, FALSE, flag, NULL, NULL, (LPSTARTUPINFOA)&sinfo, &pinfo);
829 CloseHandle(pinfo.hThread);
830 if (wait) WaitForSingleObject(pinfo.hProcess, INFINITE);
831 CloseHandle(pinfo.hProcess);
852 create(manual, initial, hname, sec);
872 m_handle = CreateEvent(secu, manual, initial, hname);
901 if (handle==NULL)
return FALSE;
903 m_wait_err = WaitForSingleObject(handle, msec);
HANDLE create(BOOL manual=TRUE, BOOL initial=FALSE, LPCTSTR hname=NULL, LPSECURITY_ATTRIBUTES sec=NULL)
BOOL wait(DWORD msec=INFINITE)
CString make_file_path_t(LPCTSTR str)
CString GetDefaultUserHomeFolder(void)
Buffer utf8_to_sjis(void *ptr, size_t len)
tList * read_index_tList_file_t(LPCTSTR fn, char cc)
CString get_file_name_t(LPCTSTR str)
void SendKeyActionTap(WORD key)
char * GetProgramFolderA(void)
int cat_ts2Buffer(LPCTSTR str, Buffer *buf)
char * ts2mbs(LPCTSTR str)
void SendKeyActionTapAlt(WORD key)
int copy_ts2Buffer(LPCTSTR str, Buffer *buf)
Buffer sjis_to_utf8_byStr(CString str)
BOOL DoSystemKeyAction(LPCTSTR com, BOOL child=FALSE)
unsigned short GetMsecondsLapTimer(unsigned short pm, unsigned short *nt=NULL)
CString mbs2ts(char *str)
tList * get_dir_files_rcsv_t(LPCTSTR dirn)
void SendKeyAction(WORD key, SENDKEY_Action action)
void setSystemLocale(LPCTSTR locale=_T(""))
CString MakeWorkingFolderPath(LPCTSTR fnm, BOOL local, LPCTSTR dir=NULL, BOOL make=FALSE)
void WinSystem(char *command, DWORD flag, BOOL wait)
Buffer ts2Buffer(LPCTSTR str, int size=-1)
CString GetCurrentUserHomeFolder(void)
void SaveToClipboard_byStr(CString data)
Buffer utf8_to_sjis_byStr(CString str)
void setResourceLocale(void)
CString get_tstr_param_tList(tList *lt, char *key, LPCTSTR dflt)
int MessageDLG(LPCTSTR ttl, LPCTSTR msg, UINT type, HWND hWnd)
CString GetCurrentFolder(void)
void SendWinMessage(UINT mesg, WPARAM wparam=NULL, LPARAM lparam=NULL)
CString GetProgramFolder(void)
tList * get_dir_files_t(LPCTSTR dirn)
void SendKeyActionTapCtrl(WORD key)
CString getResourceLocale(void)
unsigned short GetMsecondsTimer(void)
void SaveToClipboard(void *ptr, size_t len)
Buffer tc2Buffer(TCHAR *tchar, int size=-1)
locale が正しくないと,日本語の変換は失敗する. ex.) setlocale(LC_CTYPE,"jpn") or setSystemLocale()
Buffer String2Buffer(CString str)
CString numbering_name_t(LPCTSTR fmt, int n)
BOOL file_exist_t(LPCTSTR fn)
CString LoadString_byID(UINT id)
TCHAR * GetMouseCursorType(void)
CString cut_file_extension_t(LPCTSTR str)
unsigned long int file_size_t(LPCTSTR fn)
Buffer sjis_to_utf8(void *ptr, size_t len)