设为首页 加入收藏

TOP

VC获取默认浏览器(二)
2013-05-03 18:11:17 来源: 作者: 【 】 浏览:122
Tags:获取 默认 浏览器

 

  {

  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

  );

  }

  整个过程比较繁琐,但还是比较容易理解的。

      

首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇尽量使用C++风格的类型转换 下一篇VC++网络编程-文件传输

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: