아래 링크된 페이지를 보고 간단히 코딩해 봤습니다.
http://cbuilder.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_tip&no=438
http://blog.naver.com/shin5341/80036285583
void __fastcall TForm1::Button2Click(TObject *Sender)
{
if(OpenDialog1->Execute())
{
Edit1->Text=OpenDialog1->FileName;
if(CheckLinkFile(OpenDialog1->FileName))ShowMessage("바로가기 파일 있음");
else ShowMessage("바로가기 파일 없음");
}
}
//---------------------------------------------------------------------------
#define FVSHOWINFO xxFVSHOWINFOxx
#define FOLDERSETTINGS xxFOLDERSETTINGSxx
#define DESKBANDINFO xxDESKBANDINFOxx
#define SHELLFLAGSTATE xxSHELLFLAGSTATExx
#include <shlobj.h>
bool __fastcall TForm1::CheckLinkFile(String sLinkFName)
{
HRESULT hres;
IShellLink *pLink;
char szGotPath[MAX_PATH];
WIN32_FIND_DATA wfd;
bool bResult=false;
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **) &pLink);
if(SUCCEEDED(hres))
{
IPersistFile* pPersistFile;
hres=pLink->QueryInterface(IID_IPersistFile, (void **) &pPersistFile);
if(SUCCEEDED(hres))
{
WideString wsLinkFName(sLinkFName);
if(SUCCEEDED(pPersistFile->Load(wsLinkFName.c_bstr(),STGM_READ)))
{
if(SUCCEEDED(pLink->Resolve(Handle,0)))
{
pLink->GetPath(szGotPath,MAX_PATH,(WIN32_FIND_DATA *)&wfd,2);
ShowMessage(szGotPath);
if(FileExists(szGotPath))bResult=true;
}
}
}
pPersistFile->Release();
}
pLink->Release();
return bResult;
}
//---------------------------------------------------------------------------
그럼....
ugotme 님이 쓰신 글 :
: 바로가기(.LNK) 파일의 연결상태 확인(깨진파일 여부확인)
:
: a.LNK 라는 바로가기 파일의 해당 경로가 실제로 존재하는 파일인지,
: 아니면 원본파일이 존재하지 않는지 확인하는 방법이 있을까요?
:
: 제가 이걸 구현해야 하는데 어려움을 겪고 있어서,
: 정말 어렵네요ㅡㅡ;;;