Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created code using Iupdate classes, Till windows 8.1 it is working fine.
But in windows 10 feature updates & some cumulative updates don't have download url.
Any solution will be helpful.
Thanks in advance.

What I have tried:

Used APIs Iupdate classes, IupdateCollection etc.
Posted
Updated 18-Nov-19 19:28pm
Comments
Richard MacCutchan 19-Nov-19 3:58am    
Your question is not clear. If you have a problem with some code then please show the codes and explain clearly what error occurs.
Anurag__ 21-Nov-19 9:12am    
int main()
{
IUpdateSession *updateSession = NULL;
IUpdateSearcher *updateSearcher = NULL;
ISearchResult *searchResult = NULL;
IUpdateCollection *updates = NULL;
IUpdateDownloadContentCollection *pDownUrl = NULL;
IUpdateDownloadContent *downloadContent = NULL;
HRESULT res;
int ret = 1;
LONG count;
res = CoInitializeEx(NULL, 0);
if (FAILED(res)) {
HandleError(L"Failed to initialize COM", res);
return 1;
}

res = CoCreateInstance(CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER, IID_IUpdateSession, (LPVOID *)&updateSession);
if (FAILED(res)) {
HandleError(L"Failed to create update session", res);
goto cleanup;
}

res = updateSession->CreateUpdateSearcher(&updateSearcher);
if (FAILED(res)) {
HandleError(L"Failed to create update searcher", res);
goto cleanup;
}

res = updateSearcher->put_IncludePotentiallySupersededUpdates(VARIANT_TRUE);
if (FAILED(res)) {
HandleError(L"Failed to set search options", res);
goto cleanup;
}

BSTR criteria = SysAllocString(L"IsInstalled=1 or IsHidden=1");
res = updateSearcher->Search(criteria, &searchResult);
SysFreeString(criteria);
if (FAILED(res)) {
HandleError(L"Failed to search for updates", res);
goto cleanup;
}

res = searchResult->get_Updates(&updates);
if (FAILED(res)) {
HandleError(L"Failed to retrieve update list from search result", res);
goto cleanup;
}

LONG updateCount;
res = updates->get_Count(&updateCount);
if (FAILED(res)) {
HandleError(L"Failed to get update count", res);
goto cleanup;
}

for (LONG i = 0L; i < updateCount; ++i)
{
IUpdate *update = NULL;
IStringCollection *updateKBIDs = NULL;
bool innerError = true;
res = updates->get_Item(i, &update);
if (FAILED(res)) {
HandleError(L"Failed to get update item", res);
goto innerCleanup;
}

res = update->get_KBArticleIDs(&updateKBIDs);
if (FAILED(res)) {
HandleError(L"Failed to get KB article ID list", res);
goto innerCleanup;
}
res = update->get_DownloadContents(&pDownUrl);
if(SUCCEEDED(res))
{
BSTR url;
res = pDownUrl->get_Count(&count);
res = pDownUrl->get_Item(1, &downloadContent);
if(FAILED(res))
{
HandleError(L"Failed to get url article ID count", res);
//goto innerCleanup;
}
else
{
res = downloadContent->get_DownloadUrl(&url);
if(FAILED(res))
{
//goto innerCleanup;
}
else
{
std::wcout << L"URL" << url << L':' << std::endl;
SysFreeString(url);
}
}
}
LONG kbIDCount;
res = updateKBIDs->get_Count(&kbIDCount);
if (FAILED(res)) {
HandleError(L"Failed to get KB article ID count", res);
goto innerCleanup;
}

for (LONG j = 0L; j < kbIDCount; ++j) {
BSTR kbID;
res = updateKBIDs->get_Item(j, &kbID);
if (FAILED(res)) {
HandleError(L"Failed to get KB article ID", res);
goto innerCleanup;
}
std::wcout << L"KB" << kbID << L':' << std::endl;
SysFreeString(kbID);
}

BSTR updateTitle;
res = update->get_Title(&updateTitle);
if (FAILED(res)) {
HandleError(L"Failed to get update title", res);
goto innerCleanup;
}
std::wcout << L" " << updateTitle << std::endl << std::endl;
SysFreeString(updateTitle);

innerError = false;
innerCleanup:
updateKBI
Richard MacCutchan 21-Nov-19 9:43am    
Please add the code, properly formatted, to your question, so everyone can see it. You also still need to include details of what is going wrong and where in the code the problem occurs.
Anurag__ 22-Nov-19 0:15am    
Hi richard,
I think there is a word limit is there, there fore not able to see complete code,
let me check some other method.
Anurag__ 22-Nov-19 0:37am    
I got this code from following link
https://gist.github.com/apsun/b471c2e11dab94ad690d

where i added this code

res = update->get_DownloadContents(&pDownUrl);
if(SUCCEEDED(res))
{
BSTR url;
res = pDownUrl->get_Count(&count);
res = pDownUrl->get_Item(1, &downloadContent);
if(FAILED(res))
{
HandleError(L"Failed to get url article ID count", res);
//goto innerCleanup;
}
else
{
res = downloadContent->get_DownloadUrl(&url);
if(FAILED(res))
{
//goto innerCleanup;
}
else
{
std::wcout << L"URL" << url << L':' << std::endl;
SysFreeString(url);
}
}

In above section i am not getting download url.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900