{
wstring wstrDefBrowserPos = wszBuffer;
wstrDefBrowserPos += L"\\shell\\open\\command\\";
dwDataSize = sizeof(wszBuffer);
if (ERROR_SUCCESS == ::RegGetValueW(
HKEY_CLASSES_ROOT,
wstrDefBrowserPos.c_str(),
NULL,
RRF_RT_REG_SZ,
0,
wszBuffer,
&dwDataSize
))
{
// 解出exe 路径.
wstrDefBrowserPath = wszBuffer;
wstring::size_type leftQuotation = wstrDefBrowserPath.find(L'"');
if (leftQuotation != wstring::npos)
{
wstring::size_type rightQuotation = wstrDefBrowserPath.find(L'"', leftQuotation + 1);
if (rightQuotation != wstring::npos)
{
wstrDefBrowserPath.assign(
wstrDefBrowserPath.begin() + leftQuotation + 1,
wstrDefBrowserPath.begin() + rightQuotation
);
}
}
}
}
::ShellExecuteW(
NULL,
L"open",
wstrDefBrowserPath.c_str(),
NULL,
NULL,
SW_NORMAL
);
}
整个过程比较繁琐,但还是比较容易理解的。