OSDN Git Service

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