Last modified: July 23, 2011

Applies to: Outlook

Opens a section of the current profile and returns an IProfSect pointer for further access.

HRESULT OpenProfileSection(
  LPCIID lpInterface,
  ULONG ulFlags,
  LPPROFSECT FAR * lppProfSect


A pointer to the MAPIUID structure that identifies the profile section.


[in] A pointer to the interface identifier (IID) that represents the interface to be used to access the profile section. Passing NULL results in a pointer to its standard interface being returned in the lppProfSect parameter. The standard interface for a profile section is IProfSect.


[in] A bitmask of flags that controls access to the profile section. The following flags can be set:


Allows OpenProfileSection to return successfully, possibly before the profile section is fully available to the calling client. If the profile section is not available, making a subsequent call to it can raise an error.


Requests read/write permission. By default, profile sections are opened with read-only permission, and clients should not work on the assumption that read/write permission has been granted.


Allows access to all profile sections, even those owned by individual service providers.


[out] A pointer to a pointer to the profile section.


The profile section was successfully opened.


An attempt was made to access a profile section for which the caller has insufficient permissions.


The requested profile section does not exist.

The IMsgServiceAdmin::OpenProfileSection method opens a profile section, an object that supports the IProfSect interface. Profile sections are used for reading information from and writing information to the session profile.

OpenProfileSection cannot be used to open profile sections owned by individual service providers unless MAPI_FORCE_ACCESS is used.

Multiple clients can open a profile section with read-only permission, but only one client can open a profile section with read/write permission. If another client has a profile section open that you attempt to open by calling OpenProfileSection with the MAPI_MODIFY flag set, the call will fail, returning MAPI_E_NO_ACCESS.

A read-only open operation fails if the section is open for writing.

You can create a profile section by calling OpenProfileSection with the MAPI_MODIFY flag and a nonexistent MAPIUID structure in the lpUID parameter. Be sure you specify MAPI_MODIFY. If you set lpUID to point to a nonexistent MAPIUID and OpenProfileSection is set to use the default access mode of read-only, the call will fail with MAPI_E_NOT_FOUND.

For MFCMAPI sample code, see the following table.






MFCMAPI uses the IMsgServiceAdmin::OpenProfileSection method to open a profile section.