IMFAudioPolicy::SetIconPath method (mfidl.h)
Sets the icon resource for the audio session. The Windows volume control displays this icon.
Syntax
HRESULT SetIconPath(
[in] LPCWSTR pszPath
);
Parameters
[in] pszPath
A wide-character string that specifies the icon. See Remarks.
Return value
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
Remarks
The icon path has the format "path,index" or "path,-id", where path is the fully qualified path to a DLL, executable file, or icon file; index is the zero-based index of the icon within the file; and id is a resource identifier. Note that resource identifiers are preceded by a minus sign (-) to distinguish them from indexes. The path can contain environment variables, such as "%windir%". For more information, see IAudioSessionControl::SetIconPath in the Windows SDK.
Examples
The following example sets the icon using a resource identifier for an icon in the application's executable file.
HRESULT SetIcon(IMFMediaSession *pSession, int nID)
{
IMFAudioPolicy *pPolicy = NULL;
const DWORD CCH_ICON_PATH = MAX_PATH + 16;
WCHAR szFileName[MAX_PATH];
WCHAR szIconPath[CCH_ICON_PATH];
HRESULT hr = S_OK;
DWORD result = GetModuleFileNameW(NULL, szFileName, MAX_PATH);
// Note: GetModuleFileName can return a truncated string without a
// NULL terminator. If so, the function succeeds but sets the last
// error to ERROR_INSUFFICIENT_BUFFER.
if ((result == 0) || (GetLastError() == ERROR_INSUFFICIENT_BUFFER))
{
hr = E_FAIL;
goto done;
}
hr = StringCchPrintfW(szIconPath, CCH_ICON_PATH,
L"%s,-%d", szFileName, nID);
if (FAILED(hr))
{
goto done;
}
hr = MFGetService(
pSession,
MR_AUDIO_POLICY_SERVICE,
IID_PPV_ARGS(&pPolicy)
);
if (FAILED(hr))
{
goto done;
}
hr = pPolicy->SetIconPath(szIconPath);
if (FAILED(hr))
{
goto done;
}
done:
SafeRelease(&pPolicy);
return hr;
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista [desktop apps only] |
Minimum supported server | Windows Server 2008 [desktop apps only] |
Target Platform | Windows |
Header | mfidl.h |
Library | Mfuuid.lib |