svnno****@sourc*****
svnno****@sourc*****
2013年 5月 6日 (月) 01:16:53 JST
Revision: 5238 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5238 Author: yutakapon Date: 2013-05-06 01:16:52 +0900 (Mon, 06 May 2013) Log Message: ----------- チケット #31286 execマクロコマンドに第4引数(カレントディレクトリ)を追加した。 Ticket Links: ------------ http://sourceforge.jp/projects/ttssh2/tracker/detail/31286 Modified Paths: -------------- trunk/teraterm/ttpmacro/ttl.c -------------- next part -------------- Modified: trunk/teraterm/ttpmacro/ttl.c =================================================================== --- trunk/teraterm/ttpmacro/ttl.c 2013-05-05 13:20:28 UTC (rev 5237) +++ trunk/teraterm/ttpmacro/ttl.c 2013-05-05 16:16:52 UTC (rev 5238) @@ -1081,11 +1081,16 @@ WORD TTLExec() { - TStrVal Str,Str2; + TStrVal Str,Str2, CurDir; int mode = SW_SHOW; int wait = 0, ret; WORD Err; + STARTUPINFO sui; + PROCESS_INFORMATION pi; + BOOL bRet; + memset(CurDir, 0, sizeof(CurDir)); + Err = 0; GetStrVal(Str,&Err); @@ -1108,6 +1113,12 @@ if (CheckParameterGiven()) { GetIntVal(&wait, &Err); if (Err!=0) return Err; + + // get 4th arg(optional) if given + if (CheckParameterGiven()) { + GetStrVal(CurDir, &Err); + if (Err!=0) return Err; + } } } @@ -1117,16 +1128,15 @@ if (Err!=0) return Err; - if (!wait) { - WinExec(Str, mode); - } - else { - STARTUPINFO sui; - PROCESS_INFORMATION pi; - memset(&sui, 0, sizeof(STARTUPINFO)); - sui.cb = sizeof(STARTUPINFO); - sui.wShowWindow = mode; - CreateProcess(NULL, Str, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &sui, &pi); + memset(&sui, 0, sizeof(STARTUPINFO)); + sui.cb = sizeof(STARTUPINFO); + sui.wShowWindow = mode; + if (CurDir[0] == 0) + bRet = CreateProcess(NULL, Str, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &sui, &pi); + else + bRet = CreateProcess(NULL, Str, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, CurDir, &sui, &pi); + // TODO: check bRet + if (wait) { WaitForSingleObject(pi.hProcess, INFINITE); GetExitCodeProcess(pi.hProcess, &ret); SetResult(ret);