Win7下获取资源管理器地址栏文件夹路径

以下示例操作:若为C:计算机\知库同步盘,则关闭

// gAppIsWindowsVistaOrHigher()自己写的判断函数,可参考VC分类下的获取当前系统全文
if (gAppIsWindowsVistaOrHigher())
{
    HWND hwndAddressBandRoot= 0;
    HWND hwndmsctls_progress32= 0;
    HWND hwndBreadcrumbParentt= 0;
    HWND hwndToolbarWindow32= 0;
    NOT_NULL((hwndAddressBandRoot = ::FindWindowExW(hwndReBarWindow32, NULL, L"Address Band Root", NULL)));
    NOT_NULL((hwndmsctls_progress32 = ::FindWindowExW(hwndAddressBandRoot, NULL, L"msctls_progress32", NULL)));
    NOT_NULL((hwndBreadcrumbParentt = ::FindWindowExW(hwndmsctls_progress32, NULL, L"Breadcrumb Parent", NULL)));
    NOT_NULL((hwndToolbarWindow32 = ::FindWindowExW(hwndBreadcrumbParentt, NULL, L"ToolbarWindow32", NULL)));

    {
        TCHAR wcAddr[MAX_PATH+1] = {0};
        SendMessage(hwndToolbarWindow32, WM_GETTEXT, MAX_PATH, (LPARAM)wcAddr);
        QString szAddr = QString::fromUtf16(wcAddr);

        if (szAddr.startsWith("地址: ") && szAddr.endsWith("\\知库同步盘") && szAddr.count(":")==1)
        {
            SendMessage(hwndCabinet, WM_CLOSE, NULL, NULL);
        }
    }
}

 

posted @ 2014-10-18 15:00  纠纠结结  阅读(733)  评论(0编辑  收藏  举报