[Ttssh2-commit] [3648] LogMeTTのインストールパスをレジストリからも判断するようにした。

svnno****@sourc***** svnno****@sourc*****
2009年 10月 18日 (日) 22:38:52 JST


Revision: 3648
          http://sourceforge.jp/projects/ttssh2/svn/view?view=rev&revision=3648
Author:   yutakapon
Date:     2009-10-18 22:38:52 +0900 (Sun, 18 Oct 2009)

Log Message:
-----------
LogMeTTのインストールパスをレジストリからも判断するようにした。

Modified Paths:
--------------
    trunk/teraterm/teraterm/vtwin.cpp


-------------- next part --------------
Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2009-10-15 15:00:21 UTC (rev 3647)
+++ trunk/teraterm/teraterm/vtwin.cpp	2009-10-18 13:38:52 UTC (rev 3648)
@@ -945,16 +945,44 @@
 }
 
 // LogMeIn.exe -> LogMeTT.exe ‚ÖƒŠƒl[ƒ€ (2005.2.21 yutaka)
-char *LogMeTTexename = "LogMeTT.exe";
 static char LogMeTTMenuString[] = "Log&MeTT";
+static char LogMeTT[MAX_PATH];
+
 static BOOL isLogMeTTExist()
 {
-	char LogMeTT[MAX_PATH];
-	
-	strncpy_s(LogMeTT, sizeof(LogMeTT), ts.HomeDir, _TRUNCATE);
-	AppendSlash(LogMeTT, sizeof(LogMeTT));
-	strncat_s(LogMeTT, sizeof(LogMeTT), LogMeTTexename, _TRUNCATE);
+	const char *LogMeTTexename = "LogMeTT.exe";
+	LONG result;
+	HKEY key;
+	int inregist = 0;
+	DWORD dwSize;
+	DWORD dwType;
+	DWORD dwDisposition;
+	char *path;
 
+	/* LogMeTT 2.9.6‚©‚ç‚̓ŒƒWƒXƒgƒŠ‚ɃCƒ“ƒXƒg[ƒ‹ƒpƒX‚ªŠÜ‚Ü‚ê‚éB*/
+	result = RegCreateKeyEx(HKEY_CURRENT_USER, "Software\\LogMeTT", 0, NULL,
+				REG_OPTION_NON_VOLATILE, KEY_READ, NULL, &key, &dwDisposition);
+	if (result == ERROR_SUCCESS) {
+		result = RegQueryValueEx(key, "InstallPath", NULL, &dwType, NULL, &dwSize);
+		if (result == ERROR_SUCCESS) {
+			path = (char *)malloc(dwSize);
+			if (path != NULL) {
+				result = RegQueryValueEx(key, "InstallPath", NULL, &dwType, (LPBYTE)path, &dwSize);
+				if (result == ERROR_SUCCESS) {
+					inregist = 1;
+					strncpy_s(LogMeTT, sizeof(LogMeTT), path, _TRUNCATE);
+				}
+				free(path);
+			}
+		}
+	}
+
+	if (inregist == 0) {
+		strncpy_s(LogMeTT, sizeof(LogMeTT), ts.HomeDir, _TRUNCATE);
+		AppendSlash(LogMeTT, sizeof(LogMeTT));
+		strncat_s(LogMeTT, sizeof(LogMeTT), LogMeTTexename, _TRUNCATE);
+	}
+
 	if (_access(LogMeTT, 0) == -1) {
 		return FALSE;
 	}
@@ -3545,7 +3573,6 @@
 {
 	STARTUPINFO si;
 	PROCESS_INFORMATION pi;
-	char LogMeTT[MAX_PATH];
 
 	if (!isLogMeTTExist()) {
 		return;
@@ -3555,10 +3582,6 @@
 	GetStartupInfo(&si);
 	memset(&pi, 0, sizeof(pi));
 
-	strncpy_s(LogMeTT, sizeof(LogMeTT), ts.HomeDir, _TRUNCATE);
-	AppendSlash(LogMeTT, sizeof(LogMeTT));
-	strncat_s(LogMeTT, sizeof(LogMeTT), LogMeTTexename, _TRUNCATE);
-
 	if (CreateProcess(NULL, LogMeTT, NULL, NULL, FALSE, 0,
 	                  NULL, NULL, &si, &pi) == 0) {
 		char buf[80];



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