구성요소 서비스의 내 컴퓨터 기본 DCOM 통신 속성 변경하기

참고 :
http://msdn2.microsoft.com/en-us/library/ms687763(VS.85).aspx
http://msdn2.microsoft.com/en-us/library/ms682790(VS.85).aspx

기본 속성 읽어오기

try
{
ICOMAdminCatalogPtr spCatalog(_T("COMAdmin.COMAdminCatalog"));
spCatalog->Connect(_T("localhost"));

ICatalogCollectionPtr spCatalogCollection =
(ICatalogCollectionPtr)spCatalog->GetCollection(_T("LocalComputer"));
spCatalogCollection->Populate();

long nCount = 0;
nCount = spCatalogCollection->Count;
if (nCount == 0)
{
AfxMessageBox(_T("내 컴퓨터의 DCOM 통신 속성을 읽어오지 못하였습니다."));
return;
}

ASSERT(nCount == 1);

ICatalogObjectPtr spCatalogObject;
spCatalogCollection->get_Item(0, (IDispatch**)&spCatalogObject);

_variant_t value;
spCatalogObject->get_Value(_T("DefaultAuthenticationLevel"), &value);
if (value.vt == VT_I4)
{
if (value.lVal >= 0 && value.lVal <= 6) { CComboBox* pAuthCombo = (CComboBox*)GetDlgItem(IDC_CBO_AUTH); pAuthCombo->SetCurSel(value.lVal);
}
}

spCatalogObject->get_Value(_T("DefaultImpersonationLevel"), &value);
if (value.vt == VT_I4)
{
if (value.lVal >= 1 && value.lVal <= 4) { CComboBox* pImpersonationCombo = (CComboBox*)GetDlgItem(IDC_CBO_IMPERSONATION); pImpersonationCombo->SetCurSel(value.lVal);
}
}
} catch (_com_error& e) {
AfxMessageBox(e.Description());
}

 

기본속성 변경하기

try
{
ICOMAdminCatalogPtr spCatalog(_T("COMAdmin.COMAdminCatalog"));
spCatalog->Connect(_T("localhost"));

ICatalogCollectionPtr spCatalogCollection =
(ICatalogCollectionPtr)spCatalog->GetCollection(_T("LocalComputer"));
spCatalogCollection->Populate();

long nCount = 0;
nCount = spCatalogCollection->Count;
if (nCount == 0)
{
AfxMessageBox(_T("내 컴퓨터의 DCOM 통신 속성을 읽어오지 못하였습니다."));
return;
}

ASSERT(nCount == 1);

ICatalogObjectPtr spCatalogObject;
spCatalogCollection->get_Item(0, (IDispatch**)&spCatalogObject);

CComboBox* pAuthCombo = (CComboBox*)GetDlgItem(IDC_CBO_AUTH);
_variant_t value;
value.vt = VT_I4;
value.lVal = pAuthCombo->GetCurSel();
spCatalogObject->put_Value(_T("DefaultAuthenticationLevel"), value);

CComboBox* pImpersonationCombo = (CComboBox*)GetDlgItem(IDC_CBO_IMPERSONATION);
_variant_t value1;
value1.vt = VT_I4;
value1.lVal = pImpersonationCombo->GetCurSel();
spCatalogObject->put_Value(_T("DefaultImpersonationLevel"), value1);

spCatalogCollection->SaveChanges();
} catch (_com_error& e) {
AfxMessageBox(e.Description());
}

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 항목은 *(으)로 표시합니다