OSDN Git Service

Modify documents.
[ffftp/ffftp.git] / main.c
1 /*=============================================================================\r
2 *\r
3 *                                                                       FFFTP\r
4 *\r
5 ===============================================================================\r
6 / Copyright (C) 1997-2007 Sota. All rights reserved.\r
7 /\r
8 / Redistribution and use in source and binary forms, with or without \r
9 / modification, are permitted provided that the following conditions \r
10 / are met:\r
11 /\r
12 /  1. Redistributions of source code must retain the above copyright \r
13 /     notice, this list of conditions and the following disclaimer.\r
14 /  2. Redistributions in binary form must reproduce the above copyright \r
15 /     notice, this list of conditions and the following disclaimer in the \r
16 /     documentation and/or other materials provided with the distribution.\r
17 /\r
18 / THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR \r
19 / IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES \r
20 / OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. \r
21 / IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, \r
22 / INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, \r
23 / BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF \r
24 / USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON \r
25 / ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT \r
26 / (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF \r
27 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
28 /============================================================================*/\r
29 \r
30 #define  STRICT\r
31 // IPv6対応\r
32 #include <winsock2.h>\r
33 #include <windows.h>\r
34 #include <stdio.h>\r
35 #include <stdlib.h>\r
36 #include <string.h>\r
37 #include <mbstring.h>\r
38 #include <malloc.h>\r
39 #include <windowsx.h>\r
40 #include <commctrl.h>\r
41 #include <stdarg.h>\r
42 // IPv6対応\r
43 //#include <winsock.h>\r
44 \r
45 #include "common.h"\r
46 #include "resource.h"\r
47 #include "aes.h"\r
48 // 暗号化通信対応\r
49 #include "sha.h"\r
50 \r
51 #include <htmlhelp.h>\r
52 #include "helpid.h"\r
53 \r
54 // UTF-8対応\r
55 #undef __MBSWRAPPER_H__\r
56 #include "mbswrapper.h"\r
57 \r
58 \r
59 #define RESIZE_OFF              0               /* ウインドウの区切り位置変更していない */\r
60 #define RESIZE_ON               1               /* ウインドウの区切り位置変更中 */\r
61 #define RESIZE_PREPARE  2               /* ウインドウの区切り位置変更の準備 */\r
62 \r
63 #define RESIZE_HPOS             0               /* ローカル-ホスト間の区切り位置変更 */\r
64 #define RESIZE_VPOS             1               /* リスト-タスク間の区切り位置の変更 */\r
65 \r
66 \r
67 /*===== プロトタイプ =====*/\r
68 \r
69 static int InitApp(LPSTR lpszCmdLine, int cmdShow);\r
70 static int MakeAllWindows(int cmdShow);\r
71 static void DeleteAllObject(void);\r
72 static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);\r
73 static void StartupProc(char *Cmd);\r
74 static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc, int Max);\r
75 static int CheckIniFileName(char *Str, char *Ini);\r
76 static int CheckMasterPassword(char *Str, char *Ini);\r
77 static int GetTokenAfterOption(char *Str, char *Result, const char* Opt1, const char* Opt2 );\r
78 static char *GetToken(char *Str, char *Buf);\r
79 static void ExitProc(HWND hWnd);\r
80 static void ChangeDir(int Win, char *Path);\r
81 static void ResizeWindowProc(void);\r
82 static void CalcWinSize(void);\r
83 // static void AskWindowPos(HWND hWnd);\r
84 static void CheckResizeFrame(WPARAM Keys, int x, int y);\r
85 static void DispDirInfo(void);\r
86 static void DeleteAlltempFile(void);\r
87 // 64ビット対応\r
88 //static BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
89 static INT_PTR CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);\r
90 static int EnterMasterPasswordAndSet( int Res, HWND hWnd );\r
91 \r
92 /*===== ローカルなワーク =====*/\r
93 \r
94 static const char FtpClassStr[] = "FFFTPWin";\r
95 \r
96 static HINSTANCE hInstFtp;\r
97 static HWND hWndFtp = NULL;\r
98 static HWND hWndCurFocus = NULL;\r
99 \r
100 static HACCEL Accel;\r
101 static HBRUSH RootColorBrush = NULL;\r
102 \r
103 static int Resizing = RESIZE_OFF;\r
104 static int ResizePos;\r
105 static HCURSOR hCursor;\r
106 \r
107 int ClientWidth;\r
108 static int ClientHeight;\r
109 int SepaWidth;\r
110 int RemoteWidth;\r
111 int ListHeight;\r
112 \r
113 static TEMPFILELIST *TempFiles = NULL;\r
114 \r
115 static int SaveExit = YES;\r
116 static int AutoExit = NO;\r
117 \r
118 static char HelpPath[FMAX_PATH+1];\r
119 static char IniPath[FMAX_PATH+1];\r
120 static int ForceIni = NO;\r
121 \r
122 TRANSPACKET MainTransPkt;               /* ファイル転送用パケット */\r
123                                                                 /* これを使って転送を行うと、ツールバーの転送 */\r
124                                                                 /* 中止ボタンで中止できる */\r
125 \r
126 char TitleHostName[HOST_ADRS_LEN+1];\r
127 char FilterStr[FILTER_EXT_LEN+1] = { "*" };\r
128 \r
129 int CancelFlg;\r
130 \r
131 // 外部アプリケーションへドロップ後にローカル側のファイル一覧に作業フォルダが表示されるバグ対策\r
132 //static int SuppressRefresh = 0;\r
133 int SuppressRefresh = 0;\r
134 \r
135 static DWORD dwCookie;\r
136 \r
137 // 暗号化通信対応\r
138 static char SSLRootCAFilePath[FMAX_PATH+1];\r
139 // マルチコアCPUの特定環境下でファイル通信中にクラッシュするバグ対策\r
140 static DWORD MainThreadId;\r
141 // ポータブル版判定\r
142 static char PortableFilePath[FMAX_PATH+1];\r
143 int PortableVersion;\r
144 \r
145 \r
146 /*===== グローバルなワーク =====*/\r
147 \r
148 HWND hHelpWin = NULL;\r
149 \r
150 /* 設定値 */\r
151 int WinPosX = CW_USEDEFAULT;\r
152 int WinPosY = 0;\r
153 // 機能が増えたためサイズ変更\r
154 // VGAサイズに収まるようになっていたのをSVGAサイズに引き上げ\r
155 //int WinWidth = 630;\r
156 //int WinHeight = 393;\r
157 //int LocalWidth = 309;\r
158 //int TaskHeight = 50;\r
159 //int LocalTabWidth[4] = { 120, 90, 60, 37 };\r
160 //int RemoteTabWidth[6] = { 120, 90, 60, 37, 60, 60 };\r
161 int WinWidth = 790;\r
162 int WinHeight = 513;\r
163 int LocalWidth = 389;\r
164 int TaskHeight = 100;\r
165 int LocalTabWidth[4] = { 160, 110, 60, 37 };\r
166 int RemoteTabWidth[6] = { 160, 110, 60, 37, 60, 60 };\r
167 char UserMailAdrs[USER_MAIL_LEN+1] = { "who@example.com" };\r
168 char ViewerName[VIEWERS][FMAX_PATH+1] = { { "notepad" }, { "" }, { "" } };\r
169 HFONT ListFont = NULL;\r
170 LOGFONT ListLogFont;\r
171 int LocalFileSort = SORT_NAME;\r
172 int LocalDirSort = SORT_NAME;\r
173 int RemoteFileSort = SORT_NAME;\r
174 int RemoteDirSort = SORT_NAME;\r
175 int TransMode = TYPE_X;\r
176 int ConnectOnStart = YES;\r
177 int DebugConsole = NO;\r
178 int SaveWinPos = NO;\r
179 // アスキーモード判別の改良\r
180 //char AsciiExt[ASCII_EXT_LEN+1] = { "*.txt\0*.html\0*.htm\0*.cgi\0*.pl\0" };\r
181 char AsciiExt[ASCII_EXT_LEN+1] = { "*.txt\0*.html\0*.htm\0*.cgi\0*.pl\0*.js\0*.vbs\0*.css\0*.rss\0*.rdf\0*.xml\0*.xhtml\0*.xht\0*.shtml\0*.shtm\0*.sh\0*.py\0*.rb\0*.properties\0*.sql\0*.asp\0*.aspx\0*.php\0*.htaccess\0" };\r
182 int RecvMode = TRANS_DLG;\r
183 int SendMode = TRANS_DLG;\r
184 int MoveMode = MOVE_DLG;\r
185 int ListType = LVS_REPORT;\r
186 // LISTのキャッシュを無効にする(リモートのディレクトリの表示が更新されないバグ対策)\r
187 //int CacheEntry = 10;\r
188 int CacheEntry = -10;\r
189 int CacheSave = NO;\r
190 char DefaultLocalPath[FMAX_PATH+1] = { "" };\r
191 int SaveTimeStamp = YES;\r
192 int FindMode = 0;\r
193 int DotFile = YES;\r
194 int DclickOpen = YES;\r
195 int ConnectAndSet = YES;\r
196 SOUNDFILE Sound[SOUND_TYPES] = { { NO, "" }, { NO, "" }, { NO, "" } };\r
197 int FnameCnv = FNAME_NOCNV;\r
198 int TimeOut = 90;\r
199 int RmEOF = NO;\r
200 int RegType = REGTYPE_REG;\r
201 char FwallHost[HOST_ADRS_LEN+1] = { "" };\r
202 char FwallUser[USER_NAME_LEN+1] = { "" };\r
203 char FwallPass[PASSWORD_LEN+1] = { "" };\r
204 int FwallPort = PORT_NOR;\r
205 int FwallType = 1;\r
206 int FwallDefault = NO;\r
207 int FwallSecurity = SECURITY_AUTO;\r
208 int FwallResolv = NO;\r
209 int FwallLower = NO;\r
210 int FwallDelimiter = '@';\r
211 // ルータ対策\r
212 //int PasvDefault = NO;\r
213 int PasvDefault = YES;\r
214 char MirrorNoTrn[MIRROR_LEN+1] = { "*.bak\0" };\r
215 char MirrorNoDel[MIRROR_LEN+1] = { "" };\r
216 int MirrorFnameCnv = NO;\r
217 int SplitVertical = YES;\r
218 int RasClose = NO;\r
219 int RasCloseNotify = YES;\r
220 int FileHist = 5;\r
221 char DefAttrList[DEFATTRLIST_LEN+1] = { "" };\r
222 SIZE HostDlgSize = { -1, -1 };\r
223 SIZE BmarkDlgSize = { -1, -1 };\r
224 SIZE MirrorDlgSize = { -1, -1 };\r
225 int Sizing = SW_RESTORE;\r
226 int SortSave = NO;\r
227 char TmpPath[FMAX_PATH+1];\r
228 int QuickAnonymous = YES;\r
229 int PassToHist = YES;\r
230 int VaxSemicolon = NO;\r
231 int SendQuit = NO;\r
232 int NoRasControl = NO;\r
233 int SuppressSave = NO;\r
234 int DispIgnoreHide = NO;\r
235 int DispDrives = NO;\r
236 int MirUpDelNotify = YES; \r
237 int MirDownDelNotify = YES; \r
238 int FolderAttr = NO;\r
239 int FolderAttrNum = 777;\r
240 // 暗号化通信対応\r
241 BYTE CertificateCacheHash[MAX_CERT_CACHE_HASH][20];\r
242 BYTE SSLRootCAFileHash[20];\r
243 // ファイルアイコン表示対応\r
244 int DispFileIcon = NO;\r
245 // ディレクトリ自動作成\r
246 int MakeAllDir = YES;\r
247 \r
248 \r
249 \r
250 \r
251 \r
252 /*----- メインルーチン --------------------------------------------------------\r
253 *\r
254 *       Parameter\r
255 *               HINSTANCE hInstance : このアプリケーションのこのインスタンスのハンドル\r
256 *               HINSTANCE hPrevInstance : このアプリケーションの直前のインスタンスのハンドル\r
257 *               LPSTR lpszCmdLine : アプリケーションが起動したときのコマンドラインをさすロングポインタ\r
258 *               int cmdShow : 最初に表示するウインドウの形式。\r
259 *\r
260 *       Return Value\r
261 *               int 最後のメッセージのwParam\r
262 *----------------------------------------------------------------------------*/\r
263 \r
264 int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int cmdShow)\r
265 {\r
266     MSG Msg;\r
267         int Ret;\r
268         BOOL Sts;\r
269 \r
270         // プロセス保護\r
271 #ifdef ENABLE_PROCESS_PROTECTION\r
272         {\r
273                 DWORD ProtectLevel;\r
274                 char* pCommand;\r
275                 char Option[FMAX_PATH+1];\r
276                 ProtectLevel = PROCESS_PROTECTION_NONE;\r
277                 pCommand = lpszCmdLine;\r
278                 while(pCommand = GetToken(pCommand, Option))\r
279                 {\r
280                         if(strcmp(Option, "--protect") == 0)\r
281                         {\r
282                                 ProtectLevel = PROCESS_PROTECTION_DEFAULT;\r
283                                 break;\r
284                         }\r
285                         else if(strcmp(Option, "--protect-high") == 0)\r
286                         {\r
287                                 ProtectLevel = PROCESS_PROTECTION_HIGH;\r
288                                 break;\r
289                         }\r
290                         else if(strcmp(Option, "--protect-medium") == 0)\r
291                         {\r
292                                 ProtectLevel = PROCESS_PROTECTION_MEDIUM;\r
293                                 break;\r
294                         }\r
295                         else if(strcmp(Option, "--protect-low") == 0)\r
296                         {\r
297                                 ProtectLevel = PROCESS_PROTECTION_LOW;\r
298                                 break;\r
299                         }\r
300                 }\r
301                 if(ProtectLevel != PROCESS_PROTECTION_NONE)\r
302                 {\r
303                         SetProcessProtectionLevel(ProtectLevel);\r
304                         if(!InitializeLoadLibraryHook())\r
305                         {\r
306                                 MessageBox(NULL, MSGJPN321, "FFFTP", MB_OK | MB_ICONERROR);\r
307                                 return 0;\r
308                         }\r
309 #ifndef _DEBUG\r
310                         if(IsDebuggerPresent())\r
311                         {\r
312                                 MessageBox(NULL, MSGJPN322, "FFFTP", MB_OK | MB_ICONERROR);\r
313                                 return 0;\r
314                         }\r
315 #endif\r
316                         if(!UnloadUntrustedModule())\r
317                         {\r
318                                 MessageBox(NULL, MSGJPN323, "FFFTP", MB_OK | MB_ICONERROR);\r
319                                 return 0;\r
320                         }\r
321 #ifndef _DEBUG\r
322                         if(RestartProtectedProcess(" --restart"))\r
323                                 return 0;\r
324 #endif\r
325                         if(!EnableLoadLibraryHook(TRUE))\r
326                         {\r
327                                 MessageBox(NULL, MSGJPN324, "FFFTP", MB_OK | MB_ICONERROR);\r
328                                 return 0;\r
329                         }\r
330                 }\r
331                 else\r
332                         InitializeLoadLibraryHook();\r
333         }\r
334 #endif\r
335 \r
336         // マルチコアCPUの特定環境下でファイル通信中にクラッシュするバグ対策\r
337 #ifdef DISABLE_MULTI_CPUS\r
338         SetProcessAffinityMask(GetCurrentProcess(), 1);\r
339 #endif\r
340         MainThreadId = GetCurrentThreadId();\r
341 \r
342         // yutaka\r
343         if(OleInitialize(NULL) != S_OK){\r
344                 MessageBox(NULL, MSGJPN298, "FFFTP", MB_OK | MB_ICONERROR);\r
345                 return 0;\r
346         }\r
347 \r
348         InitCommonControls();\r
349 \r
350         // FTPS対応\r
351 #ifdef USE_OPENSSL\r
352         LoadOpenSSL();\r
353 #endif\r
354 \r
355         // SFTP対応\r
356         LoadPuTTY();\r
357 \r
358         Ret = FALSE;\r
359         hWndFtp = NULL;\r
360         hInstFtp = hInstance;\r
361         if(InitApp(lpszCmdLine, cmdShow) == FFFTP_SUCCESS)\r
362         {\r
363                 for(;;)\r
364                 {\r
365                         Sts = GetMessage(&Msg, NULL, 0, 0);\r
366                         if((Sts == 0) || (Sts == -1))\r
367                                 break;\r
368 \r
369                         // 64ビット対応\r
370 //                      if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD)&Msg))\r
371                         if(!HtmlHelp(NULL, NULL, HH_PRETRANSLATEMESSAGE, (DWORD_PTR)&Msg))\r
372                         { \r
373                                 /* ディレクトリ名の表示コンボボックスでBSやRETが効くように */\r
374                                 /* コンボボックス内ではアクセラレータを無効にする */\r
375                                 if((Msg.hwnd == GetLocalHistEditHwnd()) ||\r
376                                    (Msg.hwnd == GetRemoteHistEditHwnd()) ||\r
377                                    ((hHelpWin != NULL) && (GetAncestor(Msg.hwnd, GA_ROOT) == hHelpWin)) ||\r
378                                    GetHideUI() == YES ||\r
379                                    (TranslateAccelerator(hWndFtp, Accel, &Msg) == 0))\r
380                                 {\r
381                                         TranslateMessage(&Msg);\r
382                                         DispatchMessage(&Msg);\r
383                                 }\r
384                         }\r
385                 }\r
386                 Ret = Msg.wParam;\r
387         }\r
388     UnregisterClass(FtpClassStr, hInstFtp);\r
389         // FTPS対応\r
390 #ifdef USE_OPENSSL\r
391         FreeOpenSSL();\r
392 #endif\r
393         // SFTP対応\r
394         FreePuTTY();\r
395         OleUninitialize();\r
396         return(Ret);\r
397 }\r
398 \r
399 \r
400 /*----- アプリケーションの初期設定 --------------------------------------------\r
401 *\r
402 *       Parameter\r
403 *               HINSTANCE hInstance : このアプリケーションのこのインスタンスのハンドル\r
404 *               HINSTANCE hPrevInstance : このアプリケーションの直前のインスタンスのハンドル\r
405 *               LPSTR lpszCmdLine : アプリケーションが起動したときのコマンドラインをさすロングポインタ\r
406 *               int cmdShow : 最初に表示するウインドウの形式。\r
407 *\r
408 *       Return Value\r
409 *               int ステータス\r
410 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
411 *----------------------------------------------------------------------------*/\r
412 \r
413 static int InitApp(LPSTR lpszCmdLine, int cmdShow)\r
414 {\r
415         int sts;\r
416         int Err;\r
417         WSADATA WSAData;\r
418         char PwdBuf[FMAX_PATH+1];\r
419         int useDefautPassword = 0; /* 警告文表示用 */\r
420         int masterpass;\r
421         // ポータブル版判定\r
422         int ImportPortable;\r
423 \r
424         sts = FFFTP_FAIL;\r
425 \r
426         aes_init();\r
427         srand(GetTickCount());\r
428         \r
429         // 64ビット対応\r
430 //      HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD)&dwCookie);\r
431         HtmlHelp(NULL, NULL, HH_INITIALIZE, (DWORD_PTR)&dwCookie);\r
432 \r
433         SaveUpdateBellInfo();\r
434 \r
435         if((Err = WSAStartup((WORD)0x0202, &WSAData)) != 0)\r
436                 MessageBox(NULL, ReturnWSError(Err), "FFFTP - Startup", MB_OK);\r
437         else\r
438         {\r
439                 Accel = LoadAccelerators(hInstFtp, MAKEINTRESOURCE(ffftp_accel));\r
440 \r
441                 // 環境依存の不具合対策\r
442 //              GetTempPath(FMAX_PATH, TmpPath);\r
443                 GetAppTempPath(TmpPath);\r
444                 _mkdir(TmpPath);\r
445                 SetYenTail(TmpPath);\r
446 \r
447                 GetModuleFileName(NULL, HelpPath, FMAX_PATH);\r
448                 strcpy(GetFileName(HelpPath), "ffftp.chm");\r
449 \r
450                 if(CheckIniFileName(lpszCmdLine, IniPath) == 0)\r
451                 {\r
452                         GetModuleFileName(NULL, IniPath, FMAX_PATH);\r
453                         strcpy(GetFileName(IniPath), "ffftp.ini");\r
454                 }\r
455                 else\r
456                 {\r
457                         ForceIni = YES;\r
458                         RegType = REGTYPE_INI;\r
459                 }\r
460                 // ポータブル版判定\r
461                 GetModuleFileName(NULL, PortableFilePath, FMAX_PATH);\r
462                 strcpy(GetFileName(PortableFilePath), "portable");\r
463                 CheckPortableVersion();\r
464                 ImportPortable = NO;\r
465                 if(PortableVersion == YES)\r
466                 {\r
467                         ForceIni = YES;\r
468                         RegType = REGTYPE_INI;\r
469                         if(IsRegAvailable() == YES && IsIniAvailable() == NO)\r
470                         {\r
471                                 if(DialogBox(GetFtpInst(), MAKEINTRESOURCE(ini_from_reg_dlg), GetMainHwnd(), ExeEscDialogProc) == YES)\r
472                                 {\r
473                                         ImportPortable = YES;\r
474                                         ForceIni = NO;\r
475                                         RegType = REGTYPE_REG;\r
476                                 }\r
477                         }\r
478                 }\r
479 \r
480 //              AllocConsole();\r
481 \r
482                 /* 2010.02.01 genta マスターパスワードを入力させる\r
483                   -z オプションがあるときは最初だけスキップ\r
484                   -z オプションがないときは,デフォルトパスワードをまず試す\r
485                   LoadRegistry()する\r
486                   パスワードが不一致なら再入力するか尋ねる.\r
487                   (破損していた場合はさせない)\r
488                 */\r
489                 if( CheckMasterPassword(lpszCmdLine, PwdBuf))\r
490                 {\r
491                         SetMasterPassword( PwdBuf );\r
492                         useDefautPassword = 0;\r
493                 }\r
494                 else {\r
495                         /* パスワード指定無し */\r
496                         SetMasterPassword( NULL );\r
497                         /* この場では表示できないのでフラグだけ立てておく*/\r
498                         useDefautPassword = 2;\r
499                 }\r
500 \r
501                 /* パスワードチェックのみ実施 */\r
502                 masterpass = 1;\r
503                 while( ValidateMasterPassword() == YES &&\r
504                                 GetMasterPasswordStatus() == PASSWORD_UNMATCH ){\r
505                         \r
506                         if( useDefautPassword != 2 ){\r
507                                 /* 再トライするか確認 */\r
508                                 if( MessageBox(NULL, MSGJPN304, "FFFTP", MB_YESNO | MB_ICONEXCLAMATION) == IDNO ){\r
509                                         useDefautPassword = 0; /* 不一致なので,もはやデフォルトかどうかは分からない */\r
510                                         break;\r
511                                 }\r
512                         }\r
513                         \r
514                         /* 再入力させる*/\r
515                         masterpass = EnterMasterPasswordAndSet(masterpasswd_dlg, NULL);\r
516                         if( masterpass == 2 ){\r
517                                 useDefautPassword = 1;\r
518                         }\r
519                         else if( masterpass == 0 ){\r
520                                 SaveExit = NO;\r
521                                 break;\r
522                         }\r
523                         else {\r
524                                 useDefautPassword = 0;\r
525                         }\r
526                 }\r
527                 \r
528                 if(masterpass != 0)\r
529                 {\r
530                         LoadRegistry();\r
531 \r
532                         // ポータブル版判定\r
533                         if(ImportPortable == YES)\r
534                         {\r
535                                 ForceIni = YES;\r
536                                 RegType = REGTYPE_INI;\r
537                         }\r
538 \r
539                         // 暗号化通信対応\r
540                         SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);\r
541                         SetSSLConfirmCallback(SSLConfirmCallback);\r
542                         GetModuleFileName(NULL, SSLRootCAFilePath, FMAX_PATH);\r
543                         strcpy(GetFileName(SSLRootCAFilePath), "ssl.pem");\r
544                         LoadSSLRootCAFile();\r
545 \r
546                         LoadJre();\r
547                         if(NoRasControl == NO)\r
548                                 LoadRasLib();\r
549                         LoadKernelLib();\r
550 \r
551                         //タイマの精度を改善\r
552                         timeBeginPeriod(1);\r
553 \r
554                         CountPrevFfftpWindows();\r
555 \r
556                         if(MakeAllWindows(cmdShow) == FFFTP_SUCCESS)\r
557                         {\r
558                                 hWndCurFocus = GetLocalHwnd();\r
559 \r
560                                 if(strlen(DefaultLocalPath) > 0)\r
561                                         SetCurrentDirectory(DefaultLocalPath);\r
562 \r
563                                 SetSortTypeImm(LocalFileSort, LocalDirSort, RemoteFileSort, RemoteDirSort);\r
564                                 SetTransferTypeImm(TransMode);\r
565                                 DispTransferType();\r
566                                 SetHostKanaCnvImm(YES);\r
567                                 SetHostKanjiCodeImm(KANJI_NOCNV);\r
568                                 // 本当はローカルのデフォルトをUTF-8にしたいが旧バージョンとの互換性のためShift_JISに設定\r
569 //                              SetLocalKanjiCodeImm(KANJI_UTF8N);\r
570                                 SetLocalKanjiCodeImm(KANJI_SJIS);\r
571                                 DispListType();\r
572                                 DispDotFileMode();\r
573                                 DispSyncMoveMode();\r
574 \r
575                                 MakeCacheBuf(CacheEntry);\r
576                                 if(CacheSave == YES)\r
577                                         LoadCache();\r
578 \r
579                                 if(MakeTransferThread() == FFFTP_SUCCESS)\r
580                                 {\r
581                                         DoPrintf("DEBUG MESSAGE ON ! ##");\r
582 \r
583                                         DispWindowTitle();\r
584                                         // SourceForge.JPによるフォーク\r
585 //                                      SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.");\r
586                                         SetTaskMsg("FFFTP Ver." VER_STR " Copyright(C) 1997-2010 Sota & cooperators.\r\nCopyright (C) 2011-2012 FFFTP Project (Hiromichi Matsushima, Suguru Kawamoto, IWAMOTO Kouichi, vitamin0x, unarist, Asami, fortran90, tomo1192, Yuji Tanaka, Moriguchi Hirokazu).");\r
587 \r
588                                         if(ForceIni)\r
589                                                 SetTaskMsg("%s%s", MSGJPN283, IniPath);\r
590 \r
591                                         if(IsFolderExist(TmpPath) == NO)\r
592                                         {\r
593                                                 SetTaskMsg(MSGJPN152, TmpPath);\r
594                                                 GetTempPath(FMAX_PATH, TmpPath);\r
595                                                 SetTaskMsg(MSGJPN153, TmpPath);\r
596                                         }\r
597 \r
598                                         DoPrintf("Tmp =%s", TmpPath);\r
599                                         DoPrintf("Help=%s", HelpPath);\r
600 \r
601                                         DragAcceptFiles(GetRemoteHwnd(), TRUE);\r
602                                         DragAcceptFiles(GetLocalHwnd(), TRUE);\r
603 \r
604                                         SetAllHistoryToMenu();\r
605                                         GetLocalDirForWnd();\r
606                                         MakeButtonsFocus();\r
607                                         DispTransferFiles();\r
608 \r
609                                         StartupProc(lpszCmdLine);\r
610                                         sts = FFFTP_SUCCESS;\r
611 \r
612                                         /* セキュリティ警告文の表示 */\r
613                                         if( useDefautPassword ){\r
614                                                 SetTaskMsg(MSGJPN300);\r
615                                         }\r
616                                         \r
617                                         /* パスワード不一致警告文の表示 */\r
618                                         switch( GetMasterPasswordStatus() ){\r
619                                         case PASSWORD_UNMATCH:\r
620                                                 SetTaskMsg(MSGJPN301);\r
621                                                 break;\r
622                                         case BAD_PASSWORD_HASH:\r
623                                                 SetTaskMsg(MSGJPN302);\r
624                                                 break;\r
625                                         default:\r
626                                                 break;\r
627                                         }\r
628                                 }\r
629                         }\r
630                 }\r
631         }\r
632 \r
633         // 暗号化通信対応\r
634 #ifdef USE_OPENSSL\r
635         if(IsOpenSSLLoaded())\r
636                 SetTaskMsg(MSGJPN318);\r
637         else\r
638                 SetTaskMsg(MSGJPN319);\r
639 #endif\r
640 \r
641         if(sts == FFFTP_FAIL)\r
642                 DeleteAllObject();\r
643 \r
644         return(sts);\r
645 }\r
646 \r
647 \r
648 /*----- ウインドウを作成する --------------------------------------------------\r
649 *\r
650 *       Parameter\r
651 *               int cmdShow : 最初に表示するウインドウの形式。\r
652 *\r
653 *       Return Value\r
654 *               int ステータス\r
655 *                       FFFTP_SUCCESS/FFFTP_FAIL\r
656 *----------------------------------------------------------------------------*/\r
657 \r
658 static int MakeAllWindows(int cmdShow)\r
659 {\r
660         RECT Rect1;\r
661         RECT Rect2;\r
662         WNDCLASSEX wClass;\r
663         int Sts;\r
664         int StsTask;\r
665         int StsSbar;\r
666         int StsTbar;\r
667         int StsList;\r
668         int StsLvtips;\r
669         int StsSocket;\r
670 \r
671         /*===== メインウインドウ =====*/\r
672 \r
673         RootColorBrush = CreateSolidBrush(GetSysColor(COLOR_3DFACE));\r
674 \r
675         wClass.cbSize = sizeof(WNDCLASSEX);\r
676         wClass.style         = 0;\r
677         wClass.lpfnWndProc   = FtpWndProc;\r
678         wClass.cbClsExtra    = 0;\r
679         wClass.cbWndExtra    = 0;\r
680         wClass.hInstance     = hInstFtp;\r
681         wClass.hIcon         = LoadIcon(hInstFtp, MAKEINTRESOURCE(ffftp));\r
682         wClass.hCursor       = NULL;\r
683         wClass.hbrBackground = RootColorBrush;\r
684         wClass.lpszMenuName  = (LPSTR)MAKEINTRESOURCE(main_menu);\r
685         wClass.lpszClassName = FtpClassStr;\r
686         wClass.hIconSm       = NULL;\r
687         RegisterClassEx(&wClass);\r
688 \r
689         if(SaveWinPos == NO)\r
690         {\r
691                 WinPosX = CW_USEDEFAULT;\r
692                 WinPosY = 0;\r
693         }\r
694         hWndFtp = CreateWindow(FtpClassStr, "FFFTP",\r
695                                 WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,\r
696                                 WinPosX, WinPosY, WinWidth, WinHeight,\r
697                                 HWND_DESKTOP, 0, hInstFtp, NULL);\r
698 \r
699         if(hWndFtp != NULL)\r
700         {\r
701                 SystemParametersInfo(SPI_GETWORKAREA, 0, &Rect1, 0);\r
702                 GetWindowRect(hWndFtp, &Rect2);\r
703                 if(Rect2.bottom > Rect1.bottom)\r
704                 {\r
705                         Rect2.top = max1(0, Rect2.top - (Rect2.bottom - Rect1.bottom));\r
706                         MoveWindow(hWndFtp, Rect2.left, Rect2.top, WinWidth, WinHeight, FALSE);\r
707                 }\r
708 \r
709                 /*===== ステイタスバー =====*/\r
710 \r
711                 StsSbar = MakeStatusBarWindow(hWndFtp, hInstFtp);\r
712 \r
713                 CalcWinSize();\r
714 \r
715                 /*===== ツールバー =====*/\r
716 \r
717                 StsTbar = MakeToolBarWindow(hWndFtp, hInstFtp);\r
718 \r
719                 /*===== ファイルリストウインドウ =====*/\r
720 \r
721                 StsList = MakeListWin(hWndFtp, hInstFtp);\r
722 \r
723                 /*==== タスクウインドウ ====*/\r
724 \r
725                 StsTask = MakeTaskWindow(hWndFtp, hInstFtp);\r
726 \r
727                 if((cmdShow != SW_MINIMIZE) && (cmdShow != SW_SHOWMINIMIZED) && (cmdShow != SW_SHOWMINNOACTIVE) &&\r
728                    (Sizing == SW_MAXIMIZE))\r
729                         cmdShow = SW_MAXIMIZE;\r
730 \r
731                 ShowWindow(hWndFtp, cmdShow);\r
732 \r
733                 /*==== ソケットウインドウ ====*/\r
734 \r
735                 StsSocket = MakeSocketWin(hWndFtp, hInstFtp);\r
736 \r
737                 StsLvtips = InitListViewTips(hWndFtp, hInstFtp);\r
738         }\r
739 \r
740         Sts = FFFTP_SUCCESS;\r
741         if((hWndFtp == NULL) ||\r
742            (StsTbar == FFFTP_FAIL) ||\r
743            (StsList == FFFTP_FAIL) ||\r
744            (StsSbar == FFFTP_FAIL) ||\r
745            (StsTask == FFFTP_FAIL) ||\r
746            (StsLvtips == FFFTP_FAIL) ||\r
747            (StsSocket == FFFTP_FAIL))\r
748         {\r
749                 Sts = FFFTP_FAIL;\r
750         }\r
751 \r
752         if(Sts == FFFTP_SUCCESS)\r
753                 SetListViewType();\r
754 \r
755         return(Sts);\r
756 }\r
757 \r
758 \r
759 /*----- ウインドウのタイトルを表示する ----------------------------------------\r
760 *\r
761 *       Parameter\r
762 *               なし\r
763 *\r
764 *       Return Value\r
765 *               なし\r
766 *----------------------------------------------------------------------------*/\r
767 \r
768 void DispWindowTitle(void)\r
769 {\r
770         char Tmp[HOST_ADRS_LEN+FILTER_EXT_LEN+20];\r
771 \r
772         if(AskConnecting() == YES)\r
773                 sprintf(Tmp, "%s (%s) - FFFTP", TitleHostName, FilterStr);\r
774         else\r
775                 sprintf(Tmp, "FFFTP (%s)", FilterStr);\r
776 \r
777         SetWindowText(GetMainHwnd(), Tmp);\r
778         return;\r
779 }\r
780 \r
781 \r
782 /*----- 全てのオブジェクトを削除 ----------------------------------------------\r
783 *\r
784 *       Parameter\r
785 *               なし\r
786 *\r
787 *       Return Value\r
788 *               なし\r
789 *----------------------------------------------------------------------------*/\r
790 \r
791 static void DeleteAllObject(void)\r
792 {\r
793         DeleteCacheBuf();\r
794 \r
795 //move to WM_DESTROY\r
796         WSACleanup();\r
797 \r
798 //test システム任せ\r
799 //      if(ListFont != NULL)\r
800 //              DeleteObject(ListFont);\r
801 //      if(RootColorBrush != NULL)\r
802 //              DeleteObject(RootColorBrush);\r
803 \r
804 //test システム任せ\r
805 //      DeleteListViewTips();\r
806 //      DeleteListWin();\r
807 //      DeleteStatusBarWindow();\r
808 //      DeleteTaskWindow();\r
809 //      DeleteToolBarWindow();\r
810 //      DeleteSocketWin();\r
811 \r
812 //move to WM_DESTROY\r
813         if(hWndFtp != NULL)\r
814                 DestroyWindow(hWndFtp);\r
815 \r
816         ReleaseJre();\r
817         ReleaseRasLib();\r
818         ReleaseKernelLib();\r
819 \r
820         return;\r
821 }\r
822 \r
823 \r
824 /*----- メインウインドウのウインドウハンドルを返す ----------------------------\r
825 *\r
826 *       Parameter\r
827 *               なし\r
828 *\r
829 *       Return Value\r
830 *               HWND ウインドウハンドル\r
831 *----------------------------------------------------------------------------*/\r
832 \r
833 HWND GetMainHwnd(void)\r
834 {\r
835         return(hWndFtp);\r
836 }\r
837 \r
838 \r
839 /*----- 現在フォーカスがあるウインドウのウインドウハンドルを返す --------------\r
840 *\r
841 *       Parameter\r
842 *               なし\r
843 *\r
844 *       Return Value\r
845 *               HWND ウインドウハンドル\r
846 *----------------------------------------------------------------------------*/\r
847 \r
848 HWND GetFocusHwnd(void)\r
849 {\r
850         return(hWndCurFocus);\r
851 }\r
852 \r
853 \r
854 /*----- 現在フォーカスがあるウインドウのをセットする --------------------------\r
855 *\r
856 *       Parameter\r
857 *               HWND hWnd : ウインドウハンドル\r
858 *\r
859 *       Return Value\r
860 *               なし\r
861 *----------------------------------------------------------------------------*/\r
862 \r
863 void SetFocusHwnd(HWND hWnd)\r
864 {\r
865         hWndCurFocus = hWnd;\r
866         return;\r
867 }\r
868 \r
869 \r
870 /*----- プログラムのインスタンスを返す ----------------------------------------\r
871 *\r
872 *       Parameter\r
873 *               なし\r
874 *\r
875 *       Return Value\r
876 *               HINSTANCE インスタンス\r
877 *----------------------------------------------------------------------------*/\r
878 \r
879 HINSTANCE GetFtpInst(void)\r
880 {\r
881         return(hInstFtp);\r
882 }\r
883 \r
884 \r
885 /*----- メインウインドウのメッセージ処理 --------------------------------------\r
886 *\r
887 *       Parameter\r
888 *               HWND hWnd : ウインドウハンドル\r
889 *               UINT message  : メッセージ番号\r
890 *               WPARAM wParam : メッセージの WPARAM 引数\r
891 *               LPARAM lParam : メッセージの LPARAM 引数\r
892 *\r
893 *       Return Value\r
894 *               メッセージに対応する戻り値\r
895 *----------------------------------------------------------------------------*/\r
896 \r
897 static LRESULT CALLBACK FtpWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)\r
898 {\r
899         PAINTSTRUCT ps;\r
900         LPTOOLTIPTEXT lpttt;\r
901         // UTF-8対応\r
902         LPTOOLTIPTEXTW wlpttt;\r
903         RECT Rect;\r
904 \r
905         int TmpTransType;\r
906 \r
907         switch (message)\r
908         {\r
909                 // 自動切断対策\r
910                 case WM_TIMER :\r
911                         if(wParam == 1)\r
912                                 NoopProc();\r
913                         break;\r
914 \r
915                 case WM_COMMAND :\r
916                         // 同時接続対応\r
917                         // 中断後に受信バッファに応答が残っていると次のコマンドの応答が正しく処理できない\r
918                         if(CancelFlg == YES)\r
919                                 RemoveReceivedData(AskCmdCtrlSkt());\r
920                         switch(LOWORD(wParam))\r
921                         {\r
922                                 case MENU_CONNECT :\r
923                                         // 自動切断対策\r
924                                         KillTimer(hWnd, 1);\r
925                                         ConnectProc(DLG_TYPE_CON, -1);\r
926                                         // 自動切断対策\r
927                                         if(AskNoopInterval() > 0)\r
928                                                 SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
929                                         break;\r
930 \r
931                                 case MENU_CONNECT_NUM :\r
932                                         // 自動切断対策\r
933                                         KillTimer(hWnd, 1);\r
934                                         ConnectProc(DLG_TYPE_CON, (int)lParam);\r
935                                         // 自動切断対策\r
936                                         if(AskNoopInterval() > 0)\r
937                                                 SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
938                                         if(AskConnecting() == YES)\r
939                                         {\r
940                                                 if(HIWORD(wParam) & OPT_MIRROR)\r
941                                                 {\r
942                                                         if(HIWORD(wParam) & OPT_FORCE)\r
943                                                                 MirrorUploadProc(NO);\r
944                                                         else\r
945                                                                 MirrorUploadProc(YES);\r
946                                                 }\r
947                                                 else if(HIWORD(wParam) & OPT_MIRRORDOWN)\r
948                                                 {\r
949                                                         if(HIWORD(wParam) & OPT_FORCE)\r
950                                                                 MirrorDownloadProc(NO);\r
951                                                         else\r
952                                                                 MirrorDownloadProc(YES);\r
953                                                 }\r
954                                         }\r
955                                         break;\r
956 \r
957                                 case MENU_SET_CONNECT :\r
958                                         // 自動切断対策\r
959                                         KillTimer(hWnd, 1);\r
960                                         ConnectProc(DLG_TYPE_SET, -1);\r
961                                         // 自動切断対策\r
962                                         if(AskNoopInterval() > 0)\r
963                                                 SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
964                                         break;\r
965 \r
966                                 case MENU_QUICK :\r
967                                         // 自動切断対策\r
968                                         KillTimer(hWnd, 1);\r
969                                         QuickConnectProc();\r
970                                         // 自動切断対策\r
971                                         if(AskNoopInterval() > 0)\r
972                                                 SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
973                                         break;\r
974 \r
975                                 case MENU_DISCONNECT :\r
976                                         if(AskTryingConnect() == YES)\r
977                                                 CancelFlg = YES;\r
978                                         else if(AskConnecting() == YES)\r
979                                         {\r
980                                                 SaveBookMark();\r
981                                                 SaveCurrentSetToHost();\r
982                                                 DisconnectProc();\r
983                                         }\r
984                                         break;\r
985 \r
986                                 case MENU_HIST_1 :\r
987                                 case MENU_HIST_2 :\r
988                                 case MENU_HIST_3 :\r
989                                 case MENU_HIST_4 :\r
990                                 case MENU_HIST_5 :\r
991                                 case MENU_HIST_6 :\r
992                                 case MENU_HIST_7 :\r
993                                 case MENU_HIST_8 :\r
994                                 case MENU_HIST_9 :\r
995                                 case MENU_HIST_10 :\r
996                                 case MENU_HIST_11 :\r
997                                 case MENU_HIST_12 :\r
998                                 case MENU_HIST_13 :\r
999                                 case MENU_HIST_14 :\r
1000                                 case MENU_HIST_15 :\r
1001                                 case MENU_HIST_16 :\r
1002                                 case MENU_HIST_17 :\r
1003                                 case MENU_HIST_18 :\r
1004                                 case MENU_HIST_19 :\r
1005                                 case MENU_HIST_20 :\r
1006                                         // 自動切断対策\r
1007                                         KillTimer(hWnd, 1);\r
1008                                         HistoryConnectProc(LOWORD(wParam));\r
1009                                         // 自動切断対策\r
1010                                         if(AskNoopInterval() > 0)\r
1011                                                 SetTimer(hWnd, 1, AskNoopInterval() * 1000, NULL);\r
1012                                         break;\r
1013 \r
1014                                 case MENU_UPDIR :\r
1015                                         if(hWndCurFocus == GetLocalHwnd())\r
1016                                                 PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(MENU_LOCAL_UPDIR, 0), 0);\r
1017                                         else\r
1018                                                 PostMessage(hWnd, WM_COMMAND, MAKEWPARAM(MENU_REMOTE_UPDIR, 0), 0);\r
1019                                         break;\r
1020 \r
1021                                 case MENU_DCLICK :\r
1022                                         if(hWndCurFocus == GetLocalHwnd())\r
1023                                                 // ローカルフォルダを開く\r
1024 //                                              DoubleClickProc(WIN_LOCAL, YES, -1);\r
1025                                                 DoubleClickProc(WIN_LOCAL, NO, -1);\r
1026                                         else\r
1027                                         {\r
1028                                                 SuppressRefresh = 1;\r
1029                                                 // ローカルフォルダを開く\r
1030 //                                              DoubleClickProc(WIN_REMOTE, YES, -1);\r
1031                                                 DoubleClickProc(WIN_REMOTE, NO, -1);\r
1032                                                 SuppressRefresh = 0;\r
1033                                         }\r
1034                                         break;\r
1035 \r
1036                                 // ローカルフォルダを開く\r
1037                                 case MENU_OPEN :\r
1038                                         if(hWndCurFocus == GetLocalHwnd())\r
1039                                                 DoubleClickProc(WIN_LOCAL, YES, -1);\r
1040                                         else\r
1041                                         {\r
1042                                                 SuppressRefresh = 1;\r
1043                                                 DoubleClickProc(WIN_REMOTE, YES, -1);\r
1044                                                 SuppressRefresh = 0;\r
1045                                         }\r
1046                                         break;\r
1047 \r
1048                                 case MENU_OPEN1 :\r
1049                                         if(hWndCurFocus == GetLocalHwnd())\r
1050                                                 DoubleClickProc(WIN_LOCAL, YES, 0);\r
1051                                         else\r
1052                                         {\r
1053                                                 SuppressRefresh = 1;\r
1054                                                 DoubleClickProc(WIN_REMOTE, YES, 0);\r
1055                                                 SuppressRefresh = 0;\r
1056                                         }\r
1057                                         break;\r
1058 \r
1059                                 case MENU_OPEN2 :\r
1060                                         if(hWndCurFocus == GetLocalHwnd())\r
1061                                                 DoubleClickProc(WIN_LOCAL, YES, 1);\r
1062                                         else\r
1063                                         {\r
1064                                                 SuppressRefresh = 1;\r
1065                                                 DoubleClickProc(WIN_REMOTE, YES, 1);\r
1066                                                 SuppressRefresh = 0;\r
1067                                         }\r
1068                                         break;\r
1069 \r
1070                                 case MENU_OPEN3 :\r
1071                                         if(hWndCurFocus == GetLocalHwnd())\r
1072                                                 DoubleClickProc(WIN_LOCAL, YES, 2);\r
1073                                         else\r
1074                                         {\r
1075                                                 SuppressRefresh = 1;\r
1076                                                 DoubleClickProc(WIN_REMOTE, YES, 2);\r
1077                                                 SuppressRefresh = 0;\r
1078                                         }\r
1079                                         break;\r
1080 \r
1081                                 case MENU_REMOTE_UPDIR :\r
1082                                         // デッドロック対策\r
1083                                         if(AskUserOpeDisabled() == YES)\r
1084                                                 break;\r
1085                                         SuppressRefresh = 1;\r
1086                                         SetCurrentDirAsDirHist();\r
1087                                         ChangeDir(WIN_REMOTE, "..");\r
1088                                         SuppressRefresh = 0;\r
1089                                         break;\r
1090 \r
1091                                 case MENU_LOCAL_UPDIR :\r
1092                                         // デッドロック対策\r
1093                                         if(AskUserOpeDisabled() == YES)\r
1094                                                 break;\r
1095                                         SetCurrentDirAsDirHist();\r
1096                                         ChangeDir(WIN_LOCAL, "..");\r
1097                                         break;\r
1098 \r
1099                                 case MENU_REMOTE_CHDIR :\r
1100                                         SuppressRefresh = 1;\r
1101                                         SetCurrentDirAsDirHist();\r
1102                                         ChangeDirDirectProc(WIN_REMOTE);\r
1103                                         SuppressRefresh = 0;\r
1104                                         break;\r
1105 \r
1106                                 case MENU_LOCAL_CHDIR :\r
1107                                         SetCurrentDirAsDirHist();\r
1108                                         ChangeDirDirectProc(WIN_LOCAL);\r
1109                                         break;\r
1110 \r
1111                                 case MENU_DOWNLOAD :\r
1112                                         SetCurrentDirAsDirHist();\r
1113                                         DownloadProc(NO, NO, NO);\r
1114                                         break;\r
1115 \r
1116                                 case MENU_DOWNLOAD_AS :\r
1117                                         SetCurrentDirAsDirHist();\r
1118                                         DownloadProc(YES, NO, NO);\r
1119                                         break;\r
1120 \r
1121                                 case MENU_DOWNLOAD_AS_FILE :\r
1122                                         SetCurrentDirAsDirHist();\r
1123                                         DownloadProc(NO, YES, NO);\r
1124                                         break;\r
1125 \r
1126                                 case MENU_DOWNLOAD_ALL :\r
1127                                         SetCurrentDirAsDirHist();\r
1128                                         DownloadProc(NO, NO, YES);\r
1129                                         break;\r
1130 \r
1131                                 case MENU_DOWNLOAD_NAME :\r
1132                                         SetCurrentDirAsDirHist();\r
1133                                         InputDownloadProc();\r
1134                                         break;\r
1135 \r
1136                                 case MENU_UPLOAD :\r
1137                                         SetCurrentDirAsDirHist();\r
1138                                         UploadListProc(NO, NO);\r
1139                                         break;\r
1140 \r
1141                                 case MENU_UPLOAD_AS :\r
1142                                         SetCurrentDirAsDirHist();\r
1143                                         UploadListProc(YES, NO);\r
1144                                         break;\r
1145 \r
1146                                 case MENU_UPLOAD_ALL :\r
1147                                         SetCurrentDirAsDirHist();\r
1148                                         UploadListProc(NO, YES);\r
1149                                         break;\r
1150 \r
1151                                 case MENU_MIRROR_UPLOAD :\r
1152                                         SetCurrentDirAsDirHist();\r
1153                                         MirrorUploadProc(YES);\r
1154                                         break;\r
1155 \r
1156                                 case MENU_MIRROR_DOWNLOAD :\r
1157                                         SetCurrentDirAsDirHist();\r
1158                                         MirrorDownloadProc(YES);\r
1159                                         break;\r
1160 \r
1161                                 case MENU_FILESIZE :\r
1162                                         SetCurrentDirAsDirHist();\r
1163                                         CalcFileSizeProc();\r
1164                                         break;\r
1165 \r
1166                                 case MENU_DELETE :\r
1167                                         SuppressRefresh = 1;\r
1168                                         SetCurrentDirAsDirHist();\r
1169                                         DeleteProc();\r
1170                                         SuppressRefresh = 0;\r
1171                                         break;\r
1172 \r
1173                                 case MENU_RENAME :\r
1174                                         SuppressRefresh = 1;\r
1175                                         SetCurrentDirAsDirHist();\r
1176                                         RenameProc();\r
1177                                         SuppressRefresh = 0;\r
1178                                         break;\r
1179 \r
1180                                 case MENU_MKDIR :\r
1181                                         SuppressRefresh = 1;\r
1182                                         SetCurrentDirAsDirHist();\r
1183                                         MkdirProc();\r
1184                                         SuppressRefresh = 0;\r
1185                                         break;\r
1186 \r
1187                                 case MENU_CHMOD :\r
1188                                         SuppressRefresh = 1;\r
1189                                         ChmodProc();\r
1190                                         SuppressRefresh = 0;\r
1191                                         break;\r
1192 \r
1193                                 case MENU_SOMECMD :\r
1194                                         SuppressRefresh = 1;\r
1195                                         SomeCmdProc();\r
1196                                         SuppressRefresh = 0;\r
1197                                         break;\r
1198 \r
1199                                 case MENU_OPTION :\r
1200                                         SetOption(0);\r
1201                                         if(ListFont != NULL)\r
1202                                         {\r
1203                                                 SendMessage(GetLocalHwnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1204                                                 SendMessage(GetRemoteHwnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1205                                                 SendMessage(GetTaskWnd(), WM_SETFONT, (WPARAM)ListFont, MAKELPARAM(TRUE, 0));\r
1206                                         }\r
1207                                         GetLocalDirForWnd();\r
1208                                         DispTransferType();\r
1209                                         CheckHistoryNum(0);\r
1210                                         SetAllHistoryToMenu();\r
1211                                         // 暗号化通信対応\r
1212                                         SetSSLTimeoutCallback(TimeOut * 1000, SSLTimeoutCallback);\r
1213                                         break;\r
1214 \r
1215                                 case MENU_FILTER :\r
1216                                         // 同時接続対応\r
1217                                         CancelFlg = NO;\r
1218                                         SetFilter(&CancelFlg);\r
1219                                         break;\r
1220 \r
1221                                 case MENU_SORT :\r
1222                                         if(SortSetting() == YES)\r
1223                                         {\r
1224                                                 // 同時接続対応\r
1225                                                 CancelFlg = NO;\r
1226                                                 LocalFileSort = AskSortType(ITEM_LFILE);\r
1227                                                 LocalDirSort = AskSortType(ITEM_LDIR);\r
1228                                                 RemoteFileSort = AskSortType(ITEM_RFILE);\r
1229                                                 RemoteDirSort = AskSortType(ITEM_RDIR);\r
1230                                                 ReSortDispList(WIN_LOCAL, &CancelFlg);\r
1231                                                 ReSortDispList(WIN_REMOTE, &CancelFlg);\r
1232                                         }\r
1233                                         break;\r
1234 \r
1235                                 case MENU_EXIT :\r
1236                                         PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1237                                         break;\r
1238 \r
1239                                 case MENU_AUTO_EXIT :\r
1240                                         if(AutoExit == YES)\r
1241                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1242                                         break;\r
1243 \r
1244                                 case MENU_ABOUT :\r
1245                                         DialogBox(hInstFtp, MAKEINTRESOURCE(about_dlg), hWnd, AboutDialogProc);\r
1246                                         break;\r
1247 \r
1248                                 case MENU_TEXT :\r
1249                                 case MENU_BINARY :\r
1250                                 case MENU_AUTO :\r
1251                                         SetTransferType(LOWORD(wParam));\r
1252                                         DispTransferType();\r
1253                                         break;\r
1254 \r
1255                                 case MENU_XFRMODE :\r
1256                                         switch(AskTransferType())\r
1257                                         {\r
1258                                                 case TYPE_A :\r
1259                                                         TmpTransType = MENU_BINARY;\r
1260                                                         break;\r
1261 \r
1262                                                 case TYPE_I :\r
1263                                                         TmpTransType = MENU_AUTO;\r
1264                                                         break;\r
1265 \r
1266                                                 default :\r
1267                                                         TmpTransType = MENU_TEXT;\r
1268                                                         break;\r
1269                                         }\r
1270                                         SetTransferType(TmpTransType);\r
1271                                         DispTransferType();\r
1272                                         break;\r
1273 \r
1274                                 // UTF-8対応\r
1275                                 case MENU_KNJ_SJIS :\r
1276                                 case MENU_KNJ_EUC :\r
1277                                 case MENU_KNJ_JIS :\r
1278                                 case MENU_KNJ_UTF8N :\r
1279                                 case MENU_KNJ_UTF8BOM :\r
1280                                 case MENU_KNJ_NONE :\r
1281                                         SetHostKanjiCode(LOWORD(wParam));\r
1282                                         break;\r
1283 \r
1284                                 case MENU_L_KNJ_SJIS :\r
1285                                 case MENU_L_KNJ_EUC :\r
1286                                 case MENU_L_KNJ_JIS :\r
1287                                 case MENU_L_KNJ_UTF8N :\r
1288                                 case MENU_L_KNJ_UTF8BOM :\r
1289                                         SetLocalKanjiCode(LOWORD(wParam));\r
1290                                         break;\r
1291 \r
1292                                 case MENU_KANACNV :\r
1293                                         SetHostKanaCnv();\r
1294                                         break;\r
1295 \r
1296                                 case MENU_REFRESH :\r
1297                                         // デッドロック対策\r
1298                                         if(AskUserOpeDisabled() == YES)\r
1299                                                 break;\r
1300                                         // 同時接続対応\r
1301                                         CancelFlg = NO;\r
1302                                         SuppressRefresh = 1;\r
1303                                         GetLocalDirForWnd();\r
1304                                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1305                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
1306                                         SuppressRefresh = 0;\r
1307                                         break;\r
1308 \r
1309                                 case MENU_LIST :\r
1310                                         ListType = LVS_LIST;\r
1311                                         DispListType();\r
1312                                         SetListViewType();\r
1313                                         break;\r
1314 \r
1315                                 case MENU_REPORT :\r
1316                                         ListType = LVS_REPORT;\r
1317                                         DispListType();\r
1318                                         SetListViewType();\r
1319                                         break;\r
1320 \r
1321                                 case REFRESH_LOCAL :\r
1322                                         GetLocalDirForWnd();\r
1323                                         break;\r
1324 \r
1325                                 case REFRESH_REMOTE :\r
1326                                         // デッドロック対策\r
1327                                         if(AskUserOpeDisabled() == YES)\r
1328                                                 break;\r
1329                                         // 同時接続対応\r
1330                                         CancelFlg = NO;\r
1331                                         SuppressRefresh = 1;\r
1332                                         if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
1333                                                 GetRemoteDirForWnd(CACHE_REFRESH, &CancelFlg);\r
1334                                         SuppressRefresh = 0;\r
1335                                         break;\r
1336 \r
1337                                 case COMBO_LOCAL :\r
1338                                 case COMBO_REMOTE :\r
1339                                         SuppressRefresh = 1;\r
1340                                         if(HIWORD(wParam) == CBN_SELCHANGE)\r
1341                                         {\r
1342                                                 SetCurrentDirAsDirHist();\r
1343                                                 ChangeDirComboProc((HWND)lParam);\r
1344                                         }\r
1345                                         else if(HIWORD(wParam) != CBN_CLOSEUP)\r
1346                                         {\r
1347                                                 MakeButtonsFocus();\r
1348                                                 SuppressRefresh = 0;\r
1349                                                 return(0);\r
1350                                         }\r
1351                                         SuppressRefresh = 0;\r
1352                                         break;\r
1353 \r
1354                                 case MENU_HELP :\r
1355                                         hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000001);\r
1356                                         break;\r
1357 \r
1358                                 case MENU_HELP_TROUBLE :\r
1359                                         // 任意のコードが実行されるバグ修正\r
1360 //                                      ShellExecute(NULL, "open", MYWEB_URL, NULL, ".", SW_SHOW);\r
1361                                         ShellExecute(NULL, "open", MYWEB_URL, NULL, NULL, SW_SHOW);\r
1362                                         break;\r
1363 \r
1364                                 case MENU_BMARK_ADD :\r
1365                                         AddCurDirToBookMark(WIN_REMOTE);\r
1366                                         break;\r
1367 \r
1368                                 case MENU_BMARK_ADD_LOCAL :\r
1369                                         AddCurDirToBookMark(WIN_LOCAL);\r
1370                                         break;\r
1371 \r
1372                                 case MENU_BMARK_ADD_BOTH :\r
1373                                         AddCurDirToBookMark(WIN_BOTH);\r
1374                                         break;\r
1375 \r
1376                                 case MENU_BMARK_EDIT :\r
1377                                         EditBookMark();\r
1378                                         break;\r
1379 \r
1380                                 case MENU_SELECT_ALL :\r
1381                                         SelectFileInList(hWndCurFocus, SELECT_ALL);\r
1382                                         break;\r
1383 \r
1384                                 case MENU_SELECT :\r
1385                                         SelectFileInList(hWndCurFocus, SELECT_REGEXP);\r
1386                                         break;\r
1387 \r
1388                                 case MENU_FIND :\r
1389                                         FindFileInList(hWndCurFocus, FIND_FIRST);\r
1390                                         break;\r
1391 \r
1392                                 case MENU_FINDNEXT :\r
1393                                         FindFileInList(hWndCurFocus, FIND_NEXT);\r
1394                                         break;\r
1395 \r
1396                                 case MENU_DOTFILE :\r
1397                                         // デッドロック対策\r
1398                                         if(AskUserOpeDisabled() == YES)\r
1399                                                 break;\r
1400                                         // 同時接続対応\r
1401                                         CancelFlg = NO;\r
1402                                         DotFile ^= 1;\r
1403                                         DispDotFileMode();\r
1404                                         GetLocalDirForWnd();\r
1405                                         GetRemoteDirForWnd(CACHE_LASTREAD, &CancelFlg);\r
1406                                         break;\r
1407 \r
1408                                 case MENU_SYNC :\r
1409                                         ToggleSyncMoveMode();\r
1410                                         break;\r
1411 \r
1412                                 case MENU_IMPORT_WS :\r
1413                                         ImportFromWSFTP();\r
1414                                         break;\r
1415 \r
1416                                 case MENU_REGSAVE :\r
1417                                         GetListTabWidth();\r
1418                                         SaveRegistry();\r
1419                                         SaveSettingsToFile();\r
1420                                         break;\r
1421 \r
1422                                 case MENU_REGLOAD :\r
1423                                         if(LoadSettingsFromFile() == YES)\r
1424                                         {\r
1425                                                 MessageBox(hWnd, MSGJPN292, "FFFTP", MB_OK);\r
1426                                                 SaveExit = NO;\r
1427                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1428                                         }\r
1429                                         break;\r
1430 \r
1431                                 case MENU_REGINIT :\r
1432                                         if(DialogBox(hInstFtp, MAKEINTRESOURCE(reginit_dlg), hWnd, ExeEscDialogProc) == YES)\r
1433                                         {\r
1434                                                 ClearRegistry();\r
1435                                                 // ポータブル版判定\r
1436                                                 ClearIni();\r
1437                                                 SaveExit = NO;\r
1438                                                 PostMessage(hWnd, WM_CLOSE, 0, 0L);\r
1439                                         }\r
1440                                         break;\r
1441                                 case MENU_CHANGEPASSWD: /* 2010.01.31 genta */\r
1442                                         if( GetMasterPasswordStatus() != PASSWORD_OK )\r
1443                                         {\r
1444                                                 /* 強制的に設定するか確認 */\r
1445                                                 if( DialogBox(hInstFtp, MAKEINTRESOURCE(forcepasschange_dlg), hWnd, ExeEscDialogProc) != YES){\r
1446                                                         break;\r
1447                                                 }\r
1448                                                 // セキュリティ強化\r
1449                                                 if(EnterMasterPasswordAndSet(newmasterpasswd_dlg, hWnd) != 0)\r
1450                                                         SetTaskMsg(MSGJPN303);\r
1451                                         }\r
1452                                         // セキュリティ強化\r
1453 //                                      if( EnterMasterPasswordAndSet( newmasterpasswd_dlg, hWnd ) != 0 ){\r
1454 //                                              SetTaskMsg( MSGJPN303 );\r
1455 //                                      }\r
1456                                         else if(GetMasterPasswordStatus() == PASSWORD_OK)\r
1457                                         {\r
1458                                                 char Password[MAX_PASSWORD_LEN + 1];\r
1459                                                 GetMasterPassword(Password);\r
1460                                                 SetMasterPassword(NULL);\r
1461                                                 while(ValidateMasterPassword() == YES && GetMasterPasswordStatus() == PASSWORD_UNMATCH)\r
1462                                                 {\r
1463                                                         if(EnterMasterPasswordAndSet(masterpasswd_dlg, NULL) == 0)\r
1464                                                                 break;\r
1465                                                 }\r
1466                                                 if(GetMasterPasswordStatus() == PASSWORD_OK && EnterMasterPasswordAndSet(newmasterpasswd_dlg, hWnd) != 0)\r
1467                                                 {\r
1468                                                         SetTaskMsg(MSGJPN303);\r
1469                                                         SaveRegistry();\r
1470                                                 }\r
1471                                                 else\r
1472                                                 {\r
1473                                                         SetMasterPassword(Password);\r
1474                                                         ValidateMasterPassword();\r
1475                                                 }\r
1476                                         }\r
1477                                         break;\r
1478 \r
1479                                 case MENU_DIRINFO :\r
1480                                         DispDirInfo();\r
1481                                         break;\r
1482 \r
1483                                 case MENU_TASKINFO :\r
1484                                         DispTaskMsg();\r
1485                                         break;\r
1486 \r
1487                                 case MENU_ABORT :\r
1488                                         CancelFlg = YES;\r
1489                                         if(AskTryingConnect() == NO)\r
1490                                                 MainTransPkt.Abort = ABORT_USER;\r
1491                                         break;\r
1492 \r
1493                                 case MENU_OTPCALC :\r
1494                                         OtpCalcTool();\r
1495                                         break;\r
1496 \r
1497                                 case MENU_URL_COPY :\r
1498                                         CopyURLtoClipBoard();\r
1499                                         break;\r
1500 \r
1501                                 case MENU_APPKEY :\r
1502                                         EraseListViewTips();\r
1503                                         if(hWndCurFocus == GetRemoteHwnd())\r
1504                                                 RemoteRbuttonMenu(1);\r
1505                                         else if(hWndCurFocus == GetLocalHwnd())\r
1506                                                 LocalRbuttonMenu(1);\r
1507                                         break;\r
1508 \r
1509 #if defined(HAVE_TANDEM)\r
1510                                 case MENU_SWITCH_OSS :\r
1511                                         SwitchOSSProc();\r
1512                                         break;\r
1513 #endif\r
1514 \r
1515                                 default :\r
1516                                         if((LOWORD(wParam) >= MENU_BMARK_TOP) &&\r
1517                                            (LOWORD(wParam) < MENU_BMARK_TOP+100))\r
1518                                         {\r
1519                                                 ChangeDirBmarkProc(LOWORD(wParam));\r
1520                                         }\r
1521                                         break;\r
1522                         }\r
1523 // 常にホストかローカルへフォーカスを移動\r
1524 //                      SetFocus(hWndCurFocus);\r
1525                         MakeButtonsFocus();\r
1526                         break;\r
1527 \r
1528                 case WM_NOTIFY :\r
1529                         switch(((LPNMHDR)lParam)->code)\r
1530                         {\r
1531                                 /* ツールチップコントロールメッセージの処理 */\r
1532                                 // UTF-8対応\r
1533 //                              case TTN_NEEDTEXT:\r
1534                                 case TTN_NEEDTEXTW:\r
1535                                         lpttt = (LPTOOLTIPTEXT)lParam;\r
1536                                         // UTF-8対応\r
1537                                         // lptttは単なる警告回避用\r
1538                                         wlpttt = (LPTOOLTIPTEXTW)lParam;\r
1539                                         lpttt->hinst = hInstFtp;\r
1540                                         switch(lpttt->hdr.idFrom)\r
1541                                         {\r
1542                                                 case MENU_CONNECT :\r
1543                                                         lpttt->lpszText = MSGJPN154;\r
1544                                                         break;\r
1545 \r
1546                                                 case MENU_QUICK :\r
1547                                                         lpttt->lpszText = MSGJPN155;\r
1548                                                         break;\r
1549 \r
1550                                                 case MENU_DISCONNECT :\r
1551                                                         lpttt->lpszText = MSGJPN156;\r
1552                                                         break;\r
1553 \r
1554                                                 case MENU_DOWNLOAD :\r
1555                                                         lpttt->lpszText = MSGJPN157;\r
1556                                                         break;\r
1557 #if defined(HAVE_TANDEM)\r
1558                                                 case MENU_DOWNLOAD_AS :\r
1559                                                         lpttt->lpszText = MSGJPN065;\r
1560                                                         break;\r
1561 \r
1562                                                 case MENU_UPLOAD_AS :\r
1563                                                         lpttt->lpszText = MSGJPN064;\r
1564                                                         break;\r
1565 #endif\r
1566                                                 case MENU_UPLOAD :\r
1567                                                         lpttt->lpszText = MSGJPN158;\r
1568                                                         break;\r
1569 \r
1570                                                 case MENU_MIRROR_UPLOAD :\r
1571                                                         lpttt->lpszText = MSGJPN159;\r
1572                                                         break;\r
1573 \r
1574                                                 case MENU_DELETE :\r
1575                                                         lpttt->lpszText = MSGJPN160;\r
1576                                                         break;\r
1577 \r
1578                                                 case MENU_RENAME :\r
1579                                                         lpttt->lpszText = MSGJPN161;\r
1580                                                         break;\r
1581 \r
1582                                                 case MENU_MKDIR :\r
1583                                                         lpttt->lpszText = MSGJPN162;\r
1584                                                         break;\r
1585 \r
1586                                                 case MENU_LOCAL_UPDIR :\r
1587                                                 case MENU_REMOTE_UPDIR :\r
1588                                                         lpttt->lpszText = MSGJPN163;\r
1589                                                         break;\r
1590 \r
1591                                                 case MENU_LOCAL_CHDIR :\r
1592                                                 case MENU_REMOTE_CHDIR :\r
1593                                                         lpttt->lpszText = MSGJPN164;\r
1594                                                         break;\r
1595 \r
1596                                                 case MENU_TEXT :\r
1597                                                         lpttt->lpszText = MSGJPN165;\r
1598                                                         break;\r
1599 \r
1600                                                 case MENU_BINARY :\r
1601                                                         lpttt->lpszText = MSGJPN166;\r
1602                                                         break;\r
1603 \r
1604                                                 case MENU_AUTO :\r
1605                                                         lpttt->lpszText = MSGJPN167;\r
1606                                                         break;\r
1607 \r
1608                                                 case MENU_REFRESH :\r
1609                                                         lpttt->lpszText = MSGJPN168;\r
1610                                                         break;\r
1611 \r
1612                                                 case MENU_LIST :\r
1613                                                         lpttt->lpszText = MSGJPN169;\r
1614                                                         break;\r
1615 \r
1616                                                 case MENU_REPORT :\r
1617                                                         lpttt->lpszText = MSGJPN170;\r
1618                                                         break;\r
1619 \r
1620                                                 case MENU_KNJ_SJIS :\r
1621                                                         lpttt->lpszText = MSGJPN307;\r
1622                                                         break;\r
1623 \r
1624                                                 case MENU_KNJ_EUC :\r
1625                                                         lpttt->lpszText = MSGJPN171;\r
1626                                                         break;\r
1627 \r
1628                                                 case MENU_KNJ_JIS :\r
1629                                                         lpttt->lpszText = MSGJPN172;\r
1630                                                         break;\r
1631 \r
1632                                                 case MENU_KNJ_UTF8N :\r
1633                                                         lpttt->lpszText = MSGJPN308;\r
1634                                                         break;\r
1635 \r
1636                                                 case MENU_KNJ_UTF8BOM :\r
1637                                                         lpttt->lpszText = MSGJPN330;\r
1638                                                         break;\r
1639 \r
1640                                                 case MENU_KNJ_NONE :\r
1641                                                         lpttt->lpszText = MSGJPN173;\r
1642                                                         break;\r
1643 \r
1644                                                 case MENU_L_KNJ_SJIS :\r
1645                                                         lpttt->lpszText = MSGJPN309;\r
1646                                                         break;\r
1647 \r
1648                                                 case MENU_L_KNJ_EUC :\r
1649                                                         lpttt->lpszText = MSGJPN310;\r
1650                                                         break;\r
1651 \r
1652                                                 case MENU_L_KNJ_JIS :\r
1653                                                         lpttt->lpszText = MSGJPN311;\r
1654                                                         break;\r
1655 \r
1656                                                 case MENU_L_KNJ_UTF8N :\r
1657                                                         lpttt->lpszText = MSGJPN312;\r
1658                                                         break;\r
1659 \r
1660                                                 case MENU_L_KNJ_UTF8BOM :\r
1661                                                         lpttt->lpszText = MSGJPN331;\r
1662                                                         break;\r
1663 \r
1664                                                 case MENU_KANACNV :\r
1665                                                         lpttt->lpszText = MSGJPN174;\r
1666                                                         break;\r
1667 \r
1668                                                 case MENU_SYNC :\r
1669                                                         lpttt->lpszText = MSGJPN175;\r
1670                                                         break;\r
1671 \r
1672                                                 case MENU_ABORT :\r
1673                                                         lpttt->lpszText = MSGJPN176;\r
1674                                                         break;\r
1675                                         }\r
1676                                         // UTF-8対応\r
1677                                         // UTF-8からUTF-16 LEへ変換\r
1678                                         {\r
1679                                                 static wchar_t StringBufferUTF16[1024];\r
1680                                                 if(lpttt->lpszText)\r
1681                                                 {\r
1682                                                         MtoW(StringBufferUTF16, sizeof(StringBufferUTF16)/ sizeof(wchar_t), lpttt->lpszText, -1);\r
1683                                                         wlpttt->lpszText = StringBufferUTF16;\r
1684                                                 }\r
1685                                         }\r
1686                                         break;\r
1687 \r
1688                                 case LVN_COLUMNCLICK :\r
1689                                         if(((NMHDR *)lParam)->hwndFrom == GetLocalHwnd())\r
1690                                         {\r
1691                                                 // 同時接続対応\r
1692                                                 CancelFlg = NO;\r
1693                                                 SetSortTypeByColumn(WIN_LOCAL, ((NM_LISTVIEW *)lParam)->iSubItem);\r
1694                                                 ReSortDispList(WIN_LOCAL, &CancelFlg);\r
1695                                         }\r
1696                                         else if(((NMHDR *)lParam)->hwndFrom == GetRemoteHwnd())\r
1697                                         {\r
1698                                                 if(((NM_LISTVIEW *)lParam)->iSubItem != 4)\r
1699                                                 {\r
1700                                                         // 同時接続対応\r
1701                                                         CancelFlg = NO;\r
1702                                                         SetSortTypeByColumn(WIN_REMOTE, ((NM_LISTVIEW *)lParam)->iSubItem);\r
1703                                                         ReSortDispList(WIN_REMOTE, &CancelFlg);\r
1704                                                 }\r
1705                                         }\r
1706                                         SetFocus(hWndCurFocus);\r
1707                                         break;\r
1708 \r
1709                                 case LVN_ITEMCHANGED :\r
1710                                         DispSelectedSpace();\r
1711                                         MakeButtonsFocus();\r
1712                                         break;\r
1713                         }\r
1714                         break;\r
1715 \r
1716                 case WM_SIZE :\r
1717                         Sizing = SW_RESTORE;\r
1718                         if(wParam == SIZE_RESTORED)\r
1719                         {\r
1720                                 ResizeWindowProc();\r
1721                                 GetWindowRect(hWnd, &Rect);\r
1722                                 WinPosX = Rect.left;\r
1723                                 WinPosY = Rect.top;\r
1724                         }\r
1725                         else if(wParam == SIZE_MAXIMIZED)\r
1726                         {\r
1727                                 Sizing = SW_MAXIMIZE;\r
1728                                 ResizeWindowProc();\r
1729                         }\r
1730                         else\r
1731                                 return(DefWindowProc(hWnd, message, wParam, lParam));\r
1732                         break;\r
1733 \r
1734                 case WM_MOVING :\r
1735                         WinPosX = ((RECT *)lParam)->left;\r
1736                         WinPosY = ((RECT *)lParam)->top;\r
1737                         return(DefWindowProc(hWnd, message, wParam, lParam));\r
1738 \r
1739                 case WM_SETFOCUS :\r
1740                         SetFocus(hWndCurFocus);\r
1741                         break;\r
1742 \r
1743                 case WM_LBUTTONDOWN :\r
1744                 case WM_LBUTTONUP :\r
1745                 case WM_MOUSEMOVE :\r
1746                         CheckResizeFrame(wParam, LOWORD(lParam), HIWORD(lParam));\r
1747                         break;\r
1748 \r
1749                 case WM_CHANGE_COND :\r
1750                         DispTransferFiles();\r
1751                         break;\r
1752 \r
1753                 case WM_REFRESH_LOCAL_FLG :\r
1754                         // 外部アプリケーションへドロップ後にローカル側のファイル一覧に作業フォルダが表示されるバグ対策\r
1755 //                      PostMessage(hWnd,  WM_COMMAND, MAKEWPARAM(REFRESH_LOCAL, 0), 0);\r
1756                         if(SuppressRefresh == 0)\r
1757                                 PostMessage(hWnd,  WM_COMMAND, MAKEWPARAM(REFRESH_LOCAL, 0), 0);\r
1758                         break;\r
1759 \r
1760                 case WM_REFRESH_REMOTE_FLG :\r
1761                         if(SuppressRefresh == 0)\r
1762                                 PostMessage(hWnd,  WM_COMMAND, MAKEWPARAM(REFRESH_REMOTE, 0), 0);\r
1763                         break;\r
1764 \r
1765                 case WM_PAINT :\r
1766                     BeginPaint(hWnd, (LPPAINTSTRUCT) &ps);\r
1767                     EndPaint(hWnd, (LPPAINTSTRUCT) &ps);\r
1768                         break;\r
1769 \r
1770                 case WM_DESTROY :\r
1771 //                      WSACleanup();\r
1772 //                      DestroyWindow(hWndFtp);\r
1773                         PostQuitMessage(0);\r
1774                         break;\r
1775 \r
1776                 case WM_QUERYENDSESSION :\r
1777                         ExitProc(hWnd);\r
1778                         return(TRUE);\r
1779 \r
1780                 case WM_CLOSE :\r
1781                         if((AskTransferNow() == NO) ||\r
1782                            (DialogBox(hInstFtp, MAKEINTRESOURCE(exit_dlg), hWnd, ExeEscDialogProc) == YES))\r
1783                         {\r
1784                                 ExitProc(hWnd);\r
1785                                 return(DefWindowProc(hWnd, message, wParam, lParam));\r
1786                         }\r
1787                         break;\r
1788 \r
1789                 default :\r
1790                         return(DefWindowProc(hWnd, message, wParam, lParam));\r
1791         }\r
1792     return(0L);\r
1793 }\r
1794 \r
1795 \r
1796 /*----- プログラム開始時の処理 ------------------------------------------------\r
1797 *\r
1798 *       Parameter\r
1799 *               char *Cmd : コマンドライン文字列\r
1800 *\r
1801 *       Return Value\r
1802 *               なし\r
1803 *----------------------------------------------------------------------------*/\r
1804 \r
1805 static void StartupProc(char *Cmd)\r
1806 {\r
1807         int Sts;\r
1808         int AutoConnect;\r
1809         int CmdOption;\r
1810         int Kanji;\r
1811         int Kana;\r
1812         int FnameKanji;\r
1813         int TrMode;\r
1814         char unc[FMAX_PATH+1];\r
1815 \r
1816         Sts = AnalyzeComLine(Cmd, &AutoConnect, &CmdOption, unc, FMAX_PATH);\r
1817 \r
1818         TrMode = TYPE_DEFAULT;\r
1819         Kanji = KANJI_NOCNV;\r
1820         FnameKanji = KANJI_NOCNV;\r
1821         Kana = YES;\r
1822         if(CmdOption & OPT_ASCII)\r
1823                 TrMode = TYPE_A;\r
1824         if(CmdOption & OPT_BINARY)\r
1825                 TrMode = TYPE_I;\r
1826         if(CmdOption & OPT_EUC)\r
1827                 Kanji = KANJI_EUC;\r
1828         if(CmdOption & OPT_JIS)\r
1829                 Kanji = KANJI_JIS;\r
1830         if(CmdOption & OPT_EUC_NAME)\r
1831                 FnameKanji = KANJI_EUC;\r
1832         if(CmdOption & OPT_JIS_NAME)\r
1833                 FnameKanji = KANJI_JIS;\r
1834         if(CmdOption & OPT_KANA)\r
1835                 Kana = NO;\r
1836 \r
1837         if(CmdOption & OPT_QUIT)\r
1838                 AutoExit = YES;\r
1839 \r
1840         if(CmdOption & OPT_SAVEOFF)\r
1841                 SuppressSave = YES;\r
1842         if(CmdOption & OPT_SAVEON)\r
1843                 SuppressSave = NO;\r
1844 \r
1845         // UTF-8対応\r
1846         if(CmdOption & OPT_SJIS)\r
1847                 Kanji = KANJI_SJIS;\r
1848         if(CmdOption & OPT_UTF8N)\r
1849                 Kanji = KANJI_UTF8N;\r
1850         if(CmdOption & OPT_UTF8BOM)\r
1851                 Kanji = KANJI_UTF8BOM;\r
1852         if(CmdOption & OPT_SJIS_NAME)\r
1853                 FnameKanji = KANJI_SJIS;\r
1854         if(CmdOption & OPT_UTF8N_NAME)\r
1855                 FnameKanji = KANJI_UTF8N;\r
1856 \r
1857         if(Sts == 0)\r
1858         {\r
1859                 if(ConnectOnStart == YES)\r
1860                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_CONNECT, 0), 0);\r
1861         }\r
1862         else if(Sts == 1)\r
1863         {\r
1864                 DirectConnectProc(unc, Kanji, Kana, FnameKanji, TrMode);\r
1865         }\r
1866         else if(Sts == 2)\r
1867         {\r
1868                 PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_CONNECT_NUM, CmdOption), (LPARAM)AutoConnect);\r
1869         }\r
1870         return;\r
1871 }\r
1872 \r
1873 \r
1874 /*----- コマンドラインを解析 --------------------------------------------------\r
1875 *\r
1876 *       Parameter\r
1877 *               char *Str : コマンドライン文字列\r
1878 *               int *AutoConnect : 接続ホスト番号を返すワーク\r
1879 *               int *CmdOption : オプションを返すワーク\r
1880 *               char *unc : uncを返すワーク\r
1881 *               int Max : uncの最大長\r
1882 *\r
1883 *       Return Value\r
1884 *               int ステータス\r
1885 *                       0=指定なし、1=URL指定、2=設定名指定、-1=エラー\r
1886 *\r
1887 *       Note\r
1888 *               -m      --mirror\r
1889 *               -d      --mirrordown\r
1890 *               -f      --force\r
1891 *               -q      --quit\r
1892 *               -s      --set\r
1893 *               -h      --help\r
1894 *               -e      --euc\r
1895 *               -j      --jis\r
1896 *               -a      --ascii\r
1897 *               -b      --binary\r
1898 *               -x      --auto\r
1899 *               -k      --kana\r
1900 *               -u      --eucname\r
1901 *               -i      --jisname\r
1902 *               -n  --ini               (CheckIniFileNameで検索)\r
1903 *                       --saveoff\r
1904 *                       --saveon\r
1905 *               -z      --mpasswd       (CheckMasterPasswordで検索)  2010.01.30 genta 追加\r
1906 *----------------------------------------------------------------------------*/\r
1907 \r
1908 static int AnalyzeComLine(char *Str, int *AutoConnect, int *CmdOption, char *unc, int Max)\r
1909 {\r
1910         int Ret;\r
1911         char Tmp[FMAX_PATH+1];\r
1912 \r
1913         *AutoConnect = -1;\r
1914         *CmdOption = 0;\r
1915 \r
1916         Ret = 0;\r
1917         memset(unc, NUL, Max+1);\r
1918 \r
1919         while((Ret != -1) && ((Str = GetToken(Str, Tmp)) != NULL))\r
1920         {\r
1921                 if(Tmp[0] == '-')\r
1922                 {\r
1923                         _strlwr(Tmp);\r
1924                         if((strcmp(&Tmp[1], "m") == 0) || (strcmp(&Tmp[1], "-mirror") == 0))\r
1925                                 *CmdOption |= OPT_MIRROR;\r
1926                         else if((strcmp(&Tmp[1], "d") == 0) || (strcmp(&Tmp[1], "-mirrordown") == 0))\r
1927                                 *CmdOption |= OPT_MIRRORDOWN;\r
1928                         // 廃止予定\r
1929 //                      else if((strcmp(&Tmp[1], "e") == 0) || (strcmp(&Tmp[1], "-euc") == 0))\r
1930 //                              *CmdOption |= OPT_EUC;\r
1931 //                      else if((strcmp(&Tmp[1], "j") == 0) || (strcmp(&Tmp[1], "-jis") == 0))\r
1932 //                              *CmdOption |= OPT_JIS;\r
1933                         else if((strcmp(&Tmp[1], "eu") == 0) || (strcmp(&Tmp[1], "e") == 0) || (strcmp(&Tmp[1], "-euc") == 0))\r
1934                                 *CmdOption |= OPT_EUC;\r
1935                         else if((strcmp(&Tmp[1], "ji") == 0) || (strcmp(&Tmp[1], "j") == 0) || (strcmp(&Tmp[1], "-jis") == 0))\r
1936                                 *CmdOption |= OPT_JIS;\r
1937                         else if((strcmp(&Tmp[1], "a") == 0) || (strcmp(&Tmp[1], "-ascii") == 0))\r
1938                                 *CmdOption |= OPT_ASCII;\r
1939                         else if((strcmp(&Tmp[1], "b") == 0) || (strcmp(&Tmp[1], "-binary") == 0))\r
1940                                 *CmdOption |= OPT_BINARY;\r
1941                         else if((strcmp(&Tmp[1], "x") == 0) || (strcmp(&Tmp[1], "-auto") == 0))\r
1942                                 *CmdOption |= OPT_AUTO;\r
1943                         else if((strcmp(&Tmp[1], "f") == 0) || (strcmp(&Tmp[1], "-force") == 0))\r
1944                                 *CmdOption |= OPT_FORCE;\r
1945                         else if((strcmp(&Tmp[1], "q") == 0) || (strcmp(&Tmp[1], "-quit") == 0))\r
1946                                 *CmdOption |= OPT_QUIT;\r
1947                         else if((strcmp(&Tmp[1], "k") == 0) || (strcmp(&Tmp[1], "-kana") == 0))\r
1948                                 *CmdOption |= OPT_KANA;\r
1949                         // 廃止予定\r
1950 //                      else if((strcmp(&Tmp[1], "u") == 0) || (strcmp(&Tmp[1], "-eucname") == 0))\r
1951 //                              *CmdOption |= OPT_EUC_NAME;\r
1952 //                      else if((strcmp(&Tmp[1], "i") == 0) || (strcmp(&Tmp[1], "-jisname") == 0))\r
1953 //                              *CmdOption |= OPT_JIS_NAME;\r
1954                         else if((strcmp(&Tmp[1], "eun") == 0) || (strcmp(&Tmp[1], "u") == 0) || (strcmp(&Tmp[1], "-eucname") == 0))\r
1955                                 *CmdOption |= OPT_EUC_NAME;\r
1956                         else if((strcmp(&Tmp[1], "jin") == 0) || (strcmp(&Tmp[1], "i") == 0) || (strcmp(&Tmp[1], "-jisname") == 0))\r
1957                                 *CmdOption |= OPT_JIS_NAME;\r
1958                         else if((strcmp(&Tmp[1], "n") == 0) || (strcmp(&Tmp[1], "-ini") == 0))\r
1959                         {\r
1960                                 if((Str = GetToken(Str, Tmp)) == NULL)\r
1961                                 {\r
1962                                         SetTaskMsg(MSGJPN282);\r
1963                                         Ret = -1;\r
1964                                 }\r
1965                         }\r
1966                         else if(strcmp(&Tmp[1], "-saveoff") == 0)\r
1967                                 *CmdOption |= OPT_SAVEOFF;\r
1968                         else if(strcmp(&Tmp[1], "-saveon") == 0)\r
1969                                 *CmdOption |= OPT_SAVEON;\r
1970                         else if((strcmp(&Tmp[1], "z") == 0) || (strcmp(&Tmp[1], "-mpasswd") == 0))\r
1971                         {       /* 2010.01.30 genta : Add master password option */\r
1972                                 if((Str = GetToken(Str, Tmp)) == NULL)\r
1973                                 {\r
1974                                         SetTaskMsg(MSGJPN299);\r
1975                                         Ret = -1;\r
1976                                 }\r
1977                         }\r
1978                         else if((strcmp(&Tmp[1], "s") == 0) || (strcmp(&Tmp[1], "-set") == 0))\r
1979                         {\r
1980                                 if(Ret == 0)\r
1981                                 {\r
1982                                         if((Str = GetToken(Str, Tmp)) != NULL)\r
1983                                         {\r
1984                                                 if((*AutoConnect = SearchHostName(Tmp)) != -1)\r
1985                                                         Ret = 2;\r
1986                                                 else\r
1987                                                 {\r
1988                                                         SetTaskMsg(MSGJPN177, Tmp);\r
1989                                                         Ret = -1;\r
1990                                                 }\r
1991                                         }\r
1992                                         else\r
1993                                         {\r
1994                                                 SetTaskMsg(MSGJPN178);\r
1995                                                 Ret = -1;\r
1996                                         }\r
1997                                 }\r
1998                                 else\r
1999                                 {\r
2000                                         SetTaskMsg(MSGJPN179);\r
2001                                         Ret = -1;\r
2002                                 }\r
2003                         }\r
2004                         else if((strcmp(&Tmp[1], "h") == 0) || (strcmp(&Tmp[1], "-help") == 0))\r
2005                         {\r
2006                                 hHelpWin = HtmlHelp(NULL, AskHelpFilePath(), HH_HELP_CONTEXT, IDH_HELP_TOPIC_0000024);\r
2007                         }\r
2008                         // プロセス保護\r
2009 #ifdef ENABLE_PROCESS_PROTECTION\r
2010                         else if(strcmp(Tmp, "--restart") == 0)\r
2011                         {\r
2012                         }\r
2013                         else if(strcmp(Tmp, "--protect") == 0)\r
2014                         {\r
2015                         }\r
2016                         else if(strcmp(Tmp, "--protect-high") == 0)\r
2017                         {\r
2018                         }\r
2019                         else if(strcmp(Tmp, "--protect-medium") == 0)\r
2020                         {\r
2021                         }\r
2022                         else if(strcmp(Tmp, "--protect-low") == 0)\r
2023                         {\r
2024                         }\r
2025 #endif\r
2026                         // UTF-8対応\r
2027                         else if((strcmp(&Tmp[1], "sj") == 0) || (strcmp(&Tmp[1], "-sjis") == 0))\r
2028                                 *CmdOption |= OPT_SJIS;\r
2029                         else if((strcmp(&Tmp[1], "u8") == 0) || (strcmp(&Tmp[1], "-utf8") == 0))\r
2030                                 *CmdOption |= OPT_UTF8N;\r
2031                         else if((strcmp(&Tmp[1], "8b") == 0) || (strcmp(&Tmp[1], "-utf8bom") == 0))\r
2032                                 *CmdOption |= OPT_UTF8BOM;\r
2033                         else if((strcmp(&Tmp[1], "sjn") == 0) || (strcmp(&Tmp[1], "-sjisname") == 0))\r
2034                                 *CmdOption |= OPT_SJIS_NAME;\r
2035                         else if((strcmp(&Tmp[1], "u8n") == 0) || (strcmp(&Tmp[1], "-utf8name") == 0))\r
2036                                 *CmdOption |= OPT_UTF8N_NAME;\r
2037                         else\r
2038                         {\r
2039                                 SetTaskMsg(MSGJPN180, Tmp);\r
2040                                 Ret = -1;\r
2041                         }\r
2042                 }\r
2043                 else\r
2044                 {\r
2045                         if(Ret == 0)\r
2046                         {\r
2047                                 strncpy(unc, Tmp, Max);\r
2048                                 Ret = 1;\r
2049                         }\r
2050                         else\r
2051                         {\r
2052                                 SetTaskMsg(MSGJPN181);\r
2053                                 Ret = -1;\r
2054                         }\r
2055                 }\r
2056         }\r
2057         return(Ret);\r
2058 }\r
2059 \r
2060 \r
2061 /*----- INIファイルのパス名の指定をチェック ------------------------------------\r
2062 *\r
2063 *       Parameter\r
2064 *               char *Str : コマンドライン文字列\r
2065 *               char *Ini : iniファイル名を返すワーク\r
2066 *\r
2067 *       Return Value\r
2068 *               int ステータス\r
2069 *                       0=指定なし、1=あり\r
2070 *\r
2071 *       Note\r
2072 *               -n  --ini\r
2073 *----------------------------------------------------------------------------*/\r
2074 \r
2075 static int CheckIniFileName(char *Str, char *Ini)\r
2076 {\r
2077         return GetTokenAfterOption( Str, Ini, "n", "-ini" );\r
2078 }\r
2079 \r
2080 /* マスターパスワードの指定をチェック */\r
2081 static int CheckMasterPassword(char *Str, char *Ini)\r
2082 {\r
2083         return GetTokenAfterOption( Str, Ini, "z", "-mpasswd" );\r
2084 }\r
2085 \r
2086 /*----- オプションの後ろのトークンを取り出す ------------------------------------\r
2087 *\r
2088 *       Parameter\r
2089 *               char *Str : コマンドライン文字列\r
2090 *               char *Result : 取り出した文字列を格納するワーク\r
2091 *               const char* Opt1, *Opt2: オプション文字列(2つ)\r
2092 *\r
2093 *       Return Value\r
2094 *               int ステータス\r
2095 *                       0=指定なし、1=あり\r
2096 *\r
2097 *       Note\r
2098 *               2010.01.30 genta マスターパスワード取り出しのため共通化\r
2099 *----------------------------------------------------------------------------*/\r
2100 static int GetTokenAfterOption(char *Str, char *Result, const char* Opt1, const char* Opt2 )\r
2101 {\r
2102         int Ret = 0;\r
2103         char Tmp[FMAX_PATH+1];\r
2104 \r
2105         Result[0] = NUL;\r
2106         while((Str = GetToken(Str, Tmp)) != NULL)\r
2107         {\r
2108                 if(Tmp[0] == '-')\r
2109                 {\r
2110                         _strlwr(Tmp);\r
2111                         if((strcmp(&Tmp[1], Opt1) == 0) || (strcmp(&Tmp[1], Opt2) == 0))\r
2112                         {\r
2113                                 if((Str = GetToken(Str, Result)) != NULL)\r
2114                                         Ret = 1;\r
2115                                 break;\r
2116                         }\r
2117                 }\r
2118         }\r
2119         return(Ret);\r
2120 }\r
2121 \r
2122 /*----- トークンを返す --------------------------------------------------------\r
2123 *\r
2124 *       Parameter\r
2125 *               char *Str : 文字列\r
2126 *               char *Buf : 文字列を返すバッファ\r
2127 *\r
2128 *       Return Value\r
2129 *               char *返したトークンの末尾\r
2130 *                       NULL=終わり\r
2131 *----------------------------------------------------------------------------*/\r
2132 \r
2133 static char *GetToken(char *Str, char *Buf)\r
2134 {\r
2135         int InQuote;\r
2136 \r
2137         while(*Str != NUL)\r
2138         {\r
2139                 if((*Str != ' ') && (*Str != '\t'))\r
2140                         break;\r
2141                 Str++;\r
2142         }\r
2143 \r
2144         if(*Str != NUL)\r
2145         {\r
2146                 InQuote = 0;\r
2147                 while(*Str != NUL)\r
2148                 {\r
2149                         if(*Str == 0x22)\r
2150                                 InQuote = !InQuote;\r
2151                         else\r
2152                         {\r
2153                                 if(((*Str == ' ') || (*Str == '\t')) &&\r
2154                                    (InQuote == 0))\r
2155                                 {\r
2156                                         break;\r
2157                                 }\r
2158                                 *Buf++ = *Str;\r
2159                         }\r
2160                         Str++;\r
2161                 }\r
2162         }\r
2163         else\r
2164                 Str = NULL;\r
2165 \r
2166         *Buf = NUL;\r
2167 \r
2168         return(Str);\r
2169 }\r
2170 \r
2171 \r
2172 /*----- プログラム終了時の処理 ------------------------------------------------\r
2173 *\r
2174 *       Parameter\r
2175 *               HWND hWnd : ウインドウハンドル\r
2176 *\r
2177 *       Return Value\r
2178 *               なし\r
2179 *----------------------------------------------------------------------------*/\r
2180 \r
2181 static void ExitProc(HWND hWnd)\r
2182 {\r
2183         // 環境依存の不具合対策\r
2184         char Tmp[FMAX_PATH+1];\r
2185 \r
2186         CancelFlg = YES;\r
2187 \r
2188         CloseTransferThread();\r
2189 \r
2190         if(SaveExit == YES)\r
2191         {\r
2192                 SaveBookMark();\r
2193                 SaveCurrentSetToHost();\r
2194         }\r
2195         DeleteAlltempFile();\r
2196 \r
2197 //      WSACancelBlockingCall();\r
2198         DisconnectProc();\r
2199 //      CloseTransferThread();\r
2200 \r
2201         if(SaveExit == YES)\r
2202         {\r
2203                 GetListTabWidth();\r
2204                 SaveRegistry();\r
2205                 // ポータブル版判定\r
2206                 if(RegType == REGTYPE_REG)\r
2207                         ClearIni();\r
2208 \r
2209                 if((CacheEntry > 0) && (CacheSave == YES))\r
2210                         SaveCache();\r
2211                 else\r
2212                         DeleteCache();\r
2213         }\r
2214         else\r
2215                 DeleteCache();\r
2216 \r
2217         // 環境依存の不具合対策\r
2218         GetAppTempPath(Tmp);\r
2219         SetYenTail(Tmp);\r
2220         strcat(Tmp, "file");\r
2221         _rmdir(Tmp);\r
2222         GetAppTempPath(Tmp);\r
2223         _rmdir(Tmp);\r
2224 \r
2225         if(RasClose == YES)\r
2226         {\r
2227                 DisconnectRas(RasCloseNotify);\r
2228         }\r
2229         DeleteAllObject();\r
2230         HtmlHelp(NULL, NULL, HH_UNINITIALIZE, dwCookie); \r
2231         return;\r
2232 }\r
2233 \r
2234 \r
2235 /*----- ファイル名をダブルクリックしたときの処理 ------------------------------\r
2236 *\r
2237 *       Parameter\r
2238 *               int Win : ウインドウ番号 (WIN_xxx)\r
2239 *               int Mode : 常に「開く」動作をするかどうか (YES/NO)\r
2240 *               int App : アプリケーション番号(-1=関連づけ優先)\r
2241 *\r
2242 *       Return Value\r
2243 *               なし\r
2244 *----------------------------------------------------------------------------*/\r
2245 \r
2246 void DoubleClickProc(int Win, int Mode, int App)\r
2247 {\r
2248         int Pos;\r
2249         int Type;\r
2250         char Local[FMAX_PATH+1];\r
2251         char Remote[FMAX_PATH+1];\r
2252         char Tmp[FMAX_PATH+1];\r
2253         int Sts;\r
2254         int UseDiffViewer;\r
2255 \r
2256         if(AskUserOpeDisabled() == NO)\r
2257         {\r
2258                 SetCurrentDirAsDirHist();\r
2259                 if(GetSelectedCount(Win) == 1)\r
2260                 {\r
2261                         if((Pos = GetFirstSelected(Win, NO)) != -1)\r
2262                         {\r
2263                                 GetNodeName(Win, Pos, Tmp, FMAX_PATH);\r
2264                                 Type = GetNodeType(Win, Pos);\r
2265 \r
2266                                 if(Win == WIN_LOCAL)\r
2267                                 {\r
2268                                         // ローカルフォルダを開く\r
2269 //                                      if((App != -1) || (Type == NODE_FILE))\r
2270                                         if((App != -1) || (Type == NODE_FILE) || (Mode == YES))\r
2271                                         {\r
2272                                                 if((DclickOpen == YES) || (Mode == YES))\r
2273                                                 {\r
2274                                                         AskLocalCurDir(Local, FMAX_PATH);\r
2275                                                         ReplaceAll(Local, '/', '\\');\r
2276                                                         SetYenTail(Local);\r
2277                                                         strcat(Local, Tmp);\r
2278                                                         ExecViewer(Local, App);\r
2279                                                 }\r
2280                                                 else\r
2281                                                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_UPLOAD, 0), 0);\r
2282                                         }\r
2283                                         else\r
2284                                                 ChangeDir(WIN_LOCAL, Tmp);\r
2285                                 }\r
2286                                 else if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2287                                 {\r
2288                                         if((App != -1) || (Type == NODE_FILE))\r
2289                                         {\r
2290                                                 if((DclickOpen == YES) || (Mode == YES))\r
2291                                                 {\r
2292                                                         // ビューワ2、3のパスが "d " で始まっていたら差分ビューア使用\r
2293                                                         if ((App == 1 || App == 2) && strncmp(ViewerName[App], "d ", 2) == 0)\r
2294                                                                 UseDiffViewer = YES;\r
2295                                                         else\r
2296                                                                 UseDiffViewer = NO;\r
2297 \r
2298                                                         strcpy(Remote, TmpPath);\r
2299                                                         SetYenTail(Remote);\r
2300                                                         // 環境依存の不具合対策\r
2301                                                         strcat(Remote, "file");\r
2302                                                         _mkdir(Remote);\r
2303                                                         SetYenTail(Remote);\r
2304                                                         if (UseDiffViewer == YES) {\r
2305                                                                 strcat(Remote, "remote.");\r
2306                                                         }\r
2307                                                         strcat(Remote, Tmp);\r
2308 \r
2309                                                         if(AskTransferNow() == YES)\r
2310                                                                 SktShareProh();\r
2311 \r
2312         //                                              MainTransPkt.ctrl_skt = AskCmdCtrlSkt();\r
2313                                                         strcpy(MainTransPkt.Cmd, "RETR ");\r
2314                                                         if(AskHostType() == HTYPE_ACOS)\r
2315                                                         {\r
2316                                                                 strcpy(MainTransPkt.RemoteFile, "'");\r
2317                                                                 strcat(MainTransPkt.RemoteFile, AskHostLsName());\r
2318                                                                 strcat(MainTransPkt.RemoteFile, "(");\r
2319                                                                 strcat(MainTransPkt.RemoteFile, Tmp);\r
2320                                                                 strcat(MainTransPkt.RemoteFile, ")");\r
2321                                                                 strcat(MainTransPkt.RemoteFile, "'");\r
2322                                                         }\r
2323                                                         else if(AskHostType() == HTYPE_ACOS_4)\r
2324                                                         {\r
2325                                                                 strcpy(MainTransPkt.RemoteFile, Tmp);\r
2326                                                         }\r
2327                                                         else\r
2328                                                         {\r
2329                                                                 strcpy(MainTransPkt.RemoteFile, Tmp);\r
2330                                                         }\r
2331                                                         strcpy(MainTransPkt.LocalFile, Remote);\r
2332                                                         MainTransPkt.Type = AskTransferTypeAssoc(MainTransPkt.RemoteFile, AskTransferType());\r
2333                                                         MainTransPkt.Size = 1;\r
2334                                                         MainTransPkt.KanjiCode = AskHostKanjiCode();\r
2335                                                         MainTransPkt.KanjiCodeDesired = AskLocalKanjiCode();\r
2336                                                         MainTransPkt.KanaCnv = AskHostKanaCnv();\r
2337                                                         MainTransPkt.Mode = EXIST_OVW;\r
2338                                                         MainTransPkt.ExistSize = 0;\r
2339                                                         MainTransPkt.hWndTrans = NULL;\r
2340                                                         MainTransPkt.Next = NULL;\r
2341 \r
2342                                                         DisableUserOpe();\r
2343 \r
2344                                                         /* 不正なパスを検出 */\r
2345                                                         if(CheckPathViolation(&MainTransPkt) == NO)\r
2346                                                         {\r
2347 //                                                              if((Sts = DoDownload(AskCmdCtrlSkt(), &MainTransPkt, NO)) == 429)\r
2348 //                                                              {\r
2349 //                                                                      ReConnectCmdSkt();\r
2350                                                                         // 同時接続対応\r
2351                                                                         CancelFlg = NO;\r
2352                                                                         Sts = DoDownload(AskCmdCtrlSkt(), &MainTransPkt, NO, &CancelFlg);\r
2353 //                                                              }\r
2354                                                         }\r
2355 \r
2356                                                         EnableUserOpe();\r
2357 \r
2358                                                         AddTempFileList(Remote);\r
2359                                                         if(Sts/100 == FTP_COMPLETE) {\r
2360                                                                 if (UseDiffViewer == YES) {\r
2361                                                                         AskLocalCurDir(Local, FMAX_PATH);\r
2362                                                                         ReplaceAll(Local, '/', '\\');\r
2363                                                                         SetYenTail(Local);\r
2364                                                                         strcat(Local, Tmp);\r
2365                                                                         ExecViewer2(Local, Remote, App);\r
2366                                                                 } else {\r
2367                                                                         ExecViewer(Remote, App);\r
2368                                                                 }\r
2369                                                         }\r
2370                                                 }\r
2371                                                 else\r
2372                                                         PostMessage(hWndFtp, WM_COMMAND, MAKEWPARAM(MENU_DOWNLOAD, 0), 0);\r
2373                                         }\r
2374                                         else\r
2375                                                 ChangeDir(WIN_REMOTE, Tmp);\r
2376                                 }\r
2377                         }\r
2378                 }\r
2379                 MakeButtonsFocus();\r
2380         }\r
2381         return;\r
2382 }\r
2383 \r
2384 \r
2385 /*----- フォルダの移動 --------------------------------------------------------\r
2386 *\r
2387 *       Parameter\r
2388 *               int Win : ウインドウ番号 (WIN_xxx)\r
2389 *               char *Path : 移動先のパス名\r
2390 *\r
2391 *       Return Value\r
2392 *               なし\r
2393 *\r
2394 *       Note\r
2395 *               フォルダ同時移動の処理も行う\r
2396 *----------------------------------------------------------------------------*/\r
2397 \r
2398 static void ChangeDir(int Win, char *Path)\r
2399 {\r
2400         int Sync;\r
2401         char Local[FMAX_PATH+1];\r
2402         char Remote[FMAX_PATH+1];\r
2403 \r
2404         // 同時接続対応\r
2405         CancelFlg = NO;\r
2406 \r
2407         // デッドロック対策\r
2408         DisableUserOpe();\r
2409         Sync = AskSyncMoveMode();\r
2410         if(Sync == YES)\r
2411         {\r
2412                 if(strcmp(Path, "..") == 0)\r
2413                 {\r
2414                         AskLocalCurDir(Local, FMAX_PATH);\r
2415                         AskRemoteCurDir(Remote, FMAX_PATH);\r
2416                         if(strcmp(GetFileName(Local), GetFileName(Remote)) != 0)\r
2417                                 Sync = NO;\r
2418                 }\r
2419         }\r
2420 \r
2421         if((Win == WIN_LOCAL) || (Sync == YES))\r
2422         {\r
2423                 if(DoLocalCWD(Path) == FFFTP_SUCCESS)\r
2424                         GetLocalDirForWnd();\r
2425         }\r
2426 \r
2427         if((Win == WIN_REMOTE) || (Sync == YES))\r
2428         {\r
2429                 if(CheckClosedAndReconnect() == FFFTP_SUCCESS)\r
2430                 {\r
2431 #if defined(HAVE_OPENVMS)\r
2432                         /* OpenVMSの場合、".DIR;?"を取る */\r
2433                         if (AskHostType() == HTYPE_VMS)\r
2434                                 ReformVMSDirName(Path, TRUE);\r
2435 #endif\r
2436                         if(DoCWD(Path, YES, NO, YES) < FTP_RETRY)\r
2437                                 GetRemoteDirForWnd(CACHE_NORMAL, &CancelFlg);\r
2438                 }\r
2439         }\r
2440         // デッドロック対策\r
2441         EnableUserOpe();\r
2442         return;\r
2443 }\r
2444 \r
2445 \r
2446 /*----- ウインドウのサイズ変更の処理 ------------------------------------------\r
2447 *\r
2448 *       Parameter\r
2449 *               なし\r
2450 *\r
2451 *       Return Value\r
2452 *               なし\r
2453 *----------------------------------------------------------------------------*/\r
2454 \r
2455 static void ResizeWindowProc(void)\r
2456 {\r
2457 #if 0\r
2458         RECT Rect;\r
2459         int RemotePosX;\r
2460 \r
2461         GetClientRect(hWndFtp, &Rect);\r
2462         SendMessage(GetSbarWnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(Rect.right, Rect.bottom));\r
2463 \r
2464         CalcWinSize();\r
2465         SetWindowPos(GetMainTbarWnd(), 0, 0, 0, WinWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2466 \r
2467         SetWindowPos(GetLocalTbarWnd(), 0, 0, TOOLWIN_HEIGHT, LocalWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2468         SendMessage(GetLocalTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2469         SetWindowPos(GetLocalHistHwnd(), 0, Rect.right, Rect.top, LocalWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2470         SetWindowPos(GetLocalHwnd(), 0, 0, TOOLWIN_HEIGHT*2, LocalWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2471 \r
2472         RemotePosX = LocalWidth + SepaWidth;\r
2473         if(SplitVertical == YES)\r
2474                 RemotePosX = 0;\r
2475 \r
2476         SetWindowPos(GetRemoteTbarWnd(), 0, RemotePosX, TOOLWIN_HEIGHT, RemoteWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2477         SendMessage(GetRemoteTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2478         SetWindowPos(GetRemoteHistHwnd(), 0, Rect.right, Rect.top, RemoteWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2479         SetWindowPos(GetRemoteHwnd(), 0, RemotePosX, TOOLWIN_HEIGHT*2, RemoteWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2480 \r
2481         SetWindowPos(GetTaskWnd(), 0, 0, TOOLWIN_HEIGHT*2+ListHeight+SepaWidth, ClientWidth, TaskHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2482 #else\r
2483         RECT Rect;\r
2484 \r
2485         GetClientRect(hWndFtp, &Rect);\r
2486         SendMessage(GetSbarWnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(Rect.right, Rect.bottom));\r
2487 \r
2488         CalcWinSize();\r
2489         SetWindowPos(GetMainTbarWnd(), 0, 0, 0, Rect.right, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2490         SetWindowPos(GetLocalTbarWnd(), 0, 0, TOOLWIN_HEIGHT, LocalWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2491         SetWindowPos(GetRemoteTbarWnd(), 0, LocalWidth + SepaWidth, TOOLWIN_HEIGHT, RemoteWidth, TOOLWIN_HEIGHT, SWP_NOACTIVATE | SWP_NOZORDER);\r
2492         SendMessage(GetLocalTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2493         SetWindowPos(GetLocalHistHwnd(), 0, Rect.right, Rect.top, LocalWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2494         SendMessage(GetRemoteTbarWnd(), TB_GETITEMRECT, 3, (LPARAM)&Rect);\r
2495         SetWindowPos(GetRemoteHistHwnd(), 0, Rect.right, Rect.top, RemoteWidth - Rect.right, 200, SWP_NOACTIVATE | SWP_NOZORDER);\r
2496         SetWindowPos(GetLocalHwnd(), 0, 0, TOOLWIN_HEIGHT*2, LocalWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2497         SetWindowPos(GetRemoteHwnd(), 0, LocalWidth + SepaWidth, TOOLWIN_HEIGHT*2, RemoteWidth, ListHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2498         SetWindowPos(GetTaskWnd(), 0, 0, TOOLWIN_HEIGHT*2+ListHeight+SepaWidth, ClientWidth, TaskHeight, SWP_NOACTIVATE | SWP_NOZORDER);\r
2499 #endif\r
2500 \r
2501         return;\r
2502 }\r
2503 \r
2504 \r
2505 /*----- ウインドウの各部分のサイズを計算する ----------------------------------\r
2506 *\r
2507 *       Parameter\r
2508 *               なし\r
2509 *\r
2510 *       Return Value\r
2511 *               なし\r
2512 *----------------------------------------------------------------------------*/\r
2513 \r
2514 static void CalcWinSize(void)\r
2515 {\r
2516         RECT Rect;\r
2517 \r
2518         GetWindowRect(hWndFtp, &Rect);\r
2519 \r
2520         if(Sizing != SW_MAXIMIZE)\r
2521         {\r
2522                 WinWidth = Rect.right - Rect.left;\r
2523                 WinHeight = Rect.bottom - Rect.top;\r
2524         }\r
2525 \r
2526         GetClientRect(hWndFtp, &Rect);\r
2527 \r
2528         ClientWidth = Rect.right;\r
2529         ClientHeight = Rect.bottom;\r
2530 \r
2531         SepaWidth = 4;\r
2532         LocalWidth = max1(0, min1(LocalWidth, ClientWidth - SepaWidth));\r
2533         RemoteWidth = max1(0, ClientWidth - LocalWidth - SepaWidth);\r
2534 //      TaskHeight = min1(TaskHeight, max1(0, ClientHeight - TOOLWIN_HEIGHT * 2 - SepaWidth));\r
2535 \r
2536         GetClientRect(GetSbarWnd(), &Rect);\r
2537 \r
2538         ListHeight = max1(0, ClientHeight - TOOLWIN_HEIGHT * 2 - TaskHeight - SepaWidth - Rect.bottom);\r
2539 \r
2540         return;\r
2541 }\r
2542 \r
2543 \r
2544 #if 0\r
2545 /*----- ウインドウの表示位置を取得する ----------------------------------------\r
2546 *\r
2547 *       Parameter\r
2548 *               HWND hWnd : ウインドウハンドル\r
2549 *\r
2550 *       Return Value\r
2551 *               なし\r
2552 *----------------------------------------------------------------------------*/\r
2553 \r
2554 static void AskWindowPos(HWND hWnd)\r
2555 {\r
2556         WINDOWPLACEMENT WinPlace;\r
2557 \r
2558         WinPlace.length = sizeof(WINDOWPLACEMENT);\r
2559         GetWindowPlacement(hWnd, &WinPlace);\r
2560         WinPosX = WinPlace.rcNormalPosition.left;\r
2561         WinPosY = WinPlace.rcNormalPosition.top;\r
2562 \r
2563         return;\r
2564 }\r
2565 #endif\r
2566 \r
2567 \r
2568 /*----- ディレクトリリストとファイルリストの境界変更処理 ----------------------\r
2569 *\r
2570 *       Parameter\r
2571 *               WPARAM Keys : WM_MOUSEMOVEなどのWPARAMの値\r
2572 *               int x : マウスカーソルのX座標\r
2573 *               int y : マウスカーソルのY座標\r
2574 *\r
2575 *       Return Value\r
2576 *               なし\r
2577 *----------------------------------------------------------------------------*/\r
2578 \r
2579 static void CheckResizeFrame(WPARAM Keys, int x, int y)\r
2580 {\r
2581         RECT Rect;\r
2582         RECT Rect1;\r
2583 \r
2584         if((Resizing == RESIZE_OFF) && (Keys == 0))\r
2585         {\r
2586                 if((x >= LocalWidth) && (x <= LocalWidth + SepaWidth) &&\r
2587                    (y > TOOLWIN_HEIGHT) && (y < (TOOLWIN_HEIGHT * 2 + ListHeight)))\r
2588                 {\r
2589                         /* 境界位置変更用カーソルに変更 */\r
2590                         SetCapture(hWndFtp);\r
2591                         hCursor = LoadCursor(hInstFtp, MAKEINTRESOURCE(resize_lr_csr));\r
2592                         SetCursor(hCursor);\r
2593                         Resizing = RESIZE_PREPARE;\r
2594                         ResizePos = RESIZE_HPOS;\r
2595                 }\r
2596                 else if((y >= TOOLWIN_HEIGHT*2+ListHeight) && (y <= TOOLWIN_HEIGHT*2+ListHeight+SepaWidth))\r
2597                 {\r
2598                         /* 境界位置変更用カーソルに変更 */\r
2599                         SetCapture(hWndFtp);\r
2600                         hCursor = LoadCursor(hInstFtp, MAKEINTRESOURCE(resize_ud_csr));\r
2601                         SetCursor(hCursor);\r
2602                         Resizing = RESIZE_PREPARE;\r
2603                         ResizePos = RESIZE_VPOS;\r
2604                 }\r
2605         }\r
2606         else if(Resizing == RESIZE_PREPARE)\r
2607         {\r
2608                 if(Keys & MK_LBUTTON)\r
2609                 {\r
2610                         /* 境界位置変更開始 */\r
2611                         Resizing = RESIZE_ON;\r
2612                         GetWindowRect(hWndFtp, &Rect);\r
2613                         GetClientRect(GetSbarWnd(), &Rect1);\r
2614                         Rect.left += GetSystemMetrics(SM_CXFRAME);\r
2615                         Rect.right -= GetSystemMetrics(SM_CXFRAME);\r
2616                         Rect.top += TOOLWIN_HEIGHT*2 + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);\r
2617                         Rect.bottom -= GetSystemMetrics(SM_CYFRAME) + Rect1.bottom;\r
2618                         ClipCursor(&Rect);\r
2619                 }\r
2620                 else\r
2621                 {\r
2622                         if(((ResizePos == RESIZE_HPOS) &&\r
2623                                 ((x < LocalWidth) || (x > LocalWidth + SepaWidth) ||\r
2624                                  (y <= TOOLWIN_HEIGHT) || (y >= (TOOLWIN_HEIGHT * 2 + ListHeight)))) ||\r
2625                            ((ResizePos == RESIZE_VPOS) &&\r
2626                                 ((y < TOOLWIN_HEIGHT*2+ListHeight) || (y > TOOLWIN_HEIGHT*2+ListHeight+SepaWidth))))\r
2627                         {\r
2628                                 /* 元のカーソルに戻す */\r
2629                                 ReleaseCapture();\r
2630                                 hCursor = LoadCursor(NULL, IDC_ARROW);\r
2631                                 SetCursor(hCursor);\r
2632                                 Resizing = RESIZE_OFF;\r
2633                         }\r
2634                 }\r
2635         }\r
2636         else if(Resizing == RESIZE_ON)\r
2637         {\r
2638                 if(ResizePos == RESIZE_HPOS)\r
2639                         LocalWidth = x;\r
2640                 else\r
2641                 {\r
2642                         GetClientRect(hWndFtp, &Rect);\r
2643                         GetClientRect(GetSbarWnd(), &Rect1);\r
2644                         TaskHeight = max1(0, Rect.bottom - y - Rect1.bottom);\r
2645                 }\r
2646                 ResizeWindowProc();\r
2647 \r
2648                 if((Keys & MK_LBUTTON) == 0)\r
2649                 {\r
2650                         /* 境界位置変更終了 */\r
2651                         ReleaseCapture();\r
2652                         ClipCursor(NULL);\r
2653                         hCursor = LoadCursor(NULL, IDC_ARROW);\r
2654                         SetCursor(hCursor);\r
2655                         Resizing = RESIZE_OFF;\r
2656                 }\r
2657         }\r
2658         return;\r
2659 }\r
2660 \r
2661 \r
2662 /*----- ファイル一覧情報をビューワで表示 --------------------------------------\r
2663 *\r
2664 *       Parameter\r
2665 *               なし\r
2666 *\r
2667 *       Return Value\r
2668 *               なし\r
2669 *----------------------------------------------------------------------------*/\r
2670 \r
2671 static void DispDirInfo(void)\r
2672 {\r
2673         char Buf[FMAX_PATH+1];\r
2674 \r
2675         MakeCacheFileName(AskCurrentFileListNum(), Buf);\r
2676         ExecViewer(Buf, 0);\r
2677         return;\r
2678 }\r
2679 \r
2680 \r
2681 \r
2682 /*----- ビューワを起動 --------------------------------------------------------\r
2683 *\r
2684 *       Parameter\r
2685 *               char Fname : ファイル名\r
2686 *               int App : アプリケーション番号(-1=関連づけ優先)\r
2687 *\r
2688 *       Return Value\r
2689 *               なし\r
2690 *----------------------------------------------------------------------------*/\r
2691 \r
2692 void ExecViewer(char *Fname, int App)\r
2693 {\r
2694         PROCESS_INFORMATION Info;\r
2695         STARTUPINFO Startup;\r
2696         char AssocProg[FMAX_PATH+1];\r
2697         char ComLine[FMAX_PATH*2+3+1];\r
2698         char CurDir[FMAX_PATH+1];\r
2699         // 任意のコードが実行されるバグ修正\r
2700         char SysDir[FMAX_PATH+1];\r
2701 \r
2702         /* FindExecutable()は関連付けられたプログラムのパス名にスペースが        */\r
2703         /* 含まれている時、間違ったパス名を返す事がある。                                        */\r
2704         /* そこで、関連付けられたプログラムの起動はShellExecute()を使う。       */\r
2705 \r
2706         AskLocalCurDir(CurDir, FMAX_PATH);\r
2707 \r
2708         // 任意のコードが実行されるバグ修正\r
2709         // 拡張子が無いと補完されるため\r
2710 //      if((App == -1) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32))\r
2711         if((App == -1) && (strlen(GetFileExt(GetFileName(Fname))) > 0) && (FindExecutable(Fname, NULL, AssocProg) > (HINSTANCE)32))\r
2712         {\r