OSDN Git Service

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