On my NT machine, I've the following vb code which will call winapi "CreateProcess" to run another program, say ProgramA. ProgramA is vb program that uses a com object to create a socket(tcp/ip) connection to a server.
The problem is this indirect process causes the socket() , c++ function, return socket error:10106. When I run the ProgramA alone by double click on it, then the socket can be created just fine.
I think I've provided some incorrect arguement for the "CreateProcess" api which caused the socket(..) function (in programA) return error:10106.
here are the function which will call "CreateProcess"
Public Function ExecShell(ByVal App As String, ByVal WorkDir As String, dwMilliseconds As Long, ByVal start_size As enSW, ByVal Priority_Class As enPriority_Class) As Boolean
Dim pclass As Long
Dim sinfo As STARTUPINFO
Dim pinfo As PROCESS_INFORMATION
'Not used, but needed
Dim sec1 As SECURITY_ATTRIBUTES
Dim sec2 As SECURITY_ATTRIBUTES
sec1.nLength = Len(sec1)
sec2.nLength = Len(sec2)
sinfo.cb = Len(sinfo)
sinfo.dwFlags = STARTF_USESHOWWINDOW
sinfo.wShowWindow = start_size
pclass = Priority_Class
'Start the program
If CreateProcess(vbNullString, App, sec1, sec2, False, pclass, _
0&, WorkDir, sinfo, pinfo) Then
WaitForSingleObject pinfo.hProcess, dwMilliseconds
ExecShell = True
ExecShell = False
some where is the main vb program, I call the function
ExecShell "ProgramA.exe", "C:\", 0, SW_NORMAL, NORMAL_PRIORITY_CLASS
I doubt it might because I've incorrectly set the Security_Attributes of the "CreateProcess" api , these arguements are ignore on win95/98/me, but not on WinNT.