Hi.
I tired to enumerate trough all cookie files to get paths to each cookie. I used SHGetPathFromIDList() to retrieve the paths.
The problem is that I receive all the paths, as the cookies are existing on the desktop. It’s something like this:
Code:
C: Documant and Settings\username\Desktop\cookie file1.txt
C: Documant and Settings\username\Desktop\cookie file2.txt
C: Documant and Settings\username\Desktop\cookie file3.txt
while the actual path is something like :
Code:
C:\Documents and Settings\username\Cookies\cookie file1.txt
So I tried to get to other special folders using flags like CSIDL_COMMON_DOCUMENTS, CSIDL_COMMON_FAVORITES, on SHGetSpecialFolderLocation(). But the same thing happened. The paths says that every file’s are on the desktop.
Why is this?
Code:
....................
....................
if(SUCCEEDED(::SHGetSpecialFolderLocation(NULL, CSIDL_COOKIES, &pidlCookieF)))
{
// fetch the ShellFolder interface of the cookie folder
CComPtr<IShellFolder> sfiCookieF;
if(SUCCEEDED(sfiDesktop->BindToObject(
pidlCookieF, // PIDL to sub folder
NULL, // must be NULL
IID_IShellFolder, // just get non-folders
reinterpret_cast<LPVOID*>(&sfiCookieF)))) // buffer
{
// get the enumerator
CComPtr<IEnumIDList> spenumCookie;
if(SUCCEEDED(sfiCookieF->EnumObjects(
NULL, // parent window
SHCONTF_NONFOLDERS, // just get non-folders
&spenumCookie))) // buffer
{
// fetch each PIDL
LPITEMIDLIST pidlCookie = NULL;
int x=0;
char cookiePath[MAX_PATH + 1];
while(spenumCookie->Next(1, &pidlCookie, NULL) == NOERROR)
{
// ******** file operation ************
if (SHGetPathFromIDList (pidlCookie, cookiePath))
{
cookiePath[lstrlen(cookiePath)+1] = '\0';
SHFILEOPSTRUCT fopstruct = { 0 };
fopstruct.hwnd = NULL;
fopstruct.wFunc = FO_COPY;
fopstruct.fFlags = 0;
fopstruct.pFrom = cookiePath;
fopstruct.pTo = "E:\\cookies\0";
BOOL foCheck = SHFileOperation (&fopstruct);
if (foCheck)
MessageBox(NULL, "SHFileOperation failed!", NULL, MB_ICONSTOP);
}
.....................
.....................
Thanks.