OSDN Git Service

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