IELaunchURL Function

Opens a URL in an Windows Internet Explorer process with an appropriate integrity level, and returns information about the new process.

Syntax

HRESULT IELaunchURL(      
    LPCWSTR pszUrl,     LPPROCESS_INFORMATION pProcInfo,     LPIELAUNCHURL lpInfo );

Parameters

pszUrl
[in] A pointer to a NULL-terminated string containing the URL to be opened. If this parameter is NULL, the user's home page is opened.
pProcInfo
[in] A pointer to a PROCESS_INFORMATION structure that receives information about the process.
lpInfo
[in] A pointer to an IELAUNCHURLINFO structure; can be NULL.

Return Value

Returns S_OK if the URL is sucessfully opened in a new Internet Explorer process, or an error value otherwise.

Example

The following example shows a function that opens Internet Explorer processes with an appropriate integrity level.

HRESULT LaunchIE(LPCWSTR pszURL)
{
    PROCESS_INFORMATION procInfo;
    procInfo.cbSize = sizeof(PROCESS_INFORMATION);
    procInfo.dwCreationFlags = NULL;    

    IELAUNCHURLINFO launchInfo;
    launchInfo.cbSize = sizeof(IELAUNCHURLINFO);
    launchInfo.dwCreationFlags = NULL;

    HRESULT hr = IELaunchURL(pszURL, &procInfo, &launchInfo);
    if (SUCCEEDED(hr))
    {
        WaitForInputIdle(procInfo.hProcess, 2000);
        CloseHandle(procInfo.hProcess);
        CloseHandle(procInfo.hThread);
    }
    return hr;
}

Function Information

Stock Implementationieframe.dll
Custom ImplementationNo
Headeriepmapi.h
Import libraryiepmapi.lib
Minimum availabilityInternet Explorer 7
Minimum operating systems Windows Vista
Tags :


Community Content

Gu0sur20
Issue with given example
Beware, PROCESS_INFORMATION has no member named dwCreationFlags nor cbSize. These lines should be omited.
Tags : contentbug

EricLaw-MSFT
Fail to return correct PID

Response from EricLaw[MSFT]: It's important to understand the IE8 includes a new multi-process architecture called Loosely Coupled IE. The IELaunchURL API should be returning the process ID of the "tab process" spawned by IELaunchURL, and not the PID of the parent "frame process" into which that tab process was created. This was a deliberate design decision, because callers are typically interested in the tab process ID, not the parent window.


Internet Explorer 8, Haven't tested previous versions.

IELaunchURL , CreateProcess, Shell, Process.Start all return the wrong PID in some situations. Atleast on my system if there is more than one instance open or attempting to launch multiple instance will return the wrong PID. However it works fine if and only it's the first instance that will be opened on the system. In some cases the returned pid doesn't even exist.

So what gives here? It seems that iexplorer.exe is actually calling iexplorer.exe again and using the other processid from the spawned instance. But it does this in a way that you don't even notice another process actually spawning it seems it terminates almost immediatley.

How do you return the correct pid for that instance, haven't found a solution yet. What does work is Enumerate the windows but this is after the fact so there isn't any real relationship to know which instance you just spawned, only that you can find out which instances are available.

Tags : contentbug

Page view tracker