ptmcomp
asked on
-# Internet Explorer creating offline sites #-
I'm trying to create a offline site using the ISubscritpionMgr interface. The site should be synchronized every 12 hours.
I currently got stucked with the code below - I always get an "invalid parameter" error. I've no idea why.
void CSubscriptionMgr::Subcribe URL(CStrin g strURL, CString strFiendlyName, TASK_TRIGGER_TYPE Interval, TRIGGER_TYPE_UNION IntervalSettings, int iStartHour, int iStartMinute)
{
HRESULT hr;
BSTR bstrURL;
BSTR bstrName;
SUBSCRIPTIONINFO sinfo;
TASK_TRIGGER trig;
SYSTEMTIME st;
memset(&sinfo, 0, sizeof(sinfo));
sinfo.cbSize = sizeof(sinfo);
memset(&trig, 0, sizeof(trig));
trig.cbTriggerSize = sizeof(trig);
bstrURL = strURL.AllocSysString();
bstrName = strFiendlyName.AllocSysStr ing();
// Fill in current local date and time
GetLocalTime(&st);
trig.wBeginYear = st.wYear;
trig.wBeginMonth = st.wMonth;
trig.wBeginDay = st.wDay;
trig.wStartHour = iStartHour;
trig.wStartMinute = iStartMinute;
trig.TriggerType = Interval;
trig.Type = IntervalSettings;
sinfo.fUpdateFlags = SUBSINFO_SCHEDULE | SUBSINFO_RECURSE | SUBSINFO_WEBCRAWL | SUBSINFO_TASKFLAGS | SUBSINFO_GLEAM | SUBSINFO_FRIENDLYNAME | SUBSINFO_NEEDPASSWORD | SUBSINFO_TYPE;
sinfo.schedule = SUBSSCHED_WEEKLY; //SUBSSCHED_CUSTOM;
sinfo.pTrigger = &trig;
sinfo.dwRecurseLevels = 3;
sinfo.fWebcrawlerFlags = WEBCRAWL_GET_IMAGES & WEBCRAWL_GET_VIDEOS & WEBCRAWL_GET_BGSOUNDS & WEBCRAWL_GET_CONTROLS;
sinfo.bMailNotification = false;
sinfo.bGleam = true;
sinfo.bChangesOnly = false;
sinfo.bNeedPassword = false;
sinfo.fChannelFlags = 0; //CHANNEL_AGENT_PRECACHE_A LL;
sinfo.bstrFriendlyName = bstrName;
sinfo.dwMaxSizeKB = 500;
sinfo.subType = SUBSTYPE_URL;
sinfo.fTaskFlags = 1040; /////0000000000000
sinfo.dwReserved = 0;
// hr = pSubscriptionMgr->IsSubscr ibed(bstrU RL, &Bool);
hr = pSubscriptionMgr->CreateSu bscription (NULL,
bstrURL,
bstrName,
CREATESUBS_NOUI | CREATESUBS_ADDTOFAVORITES | CREATESUBS_FROMFAVORITES,
SUBSTYPE_URL,
&sinfo);
SysFreeString (bstrURL);
SysFreeString (bstrName);
CheckHResult(hr);
}
I currently got stucked with the code below - I always get an "invalid parameter" error. I've no idea why.
void CSubscriptionMgr::Subcribe
{
HRESULT hr;
BSTR bstrURL;
BSTR bstrName;
SUBSCRIPTIONINFO sinfo;
TASK_TRIGGER trig;
SYSTEMTIME st;
memset(&sinfo, 0, sizeof(sinfo));
sinfo.cbSize = sizeof(sinfo);
memset(&trig, 0, sizeof(trig));
trig.cbTriggerSize = sizeof(trig);
bstrURL = strURL.AllocSysString();
bstrName = strFiendlyName.AllocSysStr
// Fill in current local date and time
GetLocalTime(&st);
trig.wBeginYear = st.wYear;
trig.wBeginMonth = st.wMonth;
trig.wBeginDay = st.wDay;
trig.wStartHour = iStartHour;
trig.wStartMinute = iStartMinute;
trig.TriggerType = Interval;
trig.Type = IntervalSettings;
sinfo.fUpdateFlags = SUBSINFO_SCHEDULE | SUBSINFO_RECURSE | SUBSINFO_WEBCRAWL | SUBSINFO_TASKFLAGS | SUBSINFO_GLEAM | SUBSINFO_FRIENDLYNAME | SUBSINFO_NEEDPASSWORD | SUBSINFO_TYPE;
sinfo.schedule = SUBSSCHED_WEEKLY; //SUBSSCHED_CUSTOM;
sinfo.pTrigger = &trig;
sinfo.dwRecurseLevels = 3;
sinfo.fWebcrawlerFlags = WEBCRAWL_GET_IMAGES & WEBCRAWL_GET_VIDEOS & WEBCRAWL_GET_BGSOUNDS & WEBCRAWL_GET_CONTROLS;
sinfo.bMailNotification = false;
sinfo.bGleam = true;
sinfo.bChangesOnly = false;
sinfo.bNeedPassword = false;
sinfo.fChannelFlags = 0; //CHANNEL_AGENT_PRECACHE_A
sinfo.bstrFriendlyName = bstrName;
sinfo.dwMaxSizeKB = 500;
sinfo.subType = SUBSTYPE_URL;
sinfo.fTaskFlags = 1040; /////0000000000000
sinfo.dwReserved = 0;
// hr = pSubscriptionMgr->IsSubscr
hr = pSubscriptionMgr->CreateSu
bstrURL,
bstrName,
CREATESUBS_NOUI | CREATESUBS_ADDTOFAVORITES | CREATESUBS_FROMFAVORITES,
SUBSTYPE_URL,
&sinfo);
SysFreeString (bstrURL);
SysFreeString (bstrName);
CheckHResult(hr);
}
ASKER
Hi jkr
The MSDN sample above won't work since the trig structure is not correct initialized (cbSize is not set!).
I found out why my code didn't work. Whenever I set the pTrigger pointer, it failed. Actually I worked around by setting everything but the pTrigger pointer. Then I retrieve the cookie CLSID value and enumerate the triggers (ITaskScheduler interface) looking for same CLSID. Then I set the properties through the ITaskItem interface. This works for me. However if someone can tell me how to do this without this workaround, I still offer this 200 points.
The MSDN sample above won't work since the trig structure is not correct initialized (cbSize is not set!).
I found out why my code didn't work. Whenever I set the pTrigger pointer, it failed. Actually I worked around by setting everything but the pTrigger pointer. Then I retrieve the cookie CLSID value and enumerate the triggers (ITaskScheduler interface) looking for same CLSID. Then I set the properties through the ITaskItem interface. This works for me. However if someone can tell me how to do this without this workaround, I still offer this 200 points.
ptmcomp:
You logged in as recently as November, but have not updated/finalized your open questions, many of which are very old. You've asked 20 questions, but only graded/closed 10 of them. I have updated all your open questions with this information so that you can easily navigate through the and finalize them.
Here are the options:
1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.
2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.
3. Ask Community Support to help split points between participating experts. Just comment here with details.
4. Delete the question because it is of no value to you or to anyone else. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.
If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.
PLEASE DO NOT AWARD THE POINTS TO ME.
__________________________ __________ ________
Hi Experts:
In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question. Likewise, you can also suggest that I PAQ or delete the question.
Experts, please do not add further "answer" information to this question. I will be back as quickly as I can to finalize this, if it remains open.
Thank you everyone.
Moondancer :)
Community Support Moderator @ Experts Exchange
You logged in as recently as November, but have not updated/finalized your open questions, many of which are very old. You've asked 20 questions, but only graded/closed 10 of them. I have updated all your open questions with this information so that you can easily navigate through the and finalize them.
Here are the options:
1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.
2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.
3. Ask Community Support to help split points between participating experts. Just comment here with details.
4. Delete the question because it is of no value to you or to anyone else. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.
If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.
PLEASE DO NOT AWARD THE POINTS TO ME.
__________________________
Hi Experts:
In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question. Likewise, you can also suggest that I PAQ or delete the question.
Experts, please do not add further "answer" information to this question. I will be back as quickly as I can to finalize this, if it remains open.
Thank you everyone.
Moondancer :)
Community Support Moderator @ Experts Exchange
ASKER
No answer till now :o(
ptmcomp,
These questions are still open and our records indicate you logged in as recently as today. Please resolve them appropriately as soon as possible. Continued disregard of your open questions will result in the force/acceptance of a comment as an answer; other actions affecting your account may also be taken. I will revisit these questions in approximately seven (7) days.
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20114574
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20174312
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20114575
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20114691
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20154079
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20257617
EXPERTS: Please leave your thoughts on this question here.
Thanks,
Netminder
Community Support Moderator
Experts Exchange
These questions are still open and our records indicate you logged in as recently as today. Please resolve them appropriately as soon as possible. Continued disregard of your open questions will result in the force/acceptance of a comment as an answer; other actions affecting your account may also be taken. I will revisit these questions in approximately seven (7) days.
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20114574
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20174312
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20114575
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20114691
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20154079
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20257617
EXPERTS: Please leave your thoughts on this question here.
Thanks,
Netminder
Community Support Moderator
Experts Exchange
ASKER
Still no answer :o(((
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BTW,
sinfo.fWebcrawlerFlags = WEBCRAWL_GET_IMAGES & WEBCRAWL_GET_VIDEOS & WEBCRAWL_GET_BGSOUNDS & WEBCRAWL_GET_CONTROLS;
should probably read
sinfo.fWebcrawlerFlags = WEBCRAWL_GET_IMAGES | WEBCRAWL_GET_VIDEOS | WEBCRAWL_GET_BGSOUNDS | WEBCRAWL_GET_CONTROLS;
(to combine bitflags, you have to use the bitwise 'or', not the bitwise 'and')