如何让pb写的程序有返回值.
写了一个pb程序仅为一个exe文件,用于dos下执行,但现在的问题是
pb的application对像根本没有返回值 return为[none],但我想有别人程序
调用时它能够把执行结果状态返回(如在autosays下执行),请求高人指点。
[解决办法]
据我所知,是不能的!
等待其它高手回答.
进程间通讯可能用sendmessage来解决.
[解决办法]
进程间通讯可以用sendmessage来解决.
[解决办法]
在app的close事件设置Message.LongParm即可。
[解决办法]
有呀, 你是怎样取的?? 在dos下用errorlevel可以取得返回值!
[解决办法]
STARTUPINFO lstr_si
PROCESS_INFORMATION lstr_pi
ULong lul_null, lul_CreationFlags, lul_ExitCode, lul_msecs
String ls_null
// initialize arguments
SetNull(lul_null)
SetNull(ls_null)
lstr_si.cb = 72
lstr_si.dwFlags = STARTF_USESHOWWINDOW
lstr_si.wShowWindow = ai_showwindow
lul_CreationFlags = CREATE_NEW_CONSOLE + NORMAL_PRIORITY_CLASS
// create process/thread and execute the passed program
If CreateProcessA(as_exefullpath, ls_null,lul_null, &
lul_null, False, lul_CreationFlags, lul_null, &
ls_null, lstr_si, lstr_pi) Then
// wait for the process to complete
If iul_millsecs > 0 Then
// wait until process ends or timeout period expires
lul_ExitCode = WaitForSingleObject(lstr_pi.hProcess, iul_millsecs)
// terminate process if not finished
If ib_terminate And lul_ExitCode = WAIT_TIMEOUT Then
TerminateProcess(lstr_pi.hProcess, -1)
lul_ExitCode = WAIT_TIMEOUT
Else
// check for exit code
GetExitCodeProcess(lstr_pi.hProcess, lul_ExitCode)
End If
Else
// wait until process ends
WaitForSingleObject(lstr_pi.hProcess, INFINITE)
// check for exit code
GetExitCodeProcess(lstr_pi.hProcess, lul_ExitCode)
End If
// close process and thread handles
CloseHandle(lstr_pi.hProcess)
CloseHandle(lstr_pi.hThread)
Else
// return failure
lul_ExitCode = -1
End If
Return lul_ExitCode
type process_information from structure
unsignedlonghprocess
unsignedlonghthread
unsignedlongdwprocessid
unsignedlongdwthreadid
end type
type startupinfo from structure
unsignedlongcb
stringlpreserved
stringlpdesktop
stringlptitle
unsignedlongdwx
unsignedlongdwy
unsignedlongdwxsize
unsignedlongdwysize
unsignedlongdwxcountchars
unsignedlongdwycountchars
unsignedlongdwfillattribute
unsignedlongdwflags
unsignedlongwshowwindow
unsignedlongcbreserved2
stringlpreserved2
unsignedlonghstdinput
unsignedlonghstdoutput
unsignedlonghstderror
end type
[解决办法]
把想返回的写到文件再读.
[解决办法]
不行的。可以用文件或注册表方式处理。
[解决办法]
可以用文件或者注册表作为通讯的中介。