匯出 (0) 列印
全部展開
EN
本內容沒有您的語言版本,但有英文版本。
2 人當中有 2 人評分為有幫助- 為這個主題評分

IOpenControlPanel::GetPath method

Gets the registry path of a specified Control Panel item.

Syntax


HRESULT GetPath(
  [in]   LPCWSTR pszName,
  [out]  LPWSTR pszPath,
  [in]   UINT cchPath
);

Parameters

pszName [in]

Type: LPCWSTR

A pointer to the item's canonical name or its GUID. This value can be NULL. See Remarks for further details. For a list of Control Panel item canonical names, see Canonical Names of Control Panel Items.

pszPath [out]

Type: LPWSTR

When this method returns successfully, points to the registry path of the specified Control Panel item as a Unicode string.

If pszName points to the item's canonical name or GUID, then the path returned is slightly different depending on the most recent Control Panel view.

If the Control Panel was last displayed in Category view, the path string is in this form. The categoryID is the item's System.ControlPanel.Category entry, declared as part of its registry settings. In that entry, a Control Panel item can be associated with multiple categories. In that case, the categoryID returned here is the first one in the list.


::{CLSID_ControlPanel}\\categoryID\\::{item GUID}

If the Control Panel was last displayed in Large items or Small items view, the path string is in this form:


::{CLSID_ControlPanel}\\0\\::{item guid}

If pszName is NULL and the Control Panel was last displayed in Category view, then the path is returned in this form:


::{CLSID_ControlPanel}

If pszName is NULL and the Control Panel was last displayed in Large items or Small items view, then the path is returned in this form:


::{CLSID_ControlPanel}\\0

cchPath [in]

Type: UINT

The size of the buffer pointed to by pszPath, in WCHARs.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Examples

This code shows the creation of the IOpenControlPanel object and a call to its GetPath method to retrieve the path of the Windows Update item in the Control Panel.



const WCHAR* szItemName = L"Microsoft.WindowsUpdate";
HRESULT hr = S_OK;

hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if (SUCCEEDED(hr))
{
    IOpenControlPanel *pocp;

    hr = CoCreateInstance(CLSID_OpenControlPanel, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pocp));
    if (SUCCEEDED(hr))
    {
        WCHAR szPath[MAX_PATH];

        hr = pocp->GetPath(szItemName, szPath, ARRAYSIZE(szPath));
        if (SUCCEEDED(hr))
        {
            // Do something with the result.
        }
    }

    pocp->Release();
}

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Shobjidl.h

IDL

Shobjidl.idl

See also

IOpenControlPanel

 

 

本文對您有任何幫助嗎?
(剩餘 1500 個字元)
感謝您提供意見

社群新增項目

新增
顯示:
© 2014 Microsoft. 著作權所有,並保留一切權利。