[Ttssh2-commit] [3623] GetModuleFileName の返り値をチェックするようにした。

svnno****@sourc***** svnno****@sourc*****
2009年 9月 20日 (日) 22:37:45 JST


Revision: 3623
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3623
Author:   maya
Date:     2009-09-20 22:37:45 +0900 (Sun, 20 Sep 2009)

Log Message:
-----------
GetModuleFileName の返り値をチェックするようにした。
  http://sourceforge.jp/ticket/browse.php?group_id=1412&tid=18740

Modified Paths:
--------------
    trunk/doc/en/html/macro/command/getttdir.html
    trunk/doc/ja/html/macro/command/getttdir.html
    trunk/teraterm/common/ttlib.c
    trunk/teraterm/teraterm/ttplug.c
    trunk/teraterm/ttpcmn/ttcmn.c
    trunk/teraterm/ttpmacro/ttl.c
    trunk/teraterm/ttpmacro/ttmdlg.cpp


-------------- next part --------------
Modified: trunk/doc/en/html/macro/command/getttdir.html
===================================================================
--- trunk/doc/en/html/macro/command/getttdir.html	2009-09-19 14:21:06 UTC (rev 3622)
+++ trunk/doc/en/html/macro/command/getttdir.html	2009-09-20 13:37:45 UTC (rev 3623)
@@ -24,7 +24,8 @@
 <h2>Remarks</h2>
 
 <p>
-The ttpmacro.exe directory is stored in the &lt;strvar&gt; string variable.
+The ttpmacro.exe directory is stored in the &lt;strvar&gt; string variable.<br>
+If the directory is gotten successfully, the system variable "result" is set to 0. Otherwise, "result" is set to zero.
 </p>
 
 <h2>Example</h2>

Modified: trunk/doc/ja/html/macro/command/getttdir.html
===================================================================
--- trunk/doc/ja/html/macro/command/getttdir.html	2009-09-19 14:21:06 UTC (rev 3622)
+++ trunk/doc/ja/html/macro/command/getttdir.html	2009-09-20 13:37:45 UTC (rev 3623)
@@ -24,7 +24,8 @@
 <h2>‰ðà</h2>
 
 <p>
-ttpmacro.exe ‚ª‚ ‚éƒfƒBƒŒƒNƒgƒŠ‚𕶎š—ñ•Ï” &lt;strvar&gt; ‚ÉŠi”[‚·‚éB
+ttpmacro.exe ‚ª‚ ‚éƒfƒBƒŒƒNƒgƒŠ‚𕶎š—ñ•Ï” &lt;strvar&gt; ‚ÉŠi”[‚·‚éB<br>
+ƒfƒBƒŒƒNƒgƒŠ‚̎擾‚ɐ¬Œ÷‚µ‚½ê‡‚́AƒVƒXƒeƒ€•Ï” result ‚É1‚ª•Ô‚éBŽ¸”s‚µ‚½ê‡‚́Aresult ‚É0‚ª•Ô‚éB
 </p>
 
 <h2>—á</h2>

Modified: trunk/teraterm/common/ttlib.c
===================================================================
--- trunk/teraterm/common/ttlib.c	2009-09-19 14:21:06 UTC (rev 3622)
+++ trunk/teraterm/common/ttlib.c	2009-09-20 13:37:45 UTC (rev 3623)
@@ -625,7 +625,10 @@
 	char CurDir[MAX_PATH];
 
 	/* Get home directory */
-	GetModuleFileName(NULL,Temp,sizeof(Temp));
+	if (GetModuleFileName(NULL,Temp,sizeof(Temp)) == 0) {
+		memset(buf, 0, buflen);
+		return;
+	}
 	ExtractDirName(Temp, HomeDir);
 
 	/* Get SetupFName */
@@ -649,7 +652,10 @@
 	char SetupFName[MAX_PATH];
 
 	/* Get home directory */
-	GetModuleFileName(NULL,Temp,sizeof(Temp));
+	if (GetModuleFileName(NULL,Temp,sizeof(Temp)) == 0) {
+		strncpy_s(buf, buflen, "off", _TRUNCATE);
+		return;
+	}
 	ExtractDirName(Temp, HomeDir);
 
 	/* Get SetupFName */

Modified: trunk/teraterm/teraterm/ttplug.c
===================================================================
--- trunk/teraterm/teraterm/ttplug.c	2009-09-19 14:21:06 UTC (rev 3622)
+++ trunk/teraterm/teraterm/ttplug.c	2009-09-20 13:37:45 UTC (rev 3623)
@@ -85,7 +85,9 @@
     struct _finddata_t searchData;
     long searchHandle;
 
-    GetModuleFileName(hInst, buf, sizeof(buf));
+    if (GetModuleFileName(hInst, buf, sizeof(buf)) == 0) {
+      return;
+    }
     for (index = strlen(buf) - 1;
     index >= 0 && buf[index] != '\\' && buf[index] != ':' && buf[index] != '/';
       index--) {

Modified: trunk/teraterm/ttpcmn/ttcmn.c
===================================================================
--- trunk/teraterm/ttpcmn/ttcmn.c	2009-09-19 14:21:06 UTC (rev 3622)
+++ trunk/teraterm/ttpcmn/ttcmn.c	2009-09-20 13:37:45 UTC (rev 3623)
@@ -64,7 +64,9 @@
 	// if (FirstInstance) { ‚Ì•”•ª‚©‚çˆÚ“® (2008.3.13 maya)
 	// ‹N“®Žž‚ɂ́A‹¤—Lƒƒ‚ƒŠ‚Ì HomeDir ‚Æ SetupFName ‚Í‹ó‚É‚È‚é
 	/* Get home directory */
-	GetModuleFileName(hInst,Temp,sizeof(Temp));
+	if (GetModuleFileName(hInst,Temp,sizeof(Temp)) == 0) {
+		return TRUE;
+	}
 	ExtractDirName(Temp, ts->HomeDir);
 	_chdir(ts->HomeDir);
 	GetDefaultSetupFName(ts->HomeDir, ts->SetupFName, sizeof(ts->SetupFName));

Modified: trunk/teraterm/ttpmacro/ttl.c
===================================================================
--- trunk/teraterm/ttpmacro/ttl.c	2009-09-19 14:21:06 UTC (rev 3622)
+++ trunk/teraterm/ttpmacro/ttl.c	2009-09-20 13:37:45 UTC (rev 3623)
@@ -1755,9 +1755,14 @@
 		Err = ErrSyntax;
 	if (Err!=0) return Err;
 
-	GetModuleFileName(NULL, Temp, sizeof(Temp));
+	if (GetModuleFileName(NULL, Temp, sizeof(Temp)) == 0) {
+		SetStrVal(VarId,"");
+		SetResult(0);
+		return Err;
+	}
 	ExtractDirName(Temp, HomeDir);
 	SetStrVal(VarId,HomeDir);
+	SetResult(1);
 
 	return Err;
 }

Modified: trunk/teraterm/ttpmacro/ttmdlg.cpp
===================================================================
--- trunk/teraterm/ttpmacro/ttmdlg.cpp	2009-09-19 14:21:06 UTC (rev 3622)
+++ trunk/teraterm/ttpmacro/ttmdlg.cpp	2009-09-20 13:37:45 UTC (rev 3623)
@@ -89,7 +89,9 @@
 	char Temp[MAXPATHLEN];
 
 	// Get home directory
-	GetModuleFileName(AfxGetInstanceHandle(),FileName,sizeof(FileName));
+	if (GetModuleFileName(AfxGetInstanceHandle(),FileName,sizeof(FileName)) == 0) {
+		return;
+	}
 	ExtractDirName(FileName,HomeDir);
 	_chdir(HomeDir);
 



Ttssh2-commit メーリングリストの案内