http://msdn.microsoft.com/en-us/library/windows/desktop/bb776891(v=vs.85).aspx
#include "stdafx.h"
#include "shortcut.h"
#include "winnls.h"
#include "Shobjidl.h"
#include "Shlobj.h"
#include "shlguid.h"
void Shortcut::make(const wxString& link_filename, const wxString& arg) {
wxString exe_path = wxStandardPaths().GetExecutablePath();
wxString link_path = wxFileName(wxStandardPaths::MSWGetShellDir(CSIDL_DESKTOP), link_filename).GetFullPath();
com_ptr<IShellLinkW> shell_link;
HRESULT hr = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLinkW, (void**)&*shell_link);
if (FAILED(hr)) {
stringstream ss;
ss << "Shortcut.make() fail to CoCreateInstance for IID_IShellLinkW. HRESULT : " << hr;
throw runtime_error(ss.str());
}
shell_link->SetPath(exe_path.wc_str());
shell_link->SetArguments(arg.wc_str());
//shell_link->SetDescription(desc.wc_str());
//shell_link->SetIconLocation(icon_path, 0);
com_ptr<IPersistFile> persist_file;
hr = shell_link->QueryInterface(IID_IPersistFile, (void**)&*persist_file);
if (FAILED(hr)) {
stringstream ss;
ss << "Shortcut.make() fail to QueryInterface for IID_IPersistFile. HRESULT : " << hr;
throw runtime_error("");
}
hr = persist_file->Save(link_path.wc_str(), TRUE);
if (FAILED(hr)) {
return;
}
}
'C++' 카테고리의 다른 글
wxColour #FF000000 - 알파 인식여부 확인 (0) | 2012.07.11 |
---|---|
wxRegEx 사용하여 특정 문자 치환 (0) | 2012.07.11 |
std::regex (0) | 2012.07.05 |
atlconv.h code page 관련 (0) | 2012.07.04 |
c++ cookie 읽기 (0) | 2012.06.26 |
7z LZMA sdk 윈도우 visual studio 컴파일 (0) | 2012.06.26 |
GUI : Windows 7 부터 지원되는 TaskBar progress bar (0) | 2012.06.22 |
WINDOWS-1251 로 인코딩 변환 (0) | 2012.06.13 |