// @pymethod <o PyRecord>|pythoncom|GetRecordFromGuids|Creates a new record object from the given GUIDs PyObject *pythoncom_GetRecordFromGuids(PyObject *self, PyObject *args) { void *data = NULL; PyObject *obGuid, *obInfoGuid, *obdata=Py_None; int major, minor, lcid; int cb = 0; if (!PyArg_ParseTuple(args, "OiiiO|O:GetRecordFromGuids", &obGuid, // @pyparm <o PyIID>|iid||The GUID of the type library &major, // @pyparm int|verMajor||The major version number of the type lib. &minor, // @pyparm int|verMinor||The minor version number of the type lib. &lcid, // @pyparm int|lcid||The LCID of the type lib. &obInfoGuid, // @pyparm <o PyIID>|infoIID||The GUID of the record info in the library &obdata)) // @pyparm string or buffer|data|None|The raw data to initialize the record with. return NULL; if (!PyWinObject_AsReadBuffer(obdata, &data, &cb, TRUE)) return NULL; GUID guid, infoGuid; if (!PyWinObject_AsIID(obGuid, &guid)) return NULL; if (!PyWinObject_AsIID(obInfoGuid, &infoGuid)) return NULL; IRecordInfo *i = NULL; HRESULT hr = GetRecordInfoFromGuids(guid, major, minor, lcid, infoGuid, &i); if (FAILED(hr)) return PyCom_BuildPyException(hr); PyObject *ret = PyObject_FromRecordInfo(i, data, cb); i->Release(); return ret; }
STDMETHODIMP Profile::get_ForwardingRules(SAFEARRAY ** pVal) { try { WCHAR * pResult = gSkypeQueue.RetrieveProperty(L"PROFILE", L"", L"CALL_FORWARD_RULES"); size_t sz = wcslen(pResult) + 1; WCHAR * pCopy = new WCHAR[sz]; long lTotal=0, lCtr=0; HRESULT hr; ForwardingRule * pItems; for(int i = 0; i < 2; i++) { wcscpy_s(pCopy, sz, pResult); WCHAR *next_token = NULL; WCHAR * pItem = wcstok_s(pCopy, L" ", &next_token); while(pItem != NULL) { size_t iLen = wcslen(pItem); if(iLen > 0) { LONG start; LONG end; WCHAR * name = new WCHAR[iLen]; bool bValid = swscanf_s(pItem, L"%d,%d,%s", & start, & end, name, iLen) == 3; if(bValid) { if(i == 0) { lTotal++; } else { pItems[lCtr].StartTime = start; pItems[lCtr].EndTime = end; pItems[lCtr].Handle = SysAllocString(name); lCtr++; } } delete(name); } pItem = wcstok_s(NULL, L" ", &next_token); } if(i == 0) { SAFEARRAYBOUND sba; sba.cElements = lTotal; sba.lLbound = 0; CComPtr<IRecordInfo> *ptrRecInfo; hr = GetRecordInfoFromGuids(CAtlModule::m_libid, 1, 0, 0x409, __uuidof(ForwardingRule), (IRecordInfo**) & ptrRecInfo); if(FAILED(hr)) { return AtlReportError(GetObjectCLSID(), L"Unable to retrieve structure info", GUID_NULL, E_FAIL); } *pVal = SafeArrayCreateEx(VT_RECORD, 1, & sba, ptrRecInfo); if((*pVal) == NULL) { return AtlReportError(GetObjectCLSID(), L"Unable to create array", GUID_NULL, E_FAIL); } hr = SafeArrayLock(*pVal); if(FAILED(hr)) { return AtlReportError(GetObjectCLSID(), L"Unable to lock array", GUID_NULL, E_FAIL); } pItems = (ForwardingRule *) (*pVal)->pvData; } else { hr = SafeArrayUnlock(*pVal); if(FAILED(hr)) { return AtlReportError(GetObjectCLSID(), L"Unable to unlock array", GUID_NULL, E_FAIL); } } } free(pResult); return S_OK; } catch (const WCHAR * err) { return AtlReportError(GetObjectCLSID(), err, GUID_NULL, E_FAIL); } return S_OK; }