rai002 @ ウィキ
.lnkの情報取得
最終更新:
rai002
-
view
.lin の情報取得
参考:URL
http://hp.vector.co.jp/authors/VA016117/shortcut.html
http://yokohama.cool.ne.jp/chokuto/urawaza/com/shell.html
http://yokohama.cool.ne.jp/chokuto/urawaza/com/shell2.html
http://www.kis-lab.com/serikashiki/VC/VC02.html
http://hp.vector.co.jp/authors/VA016117/shortcut.html
http://yokohama.cool.ne.jp/chokuto/urawaza/com/shell.html
http://yokohama.cool.ne.jp/chokuto/urawaza/com/shell2.html
http://www.kis-lab.com/serikashiki/VC/VC02.html
重要:URL
http://www.kab-studio.biz/Programing/Codian/ShellExtension/09.html
http://yokohama.cool.ne.jp/chokuto/urawaza/interface/IShellLink/GetPath.html
http://www.kab-studio.biz/Programing/Codian/ShellExtension/09.html
http://yokohama.cool.ne.jp/chokuto/urawaza/interface/IShellLink/GetPath.html
以下プログラム
//**********************************************************************
// ショートカットの情報を取得し返す
// インクルードファイル:
// locale.h
// .Net Framework 2.0 以上で利用可能
// [引数]:ショートカへのアドレス( string original_URL)
// [戻値]:ショートカットの中身のアドレス( string link_URL)
//**********************************************************************
string get_dir::Get_Short_Cut_link_Info( string original_URL )
{
string link_URL; //ショートカット中身アドレス
//メンバ変数初期化
IShellLink *ShLinkInterface = NULL;
IPersistFile *PerFileInterface = NULL;
HRESULT result; //各結果
//初期化
::CoInitialize(NULL);
::CoCreateInstance(
CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
IID_IShellLink, (void **)&ShLinkInterface
);
ShLinkInterface->QueryInterface(
IID_IPersistFile, (void **)&PerFileInterface
);
//ユニコードに変換
OLECHAR ochLinkFile[ MAX_PATH_NAME ];
::MultiByteToWideChar(
CP_ACP, MB_PRECOMPOSED, original_URL.c_str(), -1,
ochLinkFile, MAX_PATH_NAME
);
//ショートカットの読み出し
result = PerFileInterface->Load( ochLinkFile, STGM_READ);
wchar_t temp[MAX_PATH_NAME];
if( result == S_OK ){
ShLinkInterface->Resolve( NULL, SLR_UPDATE );
ShLinkInterface->GetPath( temp , MAX_PATH_NAME, NULL, SLGP_UNCPRIORITY);
}else{
}
//後処理
PerFileInterface->Release();
if( ShLinkInterface ) ShLinkInterface->Release();
::CoUninitialize();
// wchar_t を string に変換
setlocale( LC_ALL, "japanese" );
char c_temp[MAX_PATH_NAME];
size_t wlen=0;
wcstombs_s( &wlen, c_temp, MAX_PATH_NAME, temp, _TRUNCATE);
link_URL = c_temp;
return link_URL;
}