OSDN Git Service

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