[ttssh2-commit] [9492] 単にプログラムを起動する関数を追加

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2021年 10月 23日 (土) 01:10:18 JST


Revision: 9492
          https://osdn.net/projects/ttssh2/scm/svn/commits/9492
Author:   zmatsuo
Date:     2021-10-23 01:10:18 +0900 (Sat, 23 Oct 2021)
Log Message:
-----------
単にプログラムを起動する関数を追加

- TTWinExec()
- TTWinExecA() (ANSI版)

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

-------------- next part --------------
Modified: trunk/teraterm/teraterm/vtwin.cpp
===================================================================
--- trunk/teraterm/teraterm/vtwin.cpp	2021-10-22 16:10:10 UTC (rev 9491)
+++ trunk/teraterm/teraterm/vtwin.cpp	2021-10-22 16:10:18 UTC (rev 9492)
@@ -3467,6 +3467,45 @@
 	return 0;
 }
 
+/**
+ *	\x83v\x83\x8D\x83O\x83\x89\x83\x80\x82\xF0\x8E\xC0\x8Ds\x82\xB7\x82\xE9
+ *
+ *	@param[in]	command		\x8E\xC0\x8Ds\x82\xB7\x82\xE9\x83R\x83}\x83\x93\x83h\x83\x89\x83C\x83\x93
+ *							CreateProcess() \x82ɂ\xBB\x82̂܂ܓn\x82\xB3\x82\xEA\x82\xE9
+ * 	@retval		NO_ERROR	\x83G\x83\x89\x81[\x82Ȃ\xB5
+ *	@retval		\x83G\x83\x89\x81[\x83R\x81[\x83h	(NO_ERROR\x88ȊO)
+ *
+ *	\x83V\x83\x93\x83v\x83\x8B\x82Ƀv\x83\x8D\x83O\x83\x89\x83\x80\x82\xF0\x8BN\x93\xAE\x82\xB7\x82邾\x82\xAF\x82̊֐\x94
+ *		CreateProcess() \x82\xCD CloseHandle() \x82\xF0\x96Y\x82\xEA\x82ăn\x83\x93\x83h\x83\x8B\x83\x8A\x81[\x83N\x82\xF0\x8BN\x82\xB1\x82\xB5\x82₷\x82\xA2
+ *		\x92P\x8F\x83\x82ȃv\x83\x8D\x83O\x83\x89\x83\x80\x8E\xC0\x8Ds\x82ł͂\xB1\x82̊֐\x94\x82\xF0\x8Eg\x97p\x82\xB7\x82\xE9\x82ƈ\xC0\x91S
+ */
+DWORD TTWinExec(const wchar_t *command)
+{
+	STARTUPINFOW si = {};
+	PROCESS_INFORMATION pi = {};
+
+	GetStartupInfoW(&si);
+
+	BOOL r = CreateProcessW(NULL, (LPWSTR)command, NULL, NULL, FALSE, 0,
+							NULL, NULL, &si, &pi);
+	if (r == 0) {
+		// error
+		return GetLastError();
+	}
+
+	CloseHandle(pi.hThread);
+	CloseHandle(pi.hProcess);
+	return NO_ERROR;
+}
+
+DWORD TTWinExecA(const char *commandA)
+{
+	wchar_t *commandW = ToWcharA(commandA);
+	DWORD e = TTWinExec(commandW);
+	free(commandW);
+	return e;
+}
+
 void CVTWindow::OnFileNewConnection()
 {
 	if (Connecting) return;


ttssh2-commit メーリングリストの案内
Back to archive index