我想知道系统有哪些补丁没有安装,包括补丁的详细信息:名称,安全级别等等内容有知道的话,麻烦告诉我从哪里获得,或者用哪些函数,最好能详细些

解决方案 »

  1.   

    MSDN上的例子,GetVersionEx()函数#include <windows.h>
    #include <tchar.h>
    #include <stdio.h>
    #include <strsafe.h>#define BUFSIZE 256typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
    typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD);BOOL GetOSDisplayString( LPTSTR pszOS)
    {
    OSVERSIONINFOEX osvi;
    SYSTEM_INFO si;
    PGNSI pGNSI;
    PGPI pGPI;
    BOOL bOsVersionInfoEx;
    DWORD dwType; ZeroMemory(&si, sizeof(SYSTEM_INFO));
    ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
    return 1; // Call GetNativeSystemInfo if supported or GetSystemInfo otherwise. pGNSI = (PGNSI) GetProcAddress(
    GetModuleHandle(TEXT("kernel32.dll")), 
    "GetNativeSystemInfo");
    if(NULL != pGNSI)
    pGNSI(&si);
    else GetSystemInfo(&si); if ( VER_PLATFORM_WIN32_NT==osvi.dwPlatformId && 
    osvi.dwMajorVersion > 4 )
    {
    StringCchCopy(pszOS, BUFSIZE, TEXT("Microsoft ")); // Test for the specific product. if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
    {
    if( osvi.wProductType == VER_NT_WORKSTATION )
    StringCchCat(pszOS, BUFSIZE, TEXT("Windows Vista "));
    else StringCchCat(pszOS, BUFSIZE, TEXT("Windows Server 2008 " )); pGPI = (PGPI) GetProcAddress(
    GetModuleHandle(TEXT("kernel32.dll")), 
    "GetProductInfo"); pGPI( 6, 0, 0, 0, &dwType); switch( dwType )
    {
    case PRODUCT_ULTIMATE:
    StringCchCat(pszOS, BUFSIZE, TEXT("Ultimate Edition" ));
    break;
    case PRODUCT_HOME_PREMIUM:
    StringCchCat(pszOS, BUFSIZE, TEXT("Home Premium Edition" ));
    break;
    case PRODUCT_HOME_BASIC:
    StringCchCat(pszOS, BUFSIZE, TEXT("Home Basic Edition" ));
    break;
    case PRODUCT_ENTERPRISE:
    StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition" ));
    break;
    case PRODUCT_BUSINESS:
    StringCchCat(pszOS, BUFSIZE, TEXT("Business Edition" ));
    break;
    case PRODUCT_STARTER:
    StringCchCat(pszOS, BUFSIZE, TEXT("Starter Edition" ));
    break;
    case PRODUCT_CLUSTER_SERVER:
    StringCchCat(pszOS, BUFSIZE, TEXT("Cluster Server Edition" ));
    break;
    case PRODUCT_DATACENTER_SERVER:
    StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Edition" ));
    break;
    case PRODUCT_DATACENTER_SERVER_CORE:
    StringCchCat(pszOS, BUFSIZE, TEXT("Datacenter Edition (core installation)" ));
    break;
    case PRODUCT_ENTERPRISE_SERVER:
    StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition" ));
    break;
    case PRODUCT_ENTERPRISE_SERVER_CORE:
    StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition (core installation)" ));
    break;
    case PRODUCT_ENTERPRISE_SERVER_IA64:
    StringCchCat(pszOS, BUFSIZE, TEXT("Enterprise Edition for Itanium-based Systems" ));
    break;
    case PRODUCT_SMALLBUSINESS_SERVER:
    StringCchCat(pszOS, BUFSIZE, TEXT("Small Business Server" ));
    break;
    case PRODUCT_SMALLBUSINESS_SERVER_PREMIUM:
    StringCchCat(pszOS, BUFSIZE, TEXT("Small Business Server Premium Edition" ));
    break;
    case PRODUCT_STANDARD_SERVER:
    StringCchCat(pszOS, BUFSIZE, TEXT("Standard Edition" ));
    break;
    case PRODUCT_STANDARD_SERVER_CORE:
    StringCchCat(pszOS, BUFSIZE, TEXT("Standard Edition (core installation)" ));
    break;
    case PRODUCT_WEB_SERVER:
    StringCchCat(pszOS, BUFSIZE, TEXT("Web Server Edition" ));
    break;
    }
    if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
    StringCchCat(pszOS, BUFSIZE, TEXT( ", 64-bit" ));
    else if (si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_INTEL )
    StringCchCat(pszOS, BUFSIZE, TEXT(", 32-bit"));
    } if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
    {
    if( GetSystemMetrics(SM_SERVERR2) )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Windows Server 2003 R2, "));
    else if ( osvi.wSuiteMask==VER_SUITE_STORAGE_SERVER )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Windows Storage Server 2003"));
    else if( osvi.wProductType == VER_NT_WORKSTATION &&
    si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
    {
    StringCchCat(pszOS, BUFSIZE, TEXT( "Windows XP Professional x64 Edition"));
    }
    else StringCchCat(pszOS, BUFSIZE, TEXT("Windows Server 2003, ")); // Test for the server type.
    if ( osvi.wProductType != VER_NT_WORKSTATION )
    {
    if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_IA64 )
    {
    if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Edition for Itanium-based Systems" ));
    else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Enterprise Edition for Itanium-based Systems" ));
    } else if ( si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64 )
    {
    if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter x64 Edition" ));
    else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Enterprise x64 Edition" ));
    else StringCchCat(pszOS, BUFSIZE, TEXT( "Standard x64 Edition" ));
    } else
    {
    if ( osvi.wSuiteMask & VER_SUITE_COMPUTE_SERVER )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Compute Cluster Edition" ));
    else if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Edition" ));
    else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Enterprise Edition" ));
    else if ( osvi.wSuiteMask & VER_SUITE_BLADE )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Web Edition" ));
    else StringCchCat(pszOS, BUFSIZE, TEXT( "Standard Edition" ));
    }
    }
    } if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
    {
    StringCchCat(pszOS, BUFSIZE, TEXT("Windows XP "));
    if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Home Edition" ));
    else StringCchCat(pszOS, BUFSIZE, TEXT( "Professional" ));
    } if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
    {
    StringCchCat(pszOS, BUFSIZE, TEXT("Windows 2000 ")); if ( osvi.wProductType == VER_NT_WORKSTATION )
    {
    StringCchCat(pszOS, BUFSIZE, TEXT( "Professional" ));
    }
    else 
    {
    if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Datacenter Server" ));
    else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
    StringCchCat(pszOS, BUFSIZE, TEXT( "Advanced Server" ));
    else StringCchCat(pszOS, BUFSIZE, TEXT( "Server" ));
    }
    } // Include service pack (if any) and build number. if( _tcslen(osvi.szCSDVersion) > 0 )
    {
    StringCchCat(pszOS, BUFSIZE, TEXT(" ") );
    StringCchCat(pszOS, BUFSIZE, osvi.szCSDVersion);
    } TCHAR buf[80]; StringCchPrintf( buf, 80, TEXT(" (build %d)"), osvi.dwBuildNumber);
    StringCchCat(pszOS, BUFSIZE, buf); return TRUE; 
    } else
    {  
    printf( "This sample does not support this version of Windows.\n");
    return FALSE;
    }
    }int __cdecl _tmain()
    {
    TCHAR szOS[BUFSIZE]; if( GetOSDisplayString( szOS ) )
    _tprintf( TEXT("\n%s\n"), szOS );
    }
      

  2.   

    不是这个吧
    我是想获得这样子的未修补的漏洞
    名称        级别    标题
    KB946538  重要    Active Directory中的漏洞可能导致拒绝服务
    KB942830  关键    IIS的漏洞可导致远程代码执行
      

  3.   

    楼主可以Google一下IUpdateSearcher(获取补丁信息),IUpdateDownloader(下载补丁)
      

  4.   

    还有IUpdate,IUpdateDownloadContentCollection等相关类
      

  5.   


    BOOL GetSystemDefects(struct defects      *system_defects)
    {
    int res = NO_ERROR;
    HRESULT ret;
    int flag = 1;

    try
    {
    IUpdateSession   *Session = NULL;
    ret = CoInitialize(NULL);
    if (FAILED(ret))
    {
    //Log("GetSystemDefects():Initializes the COM Failed.");
    throw -1;
    } ret = CoCreateInstance(CLSID_UpdateSession, NULL, CLSCTX_INPROC_SERVER, 
    IID_IUpdateSession  , (LPVOID*)&Session);
    if ((Session == NULL) || FAILED(ret))
    {
    //return -1;
    throw -2;
    } IUpdateDownloader *pDownloader = NULL;
    ret = Session->CreateUpdateDownloader(&pDownloader); if (FAILED(ret) || (pDownloader == NULL))
    {
    Session->Release();
    //return -1;
    throw -11;
    } IUpdateSearcher  *Searcher = NULL;
    ret = Session->CreateUpdateSearcher(&Searcher); if (FAILED(ret) || (Searcher == NULL))
    {
    Session->Release();
    //return -1;
    throw -3;
    } //Searcher->put_Online(VARIANT_FALSE);    //离线查询
       Searcher->put_Online(VARIANT_TRUE);    //在线查询
    ISearchResult   *SearchResult = NULL;
    ret = Searcher->Search(_bstr_t("IsInstalled = 0 and Type = 'Software'"), &SearchResult); if (FAILED(ret))
    {
    Searcher->Release();
    Session->Release();
    //return -1;
    throw -4;
    } IUpdateCollection *Collection;
    ret = SearchResult->get_Updates(&Collection);
    if (FAILED(ret) || Collection == NULL)
    {
    //Log("//////////////////////////////////////////////////////////////////////////");
    //Log("GetSystemDefects():failed to call ISearchResult::Updates!");
    //Log("//////////////////////////////////////////////////////////////////////////");
    //return 0;
    throw -5;
    } //IDownloadResult *pDownResult = NULL;
    //pDownloader->put_Updates(Collection);
    //pDownloader->Download(&pDownResult);
    long Colnum;
    long  i = 0;
    long  j = 0; Collection->get_Count(&Colnum); if (Colnum < 0)
    {
    //system_defects = NULL;
    //printf("There are no appliable update.\n");
    }
    else
    {
    //printf("Total update count:%d\n", Colnum);
    } for (i = 0; i < Colnum; i++)
    {
    IUpdate   *Update;
    ret = Collection->get_Item(i, &Update);
    if (FAILED(ret) || Update == NULL)
    {
    //Log("Collection->get_Item(i, &Update)");
    throw -6;
    } BSTR Title = NULL;
    ret = Update->get_Title(&Title); //安全等级
    //Critical Important Moderate Low
    BSTR SecLevel = NULL;
    ret = Update->get_MsrcSeverity(&SecLevel); //Download Url
    //
    IUpdateDownloadContentCollection *DownloadUrlCol = NULL; //获取安全公告号
    IStringCollection *SBID = NULL;//安全公告号
    ret = Update->get_SecurityBulletinIDs(&SBID);
    BSTR SB = NULL;
    if (SUCCEEDED(ret) && SBID != NULL)
    {
    long SBCount;
    ret = SBID->get_Count(&SBCount);
    SBID->get_Item(0, &SB);
    }
    //获取补丁号
    IStringCollection *KBArticles = NULL;
    ret = Update->get_KBArticleIDs(&KBArticles);
    BSTR KB;
    if (SUCCEEDED(ret) && KBArticles != NULL)
    {
    long KbCount;
    ret = KBArticles->get_Count(&KbCount);
    KBArticles->get_Item(0, &KB);
    }
    //Description
    //
    BSTR Description = NULL;
    ret = Update->get_Description(&Description); //
    //ReleaseNote
    BSTR ReleaseNote = NULL;
    ret = Update->get_ReleaseNotes(&ReleaseNote); //IUpdateCollection *pUpdateColl = NULL;#if 0
    BSTR DownloadURL = NULL;
    IUpdateDownloadContentCollection *DownCollection;
    IUpdateDownloadContent *DownContent;
    ret =  Update->get_DownloadContents(&DownCollection);
    //DownCollection->get_Item(0, &DownContent);
    //DownContent->get_DownloadUrl(&DownloadURL); //pDownloader->put_Updates()
    #endif
    //
    //More information
    IStringCollection *MoreInfo;
    ret = Update->get_MoreInfoUrls(&MoreInfo);
    BSTR MoreInfoUrl;
    if (SUCCEEDED(ret) && MoreInfo != NULL)
    {
    long MICount;
    ret = MoreInfo->get_Count(&MICount);
    MoreInfo->get_Item(0, &MoreInfoUrl);    
    } // 有安全公告号,才显示
    if (SB != NULL)
    { wchar_t buffer[max_size];
    memset(buffer, '\0', max_size); defects tmpdf; ZeroMemory(&tmpdf, sizeof(defects));
    swprintf(tmpdf.defects_name, L"%s", Title);
    swprintf(tmpdf.defects_id, L"%s", SB);
    swprintf(tmpdf.defects_level, L"%s", SecLevel);
    swprintf(tmpdf.defects_desc, L"%s", Description);
    swprintf(tmpdf.patch_name, L"KB%s", KB);
    swprintf(tmpdf.MoreInfoUrl, L"%s", MoreInfoUrl); g_KBList.push_back(tmpdf);
    }
    } Session->Release();
    Searcher->Release();
    SearchResult->Release(); CoUninitialize();
    }catch(int err)
    {
    wchar_t inf[1024];
    res = err;    
    wsprintf(inf, L"Error:%d, ret = %x\n", res, ret);
    MessageBox(NULL, inf, NULL, MB_OK); return false;
    }// Log("Get system defects successed.");
    return true;
    }
    再给你一段示例代码
      

  6.   

    楼上的多谢了我想问一下这个能在vc6.0中运行吗?
    我编译不通过,说是没找到wuapi.h这个头文件如果可以的话麻烦告诉我一下
      

  7.   

    写过,必须有wuapi.h、wuguid.lib、wuapi.idl、wuerror.h这些文件,才能编译,网上可以下到。
    或者联系我[email protected]
      

  8.   

    这里有个例子
    http://msdn.microsoft.com/en-us/library/aa386515(VS.85).aspx