CInternetSession::CInternetSession

CInternetSession( LPCTSTR pstrAgent = NULL, DWORD dwContext = 1, DWORD dwAccessType = INTERNET_OPEN_TYPE_PRECONFIG, LPCTSTR pstrProxyName = NULL, LPCTSTR pstrProxyBypass = NULL, DWORD dwFlags = 0 );

Parameters

pstrAgent

A pointer to a string that identifies the name of the application or entity calling the Internet functions (for example, "Microsoft Internet Browser"). If pstrAgent is NULL (the default), the framework calls the global function AfxGetAppName, which returns a null-terminated string containing an application’s name. Some protocols use this string to identify your application to the server.

dwContext

The context identifier for the operation. dwContext identifies the operation’s status information returned by CInternetSession::OnStatusCallback. The default is set to 1; however, you can explicitly assign a specific context ID for the operation. The object and any work it does will be associated with that context ID. If dwFlags includes INTERNET_FLAG_ASYNC, then objects created by this object have asynchronous behavior as long as a status callback routine is registered. In order for a function to be completed synchronously, dwContext has to be set to zero for that call.

dwAccessType

The type of access required. The following are valid values, exactly one of which may be supplied:

pstrProxyName

The name of the preferred CERN proxy if dwAccessType is set as INTERNET_OPEN_TYPE_PROXY. The default is NULL.

pstrProxyBypass

A pointer to a string containing an optional list of server addresses. These addresses may be bypassed when using proxy access. If a NULL value is supplied, the bypass list will be read from the registry. This parameter is meaningful only if dwAccessType is set to INTERNET_OPEN_TYPE_PROXY.

dwFlags

Indicates various options such as caching and asynchronous behavior. The default is set to 0. The possible values include:

Remarks

This member function is called when a CInternetSession object is created. CInternetSession is the first Internet function called by an application. It initializes internal data structures and prepares for future calls from the application.

If dwFlags includes INTERNET_FLAG_ASYNC, then all handles derived from this handle will have asynchronous behavior as long as a status callback routine is registered.

If no Internet connection can be opened, CInternetSession throws an AfxThrowInternetException.

CInternetSession OverviewClass MembersHierarchy Chart

See Also   CInternetSession::Close, CInternetSession::EnableStatusCallback, CInternetSession::GetContext