主题:关于CreateProcess的参数lpCommandLine的问题
[size=4]下面是与CreateProcess相关的代码,当下面的COMMANDLINE字符串变量长度声明为30时,程序调用正常,但是当长度为100时,程序调用出错:被调用程序(程序中的CALCULATE_OBJVALUE.EXE)接收到的命令行参数为4个,不是实际的2个。
是参数lpCommandLine方面的问题吗,还请各位指点一下,非常感谢 [/size]
USE DFWIN
integer::ret
type (T_STARTUPINFO) :: StartInfo
type (T_PROCESS_INFORMATION) :: ProcessInfo
CHARACTER(LEN=30)::COMMANDLINE
StartInfo%cb = 68
StartInfo%lpReserved = 0
StartInfo%lpDesktop = NULL
StartInfo%lpTitle = NULL
StartInfo%dwX = 0
StartInfo%dwY = 0
StartInfo%dwXSize = 0
StartInfo%dwYSize = 0
StartInfo%dwXCountChars = 0
StartInfo%dwYCountChars = 0
StartInfo%dwFillAttribute = 0
StartInfo%dwFlags = StartF_UseShowWindow
StartInfo%wShowWindow = SW_SHOW
StartInfo%cbReserved2 = 0
StartInfo%lpReserved2 = NULL
INDX=11
COMMANDLINE='CALCULATE_OBJVALUE.EXE '//ACHAR(48+INDX/10)//ACHAR(48+MOD(INDX,10))
ret = CreateProcess (NULL_CHARACTER, & ! Application Name
COMMANDLINE, & ! Command line
NULL_SECURITY_ATTRIBUTES, &
NULL_SECURITY_ATTRIBUTES, &
.TRUE., & ! InheritHandles
CREATE_NEW_CONSOLE, & ! CreationFlags
NULL, & ! Environment variables
NULL_CHARACTER, & ! Current directory
StartInfo, &
ProcessInfo)
ret = WaitForSingleObject (ProcessInfo%hProcess,INFINITE)
ret = CloseHandle (ProcessInfo%hThread)
ret = CloseHandle (ProcessInfo%hProcess)
是参数lpCommandLine方面的问题吗,还请各位指点一下,非常感谢 [/size]
USE DFWIN
integer::ret
type (T_STARTUPINFO) :: StartInfo
type (T_PROCESS_INFORMATION) :: ProcessInfo
CHARACTER(LEN=30)::COMMANDLINE
StartInfo%cb = 68
StartInfo%lpReserved = 0
StartInfo%lpDesktop = NULL
StartInfo%lpTitle = NULL
StartInfo%dwX = 0
StartInfo%dwY = 0
StartInfo%dwXSize = 0
StartInfo%dwYSize = 0
StartInfo%dwXCountChars = 0
StartInfo%dwYCountChars = 0
StartInfo%dwFillAttribute = 0
StartInfo%dwFlags = StartF_UseShowWindow
StartInfo%wShowWindow = SW_SHOW
StartInfo%cbReserved2 = 0
StartInfo%lpReserved2 = NULL
INDX=11
COMMANDLINE='CALCULATE_OBJVALUE.EXE '//ACHAR(48+INDX/10)//ACHAR(48+MOD(INDX,10))
ret = CreateProcess (NULL_CHARACTER, & ! Application Name
COMMANDLINE, & ! Command line
NULL_SECURITY_ATTRIBUTES, &
NULL_SECURITY_ATTRIBUTES, &
.TRUE., & ! InheritHandles
CREATE_NEW_CONSOLE, & ! CreationFlags
NULL, & ! Environment variables
NULL_CHARACTER, & ! Current directory
StartInfo, &
ProcessInfo)
ret = WaitForSingleObject (ProcessInfo%hProcess,INFINITE)
ret = CloseHandle (ProcessInfo%hThread)
ret = CloseHandle (ProcessInfo%hProcess)