1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
try
{
CLSID clsid;
HRESULT hr = CLSIDFromProgID(L"System.Collections.Hashtable", &clsid);
mscorlib::IDictionaryPtr mymap;
hr = CoCreateInstance(clsid, NULL, CLSCTX_ALL, mscorlib::IID_IDictionary, (void **)&mymap);
// mymap.CreateInstance( mscorlib::IID_IDictionary);
::MessageBox(NULL,L"got the hashtable from COM", L"setProperties", MB_ICONINFORMATION);
//works so far
_variant_t key = "PORT";
_variant_t val = "COM19";
mymap->Clear();
mymap->Add(key, val);
//seems to work, at least no exception
_variant_t mapVariant = mymap;
m_diagSystem->setProperties(mapVariant);
//BOOOM, „Interface not supported“,
::MessageBox(NULL,L"table handed over", L"setProperties", MB_ICONINFORMATION);
}
catch( _com_error& ex )
{
LPCTSTR errMsg = ex.ErrorMessage();
::MessageBox(NULL,errMsg, L"setProperties", MB_ICONERROR);
}
|