Vista인경우는 레지스트리에서 운영체제 Hotfix 리스트를 가져올 수 없다.
윈도우에서 제공하는 WMI 함수가 있긴한데 결정적으로... 느리다;;;;
그래도 이게 어디!!
hr = CoSetProxyBlanket(pSvc,
RPC_C_AUTHN_WINNT, // NTLMSSP (Windows NT LAN Manager Security Support Provider).
RPC_C_AUTHZ_NONE, // Server performs no authorization
NULL,
RPC_C_AUTHN_LEVEL_CALL, // Authenticates only at the beginning of each remote procedure call when the server receives the request.
RPC_C_IMP_LEVEL_IMPERSONATE, // The server process can impersonate the client's security context while acting on behalf of the client.
NULL,
EOAC_NONE);
CoUninitialize();
return true;
}
윈도우에서 제공하는 WMI 함수가 있긴한데 결정적으로... 느리다;;;;
그래도 이게 어디!!
bool GetHotFixFromWMI(set<tstring>& setPatch)
{
HRESULT hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
if ( FAILED( hr ) )
{
_PE(_T("COM initialization failed\n"));
return false;
}
IWbemLocator *pLoc = NULL;
hr = CoCreateInstance( CLSID_WbemAdministrativeLocator, NULL,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, reinterpret_cast< void** >( &pLoc ) );
if ( FAILED( hr ) )
{
_PE(_T("Instantiation of IWbemLocator failed\n"));
return false;
}
IWbemServices *pSvc = NULL;
hr = pLoc->ConnectServer( L"root\\cimv2", NULL, NULL, NULL,
WBEM_FLAG_CONNECT_USE_MAX_WAIT,
NULL, NULL, &pSvc );
{
HRESULT hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
if ( FAILED( hr ) )
{
_PE(_T("COM initialization failed\n"));
return false;
}
IWbemLocator *pLoc = NULL;
hr = CoCreateInstance( CLSID_WbemAdministrativeLocator, NULL,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, reinterpret_cast< void** >( &pLoc ) );
if ( FAILED( hr ) )
{
_PE(_T("Instantiation of IWbemLocator failed\n"));
return false;
}
IWbemServices *pSvc = NULL;
hr = pLoc->ConnectServer( L"root\\cimv2", NULL, NULL, NULL,
WBEM_FLAG_CONNECT_USE_MAX_WAIT,
NULL, NULL, &pSvc );
if(FAILED(hr))
{
_PE(_T("Couldn't connect to service\n"));
pLoc->Release();
return false;
}
{
_PE(_T("Couldn't connect to service\n"));
pLoc->Release();
return false;
}
hr = CoSetProxyBlanket(pSvc,
RPC_C_AUTHN_WINNT, // NTLMSSP (Windows NT LAN Manager Security Support Provider).
RPC_C_AUTHZ_NONE, // Server performs no authorization
NULL,
RPC_C_AUTHN_LEVEL_CALL, // Authenticates only at the beginning of each remote procedure call when the server receives the request.
RPC_C_IMP_LEVEL_IMPERSONATE, // The server process can impersonate the client's security context while acting on behalf of the client.
NULL,
EOAC_NONE);
if(FAILED(hr))
{
_PE(_T("Could not set proxy blanket\n"));
pLoc->Release();
return false;
}
{
_PE(_T("Could not set proxy blanket\n"));
pLoc->Release();
return false;
}
IEnumWbemClassObject *pEnum = NULL;
hr = pSvc->ExecQuery( L"WQL", L"SELECT * FROM Win32_QuickFixEngineering",
WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum );
hr = pSvc->ExecQuery( L"WQL", L"SELECT * FROM Win32_QuickFixEngineering",
WBEM_FLAG_FORWARD_ONLY, NULL, &pEnum );
if(FAILED(hr))
{
_PE(_T("Query failed\n"));
pLoc->Release();
return false;
}
{
_PE(_T("Query failed\n"));
pLoc->Release();
return false;
}
ULONG uReturned=0;
IWbemClassObject *pObj = NULL;
while((hr = pEnum->Next(WBEM_INFINITE, // time in milliseconds that the call blocks
1, // number of requested objects
reinterpret_cast<IWbemClassObject**>( &pObj ), // IWbemClassObject
&uReturned)) // number of objects returned
== WBEM_S_NO_ERROR)
{
if ( uReturned <= 0 )
{
std::cout << "Enumeration empty" << std::endl;
break;
}
IWbemClassObject *pObj = NULL;
while((hr = pEnum->Next(WBEM_INFINITE, // time in milliseconds that the call blocks
1, // number of requested objects
reinterpret_cast<IWbemClassObject**>( &pObj ), // IWbemClassObject
&uReturned)) // number of objects returned
== WBEM_S_NO_ERROR)
{
if ( uReturned <= 0 )
{
std::cout << "Enumeration empty" << std::endl;
break;
}
//HOTFIX_INFO stHotfix;
_variant_t var_val;
hr = pObj->Get( L"HotFixID", 0, &var_val, NULL, NULL );
if ( SUCCEEDED( hr ) )
{
_bstr_t str = var_val;
//stHotfix.id=(TCHAR*)str;
if(_tcscmp((TCHAR*)str,_T("File 1"))==0)
continue;
setPatch.insert((TCHAR*)str);
}
_variant_t var_val;
hr = pObj->Get( L"HotFixID", 0, &var_val, NULL, NULL );
if ( SUCCEEDED( hr ) )
{
_bstr_t str = var_val;
//stHotfix.id=(TCHAR*)str;
if(_tcscmp((TCHAR*)str,_T("File 1"))==0)
continue;
setPatch.insert((TCHAR*)str);
}
// hr = pObj->Get( L"Description", 0, &var_val, NULL, NULL );
// if ( SUCCEEDED( hr ) )
// {
// _bstr_t str = var_val;
// stHotfix.desc=(TCHAR*)str;
// }
//
// hr = pObj->Get( L"ServicePackInEffect", 0, &var_val, NULL, NULL );
// if ( SUCCEEDED( hr ) )
// {
// _bstr_t str = var_val;
// stHotfix.sp=(TCHAR*)str;
// }
//_PL(_T("%s %s %s\n"),stHotfix.id.c_str(),stHotfix.desc.c_str(),stHotfix.sp.c_str() );
//vecHotfix.push_back(stHotfix);
// if ( SUCCEEDED( hr ) )
// {
// _bstr_t str = var_val;
// stHotfix.desc=(TCHAR*)str;
// }
//
// hr = pObj->Get( L"ServicePackInEffect", 0, &var_val, NULL, NULL );
// if ( SUCCEEDED( hr ) )
// {
// _bstr_t str = var_val;
// stHotfix.sp=(TCHAR*)str;
// }
//_PL(_T("%s %s %s\n"),stHotfix.id.c_str(),stHotfix.desc.c_str(),stHotfix.sp.c_str() );
//vecHotfix.push_back(stHotfix);
pObj->Release();
}
}
if(pEnum)
pEnum->Release();
pEnum->Release();
if(pLoc)
pLoc->Release();
pLoc->Release();
if(pSvc)
pSvc->Release();
pSvc->Release();
CoUninitialize();
return true;
}
'Programming > MFC' 카테고리의 다른 글
운영체제가 Vista 64 bit 인지 확인하기 (0) | 2009.06.24 |
---|---|
CDialog에서 엔터키로 인한 종료 막기 (0) | 2009.06.04 |
Visual Studio 단축키 (0) | 2009.03.31 |
Visual Studio Just In Time Debugger 해제 방법 (1) | 2009.03.30 |
VC++ with Mysql (0) | 2008.07.22 |