如何以编程方式查询Windows控制面板? [英] How to query Windows Control Panel Programmatically?

查看:137
本文介绍了如何以编程方式查询Windows控制面板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在整个Windows控制面板中搜索C ++ MFC中的字符串(就像从开始菜单或控制面板资源管理器中进行Windows搜索一样),有人可以帮助我吗?

I need to search the entire Windows Control Panel for a string (just like windows search from start menu or control panel explorer) in C++ MFC, anyone could help me?

我已经尝试在控制面板虚拟文件夹中搜索,但是不起作用...

I've already tried to search within the control panel virtual folder but doesn't work...

现在可以使用!但前提是必须遵守适当的平台(x86或x64)(x86在x64 SO上不起作用)

It Works NOW! but only if compliled to the proper plataform (x86 or x64) (x86 dosen't work on x64 SO)

void CSearchView::BuildControlPanelCache()
{
    CComPtr<IShellFolder> pDesktop;
    SHGetDesktopFolder(&pDesktop);
    PIDLIST_ABSOLUTE path;
    SHGetKnownFolderIDList(FOLDERID_ControlPanelFolder,0,NULL,&path);
    CComPtr<IShellFolder> pFolder;
    pDesktop->BindToObject(path,NULL,IID_IShellFolder,(void**)&pFolder);

    ILFree(path);

    CComPtr<IEnumIDList> pEnum;
    if (pFolder->EnumObjects(NULL,SHCONTF_NONFOLDERS|SHCONTF_FOLDERS,&pEnum)!=S_OK) pEnum=NULL;
    if (!pEnum) return;

    PITEMID_CHILD pidl;
    while (pEnum->Next(1,&pidl,NULL)==S_OK)
    {
      STRRET strDispName;

        if( pFolder->GetDisplayNameOf(pidl, SHGDN_NORMAL, &strDispName) == S_OK )
        { 
              CComPtr<IQueryInfo> pLink;
              if (SUCCEEDED(pFolder->GetUIObjectOf(NULL,1,(PCITEMID_CHILD*) &pidl,IID_IQueryInfo,NULL,(void**)&pLink)))
              {
                    TCHAR *pwszTip; 
                    pLink->GetInfoTip( 0, &pwszTip ); 
                    if ( pwszTip ) 
                          { 
                                SHFree( pwszTip ); 
                          } 
                    //pLink->Release();           
              }
        }

        ILFree(pidl);
    }
}

似乎可以解决问题! Ty Guys!

It seems to do the trick! Ty Guys!

推荐答案

您可以枚举所有控制面板项目并搜索您要寻找的项目,请尝试

You can enumerate all the control panel items and search for the one which you are looking for try this and this

这篇关于如何以编程方式查询Windows控制面板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆