DECLARE LONG CreateProcess IN Kernel32;
STRING@, STRING@, STRING@, STRING@, LONG, LONG, STRING@, STRING@, STRING@, STRING@
DECLARE LONG TerminateProcess IN Kernel32 LONG, LONG
#DEFINE CREATE_NEW_CONSOLE
0x00000010
szFileName = "c:\windows\system32\notepad.exe"
dhProcess = 0
IF _CreateProcess(szFileName, @dhProcess)
? "成功运行 " + szFileName + " 程序"
? " 1 秒后自动关闭 " + szFileName + " 程序"
INKEY(1)
TerminateProcess(dhProcess, 0)
ENDIF
RETURN
FUNCTION _CreateProcess(szFileName, dhProcess)
LOCAL stSI, stPI
stSI = BINTOC(68, "4RS") + REPLICATE(0h00, 64)
stPI = REPLICATE(0h00, 16)
IF CreateProcess(@szFileName, NULL, NULL, NULL,;
0, CREATE_NEW_CONSOLE, NULL,NULL,;
@stSI, @stPI) == 0
MESSAGEBOX("运行 " + szFileName + " 失败", "提示")
RETURN .F.
ENDIF
dhProcess = CTOBIN(SUBSTR(stPI, 1, 4), "4RS")
RETURN .T.
ENDFUNC