奇怪错误问题50分求解
spdia 2001-02-18 11:29:00 #include<comdef.h>
::CoInitialize(NULL);
LPSTR URLpath;
IUniformResourceLocatorA * pURL;
IPersistFile * ppf;
HRESULT hr = ::CoCreateInstance(CLSID_InternetShortcut,
NULL,CLSCTX_INPROC_SERVER,
IID_IUniformResourceLocatorA,
(void * *)&pURL);
//HRESULT hr = pURL.CreateInstance(CLSID_InternetShortcut);
if(SUCCEEDED(hr))
{
hr = pURL->QueryInterface(IID_IPersistFile,(void * *)&ppf);
//此句出错错误信息为
//error C2027: use of undefined type 'IUniformResourceLocatorA'
//但comdef.h中有此定义,为什么?
if(SUCCEEDED(hr))
{
_bstr_t bstrfilename(filename.AllocSysString(),false);
ppf->Load(bstrfilename,STGM_READ);
ppf->Release();
pURL->GetURL(&URLpath);
URLpath.ReleaseBuffer();
pURL->Release();
}
}
::CoUninitialize();
CString returnpath(URLpath);
delete URLpath;
return returnpath;