SetQueryNetSessionCount function

Returns the current net session count.

Syntax

long WINAPI SetQueryNetSessionCount(
   DWORD dwSessionOp
);

Parameters

  • dwSessionOp
    The session operation associated with the function call.

    Value Meaning
    SESSION_QUERY 0

    Returns the current net session count

    SESSION_INCREMENT 1

    Not currently supported.

    SESSION_DECREMENT 2

    Not currently supported.

Return value

Current number of web browser control sessions

Remarks

The net session count tracks the number of instances of the web browser control. When a web browser control is created, the net session count is incremented. When the control is destroyed, the net session count is decremented. When the net session count reaches zero, the session cookies for the process are cleared.

SetQueryNetSessionCount can be used to prevent the session cookies from being cleared for applications where web browser controls are being created and destroyed throughout the lifetime of the application. (Because the application lives longer than a given instance, session cookies must be retained for a longer periods of time.)

Examples

This example shows how to use LoadLibrary and GetProcAddress to load and call SetQueryNetSessionCount.

enum SessionOp
{
       SESSION_QUERY = 0,
       SESSION_INCREMENT,
       SESSION_DECREMENT,
};

typedef long WINAPI PFN_SETQUERYNETSESSIONCOUNT(SessionOp Op);

long IncrementNetSessionCount()
{
       long cSessions = 0;

       HMODULE hModule = LoadLibrary(L"ieframe.dll");
       if (hModule != NULL)
       {
              PFN_SETQUERYNETSESSIONCOUNT* pfnSetQueryNetSessionCount =
                     (PFN_SETQUERYNETSESSIONCOUNT*) GetProcAddress(hModule, "SetQueryNetSessionCount");
              if (pfnSetQueryNetSessionCount != NULL)
              {
                     cSessions = pfnSetQueryNetSessionCount(SESSION_INCREMENT);
              }
              FreeLibrary(hModule);
       }

       return cSessions;
}

Requirements

Minimum supported client

Windows 7

Minimum supported server

Windows Server 2008 R2

Header

None

Library

None

DLL

Ieframe.dll