OSDN Git Service

Add support for simultaneous connection for file transfer (sometimes freezes).
[ffftp/ffftp.git] / mbswrapper.h
1 // mbswrapper.h
2 // Copyright (C) 2011 Suguru Kawamoto
3 // マルチバイト文字ワイド文字APIラッパー
4
5 #ifndef __MBSWRAPPER_H__
6 #define __MBSWRAPPER_H__
7
8 #include <windows.h>
9 #include <shlobj.h>
10
11 #ifndef DO_NOT_REPLACE
12
13 #undef CreateFile
14 #define CreateFile CreateFileM
15 HANDLE CreateFileM(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
16 #undef MessageBox
17 #define MessageBox MessageBoxM
18 int MessageBoxM(HWND hWnd, LPCSTR lpText, LPCSTR lpCaption, UINT uType);
19 #undef FindFirstFile
20 #define FindFirstFile FindFirstFileM
21 HANDLE FindFirstFileM(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData);
22 #undef FindNextFile
23 #define FindNextFile FindNextFileM
24 BOOL FindNextFileM(HANDLE hFindFile, LPWIN32_FIND_DATAA lpFindFileData);
25 #undef GetLogicalDriveStrings
26 #define GetLogicalDriveStrings GetLogicalDriveStringsM
27 DWORD GetLogicalDriveStringsM(DWORD nBufferLength, LPSTR lpBuffer);
28 #undef RegisterClassEx
29 #define RegisterClassEx RegisterClassExM
30 ATOM RegisterClassExM(CONST WNDCLASSEXA * v0);
31 #undef CreateWindowEx
32 #define CreateWindowEx CreateWindowExM
33 HWND CreateWindowExM(DWORD dwExStyle, LPCSTR lpClassName, LPCSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth, int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam);
34 #undef GetWindowLong
35 #define GetWindowLong GetWindowLongM
36 LONG GetWindowLongM(HWND hWnd, int nIndex);
37 #undef SetWindowLong
38 #define SetWindowLong SetWindowLongM
39 LONG SetWindowLongM(HWND hWnd, int nIndex, LONG dwNewLong);
40 #undef DefWindowProc
41 #define DefWindowProc DefWindowProcM
42 LRESULT DefWindowProcM(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
43 #undef CallWindowProc
44 #define CallWindowProc CallWindowProcM
45 LRESULT CallWindowProcM(WNDPROC lpPrevWndFunc, HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
46 #undef SendMessage
47 #define SendMessage SendMessageM
48 LRESULT SendMessageM(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
49 #undef DefDlgProc
50 #define DefDlgProc DefDlgProcM
51 LRESULT DefDlgProcM(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
52 #undef SendDlgItemMessage
53 #define SendDlgItemMessage SendDlgItemMessageM
54 LRESULT SendDlgItemMessageM(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam);
55 #undef SetWindowText
56 #define SetWindowText SetWindowTextM
57 BOOL SetWindowTextM(HWND hWnd, LPCSTR lpString);
58 #undef DragQueryFile
59 #define DragQueryFile DragQueryFileM
60 UINT DragQueryFileM(HDROP hDrop, UINT iFile, LPSTR lpszFile, UINT cch);
61 #undef GetCurrentDirectory
62 #define GetCurrentDirectory GetCurrentDirectoryM
63 DWORD GetCurrentDirectoryM(DWORD nBufferLength, LPSTR lpBuffer);
64 #undef SetCurrentDirectory
65 #define SetCurrentDirectory SetCurrentDirectoryM
66 BOOL SetCurrentDirectoryM(LPCSTR lpPathName);
67 #undef SetDllDirectory
68 #define SetDllDirectory SetDllDirectoryM
69 BOOL SetDllDirectoryM(LPCSTR lpPathName);
70 #undef GetTempPath
71 #define GetTempPath GetTempPathM
72 DWORD GetTempPathM(DWORD nBufferLength, LPSTR lpBuffer);
73 #undef GetFileAttributes
74 #define GetFileAttributes GetFileAttributesM
75 DWORD GetFileAttributesM(LPCSTR lpFileName);
76 #undef GetModuleFileName
77 #define GetModuleFileName GetModuleFileNameM
78 DWORD GetModuleFileNameM(HMODULE hModule, LPCH lpFilename, DWORD nSize);
79 #undef RegOpenKeyEx
80 #define RegOpenKeyEx RegOpenKeyExM
81 LSTATUS RegOpenKeyExM(HKEY hKey, LPCSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult);
82 #undef RegCreateKeyEx
83 #define RegCreateKeyEx RegCreateKeyExM
84 LSTATUS RegCreateKeyExM(HKEY hKey, LPCSTR lpSubKey, DWORD Reserved, LPSTR lpClass, DWORD dwOptions, REGSAM samDesired, CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes, PHKEY phkResult, LPDWORD lpdwDisposition);
85 #undef RegDeleteValue
86 #define RegDeleteValue RegDeleteValueM
87 LSTATUS RegDeleteValueM(HKEY hKey, LPCSTR lpValueName);
88 #undef RegQueryValueEx
89 #define RegQueryValueEx RegQueryValueExM
90 LSTATUS RegQueryValueExM(HKEY hKey, LPCSTR lpValueName, LPDWORD lpReserved, LPDWORD lpType, LPBYTE lpData, LPDWORD lpcbData);
91 #undef RegSetValueEx
92 #define RegSetValueEx RegSetValueExM
93 LSTATUS RegSetValueExM(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE* lpData, DWORD cbData);
94 #undef TextOut
95 #define TextOut TextOutM
96 BOOL TextOutM(HDC hdc, int x, int y, LPCSTR lpString, int c);
97 #undef GetTextExtentPoint32
98 #define GetTextExtentPoint32 GetTextExtentPoint32M
99 BOOL GetTextExtentPoint32M(HDC hdc, LPCSTR lpString, int c, LPSIZE psizl);
100 #undef PropertySheet
101 #define PropertySheet PropertySheetM
102 INT_PTR PropertySheetM(LPCPROPSHEETHEADERA v0);
103 #undef GetOpenFileName
104 #define GetOpenFileName GetOpenFileNameM
105 BOOL GetOpenFileNameM(LPOPENFILENAMEA v0);
106 #undef GetSaveFileName
107 #define GetSaveFileName GetSaveFileNameM
108 BOOL GetSaveFileNameM(LPOPENFILENAMEA v0);
109 #undef HtmlHelp
110 #define HtmlHelp HtmlHelpM
111 HWND HtmlHelpM(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD_PTR dwData);
112 #undef CreateProcess
113 #define CreateProcess CreateProcessM
114 BOOL CreateProcessM(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation);
115 #undef FindExecutable
116 #define FindExecutable FindExecutableM
117 HINSTANCE FindExecutableM(LPCSTR lpFile, LPCSTR lpDirectory, LPSTR lpResult);
118 #undef ShellExecute
119 #define ShellExecute ShellExecuteM
120 HINSTANCE ShellExecuteM(HWND hwnd, LPCSTR lpOperation, LPCSTR lpFile, LPCSTR lpParameters, LPCSTR lpDirectory, INT nShowCmd);
121 #undef SHBrowseForFolder
122 #define SHBrowseForFolder SHBrowseForFolderM
123 PIDLIST_ABSOLUTE SHBrowseForFolderM(LPBROWSEINFOA lpbi);
124 #undef SHGetPathFromIDList
125 #define SHGetPathFromIDList SHGetPathFromIDListM
126 BOOL SHGetPathFromIDListM(PCIDLIST_ABSOLUTE pidl, LPSTR pszPath);
127 #undef SHFileOperation
128 #define SHFileOperation SHFileOperationM
129 int SHFileOperationM(LPSHFILEOPSTRUCTA lpFileOp);
130 #undef AppendMenu
131 #define AppendMenu AppendMenuM
132 BOOL AppendMenuM(HMENU hMenu, UINT uFlags, UINT_PTR uIDNewItem, LPCSTR lpNewItem);
133 #undef GetMenuItemInfo
134 #define GetMenuItemInfo GetMenuItemInfoM
135 BOOL GetMenuItemInfoM(HMENU hmenu, UINT item, BOOL fByPosition, LPMENUITEMINFOA lpmii);
136 #undef CreateFontIndirect
137 #define CreateFontIndirect CreateFontIndirectM
138 HFONT CreateFontIndirectM(CONST LOGFONTA *lplf);
139 #undef ChooseFont
140 #define ChooseFont ChooseFontM
141 BOOL ChooseFontM(LPCHOOSEFONTA v0);
142 #undef DialogBoxParam
143 #define DialogBoxParam DialogBoxParamM
144 INT_PTR DialogBoxParamM(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam);
145 #undef CreateDialogParam
146 #define CreateDialogParam CreateDialogParamM
147 HWND CreateDialogParamM(HINSTANCE hInstance, LPCSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam);
148 #undef mkdir
149 #define mkdir _mkdirM
150 int mkdirM(const char * _Path);
151 #undef _mkdir
152 #define _mkdir _mkdirM
153 int _mkdirM(const char * _Path);
154 #undef rmdir
155 #define rmdir rmdirM
156 int rmdirM(const char * _Path);
157 #undef _rmdir
158 #define _rmdir _rmdirM
159 int _rmdirM(const char * _Path);
160 #undef _mbslen
161 #define _mbslen _mbslenM
162 size_t _mbslenM(const unsigned char * _Str);
163 #undef _mbschr
164 #define _mbschr _mbschrM
165 unsigned char * _mbschrM(const unsigned char * _Str, unsigned int _Ch);
166 #undef _mbsrchr
167 #define _mbsrchr _mbsrchrM
168 unsigned char * _mbsrchrM(const unsigned char * _Str, unsigned int _Ch);
169 #undef _mbsstr
170 #define _mbsstr _mbsstrM
171 unsigned char * _mbsstrM(const unsigned char * _Str, const unsigned char * _Substr);
172 #undef _mbscmp
173 #define _mbscmp _mbscmpM
174 int _mbscmpM(const unsigned char * _Str1, const unsigned char * _Str2);
175 #undef _mbsicmp
176 #define _mbsicmp _mbsicmpM
177 int _mbsicmpM(const unsigned char * _Str1, const unsigned char * _Str2);
178 #undef _mbsncmp
179 #define _mbsncmp _mbsncmpM
180 int _mbsncmpM(const unsigned char * _Str1, const unsigned char * _Str2, size_t _MaxCount);
181 #undef _mbslwr
182 #define _mbslwr _mbslwrM
183 unsigned char * _mbslwrM(unsigned char * _String);
184 #undef _mbsupr
185 #define _mbsupr _mbsuprM
186 unsigned char * _mbsuprM(unsigned char * _String);
187 #undef _mbsninc
188 #define _mbsninc _mbsnincM
189 unsigned char * _mbsnincM(const unsigned char * _Str, size_t _Count);
190
191 #undef CreateWindow
192 #define CreateWindow(lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam) CreateWindowEx(0L, lpClassName, lpWindowName, dwStyle, x, y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam)
193 #undef DialogBox
194 #define DialogBox(hInstance, lpTemplate, hWndParent, lpDialogFunc) DialogBoxParam(hInstance, lpTemplate, hWndParent, lpDialogFunc, 0L)
195
196 #endif
197
198 int MtoW(LPWSTR pDst, int size, LPCSTR pSrc, int count);
199 int WtoM(LPSTR pDst, int size, LPCWSTR pSrc, int count);
200 int WtoA(LPSTR pDst, int size, LPCWSTR pSrc, int count);
201 int TerminateStringM(LPSTR lpString, int size);
202 int TerminateStringW(LPWSTR lpString, int size);
203 int TerminateStringA(LPWSTR lpString, int size);
204 size_t GetMultiStringLengthM(LPCSTR lpString);
205 size_t GetMultiStringLengthW(LPCWSTR lpString);
206 size_t GetMultiStringLengthA(LPCWSTR lpString);
207 int MtoWMultiString(LPWSTR pDst, int size, LPCSTR pSrc);
208 int WtoMMultiString(LPSTR pDst, int size, LPCWSTR pSrc);
209 int WtoAMultiString(LPSTR pDst, int size, LPCWSTR pSrc);
210 char* AllocateStringM(int size);
211 wchar_t* AllocateStringW(int size);
212 char* AllocateStringA(int size);
213 wchar_t* DuplicateMtoW(LPCSTR lpString, int c);
214 wchar_t* DuplicateMtoWBuffer(LPCSTR lpString, int c, int size);
215 wchar_t* DuplicateMtoWMultiString(LPCSTR lpString);
216 wchar_t* DuplicateMtoWMultiStringBuffer(LPCSTR lpString, int size);
217 char* DuplicateWtoM(LPCWSTR lpString, int c);
218 char* DuplicateWtoA(LPCWSTR lpString, int c);
219 void FreeDuplicatedString(void* p);
220
221 #endif
222