From: Cheng Zhao Date: Mon, 17 Nov 2014 07:53:18 +0000 (+0800) Subject: win: Implement Browser::AddRecentDocument X-Git-Tag: v0.19.3~1^2~14 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=78322b5231a049a49b25c3b30bef2bd5e1005ee2;p=electron.git win: Implement Browser::AddRecentDocument --- diff --git a/atom/browser/browser_win.cc b/atom/browser/browser_win.cc index 4d90933a..85be2d32 100644 --- a/atom/browser/browser_win.cc +++ b/atom/browser/browser_win.cc @@ -4,14 +4,19 @@ #include "atom/browser/browser.h" +#include #include +#include +#include #include "base/base_paths.h" #include "base/file_version_info.h" #include "base/files/file_path.h" #include "base/memory/scoped_ptr.h" #include "base/path_service.h" +#include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "base/win/windows_version.h" #include "atom/common/atom_version.h" namespace atom { @@ -40,6 +45,18 @@ void Browser::Focus() { } void Browser::AddRecentDocument(const base::FilePath& path) { + if (base::win::GetVersion() < base::win::VERSION_WIN7) + return; + + CComPtr item; + HRESULT hr = SHCreateItemFromParsingName( + path.value().c_str(), NULL, IID_PPV_ARGS(&item)); + if (SUCCEEDED(hr)) { + SHARDAPPIDINFO info; + info.psi = item; + info.pszAppID = L"Atom"; + SHAddToRecentDocs(SHARD_APPIDINFO, &info); + } } std::string Browser::GetExecutableFileVersion() const {