如何使用com组建,得到上网历史记录?
我在网上找了一段代码,可是引用shlobj.h和atlbase.h编译时报错,初学者,不知道如何使用,请各位大哥指导一下
#include <stdio.h>
#include <windows.h>
#include <UrlHist.h> // IUrlHistoryStg2
#include <shlobj.h> // CLSID_CUrlHistory, SHAddToRecentDocs
#include <atlbase.h> // USES_CONVERSION;
void GetIEHistory()
......{
USES_CONVERSION;//Unicode转Ansi用
CoInitialize(NULL); //初始化
IUrlHistoryStg2* pUrlHistoryStg2 = NULL;
HRESULT hr = CoCreateInstance(CLSID_CUrlHistory,
NULL, CLSCTX_INPROC, IID_IUrlHistoryStg2,
(void**)&pUrlHistoryStg2);
/**//**//**//*if (SUCCEEDED(hr))
{
hr = pUrlHistoryStg2->ClearHistory();
pUrlHistoryStg2->Release();
}*/
IEnumSTATURL* pEnumURL;
hr = pUrlHistoryStg2->EnumUrls(&pEnumURL);
STATURL suURL;
ULONG pceltFetched;
suURL.cbSize = sizeof(suURL);
hr = pEnumURL->Reset();
while((hr = pEnumURL->Next(1, &suURL, &pceltFetched)) == S_OK)
......{
//hr = pUrlHistoryStg2->DeleteUrl(suURL.pwcsUrl, 0);
printf("%s ", W2T(suURL.pwcsUrl));
}
pEnumURL->Release();
pUrlHistoryStg2->Release();
CoUninitialize();
}
[解决办法]
工程选项中,incluse path中添加一个:$(BCB)\include\atl