怎么让pb写的程序有返回值
如何让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
unsignedlong hprocess
unsignedlong hthread
unsignedlong dwprocessid
unsignedlong dwthreadid
end type
type startupinfo from structure
unsignedlong cb
string lpreserved
string lpdesktop
string lptitle
unsignedlong dwx
unsignedlong dwy
unsignedlong dwxsize
unsignedlong dwysize
unsignedlong dwxcountchars
unsignedlong dwycountchars
unsignedlong dwfillattribute
unsignedlong dwflags
unsignedlong wshowwindow
unsignedlong cbreserved2
string lpreserved2
unsignedlong hstdinput
unsignedlong hstdoutput
unsignedlong hstderror
end type
------解决方案--------------------
把想返回的写到文件再读.
------解决方案--------------------
不行的。可以用文件或注册表方式处理。
------解决方案--------------------
写了一个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
unsignedlong hprocess
unsignedlong hthread
unsignedlong dwprocessid
unsignedlong dwthreadid
end type
type startupinfo from structure
unsignedlong cb
string lpreserved
string lpdesktop
string lptitle
unsignedlong dwx
unsignedlong dwy
unsignedlong dwxsize
unsignedlong dwysize
unsignedlong dwxcountchars
unsignedlong dwycountchars
unsignedlong dwfillattribute
unsignedlong dwflags
unsignedlong wshowwindow
unsignedlong cbreserved2
string lpreserved2
unsignedlong hstdinput
unsignedlong hstdoutput
unsignedlong hstderror
end type
------解决方案--------------------
把想返回的写到文件再读.
------解决方案--------------------
不行的。可以用文件或注册表方式处理。
------解决方案--------------------