I need immediate help to launch iexplore using CreateProcess, then through next command button pinfo.dwThreadId to find Active or not

VB form has 3 command buttons

first command button
lngRetValue = CreateProcess(vbNullString, "c:\program files (x86)\internet explorer\iexplore.exe", sec1, sec2, False, pclass, 0&, "C:\", sinfo, pinfo)
hnd = pinfo.dwThreadId

It launching a new iexplore only when existing iexplore is there and I'm getting dwthreadid but when I transfer hwnd to threadid always shows same wrong id.
ThreadID = hnd
lhWnd = FindWindowEx(AddressOf EnumThreadWndActive, lhWnd, "IEFrame", vbNullString)
pid = GetWindowThreadProcessId(hwnd, lpId)

and tried with below code also

If GetWindowThreadProcessId(lhWnd, tId) <> 0 Then 'Get the window's thread id
If tId = pid Then InstanceToWnd = hwnd: ' If pid matches then exit
End If

Expected the foll.functionality:
I wanted to open iexplore and when ever ipress the button next next iexplore should be open with different threadid using createprocess.

In next command button based on that threadid I wanted to check whether iexplore window is active or not and another 3rd command button to close the particular Active iexplore based on threadid.