exec¤Ç¤Ê¤¯¡¢CreateProcess´Ø¿ô¤Ç¼Â¹Ô¤¹¤ì¤ÐľÀÜ¥×¥í¥»¥¹ID¤¬¼è¤ì¤Þ¤¹¤è¡£
½ªÎ»¤Ë¤Ï¡¢taskkill¥³¥Þ¥ó¥É¤ò/f¥ª¥×¥·¥ç¥ó¤òÉÕ¤±¤º¤Ë»È¤¤¡¢Ä̾ェ뤵¤»¤Þ¤¹¡Ê¶¯À©½ªÎ»¤µ¤»¤ë¤È½ªÎ»»þ¤Î½èÍý¤¬¤µ¤ì¤Ê¤¤¤Î¤Ç¡Ë
#uselib "kernel32.dll"
#func CreateProcess "CreateProcessA" sptr,sptr,sptr,sptr,sptr,sptr,sptr,sptr,sptr,sptr
#define NULL 0
#define FALSE 0
#define CREATE_NO_WINDOW 0x8000000
#func CloseHandle "CloseHandle" sptr
// ¼Â¹Ô¤¹¤ë¥Õ¥¡¥¤¥ëÁªÂò¡Ê°ì±þ¥«¥ì¥ó¥È¥Ç¥£¥ì¥¯¥È¥ê¤Ï¸µ¤ËÌ᤹¡Ë
originalCurDir = dir_cur
dialog "exe", 16, "¼Â¹Ô²Äǽ¥Õ¥¡¥¤¥ë"
if (stat == 0) : end
fileName = refstr
chdir originalCurDir
// µ¯Æ°
dim startupInfo, 17
startupInfo(0) = varsize(startupInfo)
dim processInfo, 4
CreateProcess fileName, "", NULL, NULL, FALSE, 0, NULL, NULL, varptr(startupInfo), varptr(processInfo)
hProcess = processInfo(0)
hThread = processInfo(1)
processId = processInfo(2)
;threadId = processInfo(3)
button "½ªÎ»",*owari
stop
*owari
// ½ªÎ»¡Êtaskkill¥³¥Þ¥ó¥É¤Ç¡¢¶¯À©½ªÎ»¤Ç¤Ï¤Ê¤¯Ä̾ェ뤵¤»¤ë¡£CREATE_NO_WINDOW¥Õ¥é¥°¤Ç¥³¥Þ¥ó¥É¥×¥í¥ó¥×¥È¤¬É½¼¨¤µ¤ì¤Ê¤¤¤è¤¦¤Ë¡Ë
dim startupInfoCmd, 17
startupInfoCmd(0) = varsize(startupInfoCmd)
dim startupInfoCmd, 4
CreateProcess NULL, strf("cmd.exe /c taskkill /pid %d", processId), NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, varptr(startupInfo), varptr(processInfo)
CloseHandle startupInfoCmd(0)
CloseHandle startupInfoCmd(1)
// ¥×¥í¥»¥¹¡¦¥¹¥ì¥Ã¥É¤Î¥Ï¥ó¥É¥ë¤òÊĤ¸¤ë
CloseHandle hProcess
CloseHandle hThread
end