【困惑】CreateProcess创建的进程无法访问网络,Shell的确可以

TimLee✿ 2009-03-17 02:14:30
试过包括IE在内的几个程序都不行..真是奇怪了,Shell起来的没问题....
我OD了一下,发现Shell后来调用的是kernel32.CreateProcessW,参数就更奇怪了...

0012F420 00000000 |ModuleFileName = NULL
0012F424 0015E464 |CommandLine = "C:\Program Files\Internet Explorer\iexplore.exe"
0012F428 00000000 |pProcessSecurity = NULL
0012F42C 00000000 |pThreadSecurity = NULL
0012F430 00000000 |InheritHandles = FALSE
0012F434 00000000 |CreationFlags = 0
0012F438 00000000 |pEnvironment = NULL
0012F43C 00000000 |CurrentDir = NULL <---这个工作目录竟然是Null
0012F440 0012F454 |pStartupInfo = 0012F454
0012F444 0012F498 \pProcessInfo = 0012F498



代码如下....

Option Explicit
Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As SECURITY_ATTRIBUTES, lpThreadAttributes As SECURITY_ATTRIBUTES, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Type PROCESS_INFORMATION '该结构用于容纳新进程的进程和线程标识符
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type

Private Type STARTUPINFO 'STARTUPINFO结构,其中包含了创建进程时使用的附加信息
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type


Private Type SECURITY_ATTRIBUTES '该参数定义了进程的安全特性
nLength As Long
lpSecurityDescriptor As Long
bInheritHandle As Long
End Type


Private Sub Command1_Click()
Dim psa As SECURITY_ATTRIBUTES
Dim tsa As SECURITY_ATTRIBUTES
Dim sinfo As STARTUPINFO
Dim pinfo As PROCESS_INFORMATION
CreateProcess vbNullString, "C:\Program Files\Internet Explorer\iexplore.exe", psa, tsa, 0, 0, 0&, "C:\Program Files\Internet Explorer\", sinfo, pinfo
End Sub

...全文
152 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
TimLee✿ 2009-03-18
  • 打赏
  • 举报
回复
http://support.microsoft.com/Default.aspx?kbid=129797
在ms上找到这个文章,就等着有个人来回答然后结贴呢.....
都是那破API浏览器干的好事.....参数问题....唉..
chenhui530 2009-03-17
  • 打赏
  • 举报
回复
Option Explicit
Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, ByVal lpCommandLine As String, lpProcessAttributes As any, lpThreadAttributes As any, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, lpEnvironment As Any, ByVal lpCurrentDriectory As String, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long
Private Type PROCESS_INFORMATION '该结构用于容纳新进程的进程和线程标识符
hProcess As Long
hThread As Long
dwProcessId As Long
dwThreadId As Long
End Type

Private Type STARTUPINFO 'STARTUPINFO结构,其中包含了创建进程时使用的附加信息
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Byte
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type




Private Sub Command1_Click()
Dim psa As SECURITY_ATTRIBUTES
Dim tsa As SECURITY_ATTRIBUTES
Dim sinfo As STARTUPINFO
Dim pinfo As PROCESS_INFORMATION
sinfo.cb=lenb(sinfo )
CreateProcess vbNullString, "C:\Program Files\Internet Explorer\iexplore.exe", byval 0&, byval 0&, 0, 0,byval 0&, VbNullString, sinfo, pinfo
End Sub

1,488

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧