OSDN Git Service

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