OSDN Git Service

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