【问题标题】:How to set timeout for IWbemLocator::ConnectServer?如何为 IWbemLocator::ConnectServer 设置超时?
【发布时间】:2013-07-19 19:05:53
【问题描述】:

现在我正在按照此链接中提供的示例编写 WMI 查询实用程序: http://msdn.microsoft.com/en-us/library/windows/desktop/aa390422(v=vs.85).aspx

但我发现程序可能会阻塞对 IWbemLocator::ConnectServer 的调用。代码如下:

  hres = pLoc->ConnectServer(
    _bstr_t(L"\\\\COMPUTERNAME\\root\\cimv2"),
    _bstr_t(useToken?NULL:pszName),    // User name
    _bstr_t(useToken?NULL:pszPwd),     // User password
    NULL,                              // Locale             
    NULL,                              // Security flags
    _bstr_t(useNTLM?NULL:pszAuthority),// Authority        
    NULL,                              // Context object 
    &pSvc                              // IWbemServices proxy
    );

我的问题是如何在致电IWbemLocator::ConnectServer 之前设置超时选项。

【问题讨论】:

    标签: visual-c++ wmi


    【解决方案1】:

    根据ConnectServer method description,将lSecurityFlags 参数设置为WBEM_FLAG_CONNECT_USE_MAX_WAIT 会强制执行2 分钟超时。看起来没有办法设置自定义超时。

    【讨论】:

      猜你喜欢
      • 2017-01-13
      • 2021-03-28
      • 2016-06-29
      • 1970-01-01
      • 2021-12-20
      • 2018-07-08
      • 2010-11-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多