// --------------------------------------------------- // // Gateway Implementation STDMETHODIMP_(UINT) PyGCopyHookW::CopyCallback( /* [unique][in] */ HWND hwnd, /* [unique][in] */ UINT wFunc, /* [unique][in] */ UINT wFlags, /* [unique][in] */ LPCWSTR srcFile, /* [unique][in] */ DWORD srcAttribs, /* [unique][in] */ LPCWSTR destFile, /* [unique][in] */ DWORD destAttribs) { PY_GATEWAY_METHOD; PyObject *result; HRESULT hr=InvokeViaPolicy("CopyCallback", &result, "NiiNlNl", PyWinLong_FromHANDLE(hwnd), wFunc, wFlags, PyWinObject_FromWCHAR(srcFile), srcAttribs, PyWinObject_FromWCHAR(destFile), destAttribs); if (FAILED(hr)) return hr; hr = PyInt_AsLong(result); if ((hr==-1) && PyErr_Occurred()) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("CopyCallBack"); Py_DECREF(result); return hr; }
PyObject *PyObject_FromMAPIERROR(MAPIERROR *e, BOOL bIsUnicode, BOOL free_buffer) { PyObject *obError; if (e->lpszError) obError = bIsUnicode ? PyWinObject_FromWCHAR((const WCHAR *)e->lpszError) : PyString_FromString((const char *)e->lpszError); else { obError = Py_None; Py_INCREF(Py_None); } PyObject *obComp; if (e->lpszComponent) obComp = bIsUnicode ? PyWinObject_FromWCHAR((const WCHAR *)e->lpszComponent) : PyString_FromString((const char *)e->lpszComponent); else { obComp = Py_None; Py_INCREF(Py_None); } PyObject *ret = Py_BuildValue("lOOll", e->ulVersion, obError, obComp, e->ulLowLevelError, e->ulContext); Py_XDECREF(obError); Py_XDECREF(obComp); if (free_buffer) MAPIFreeBuffer(e); return ret; }
PyADS_OBJECT_INFO(const ADS_OBJECT_INFO *pInfo) { ob_type = &Type; _Py_NewReference(this); obRDN = PyWinObject_FromWCHAR(pInfo->pszRDN); obObjectDN = PyWinObject_FromWCHAR(pInfo->pszObjectDN); obParentDN = PyWinObject_FromWCHAR(pInfo->pszParentDN); obClassName = PyWinObject_FromWCHAR(pInfo->pszClassName); }
static PyObject *PyObject_FromDS_NAME_RESULT(DS_NAME_RESULT *dsresult) { PyObject *ret = PyList_New(dsresult->cItems); if (!ret) return NULL; for (DWORD i=0;i<dsresult->cItems;i++) { DS_NAME_RESULT_ITEM *pi = dsresult->rItems + i; PyList_SET_ITEM(ret, i, Py_BuildValue("iNN", pi->status, PyWinObject_FromWCHAR(pi->pDomain), PyWinObject_FromWCHAR(pi->pName))); } return ret; }
// @pymethod <o PyUNICODE>|pythoncom|FmtIdToPropStgName|Converts a FMTID to its stream name PyObject *pythoncom_FmtIdToPropStgName(PyObject *self, PyObject *args) { // @pyparm <o PyIID>|fmtid||Format id - a property storage GUID (FMTID_* IIDs) HRESULT err; WCHAR oszName[CCH_MAX_PROPSTG_NAME]; FMTID fmtid; PyObject *obfmtid=NULL; typedef HRESULT (WINAPI * PFNFmtIdToPropStgName)(const FMTID*, LPOLESTR); static PFNFmtIdToPropStgName pfnFmtIdToPropStgName=NULL; static BOOL pfnchecked=FALSE; if (!pfnchecked){ if (ole32==NULL) ole32=GetModuleHandle(_T("Ole32.dll")); if (ole32!=NULL) pfnFmtIdToPropStgName = (PFNFmtIdToPropStgName)GetProcAddress(ole32, "FmtIdToPropStgName"); pfnchecked=TRUE; } if (pfnFmtIdToPropStgName==NULL) return PyErr_Format(PyExc_NotImplementedError,"FmtIdToPropStgName is not available on this platform"); if (!PyArg_ParseTuple(args, "O:FmtIdToPropStgName", &obfmtid)) return NULL; if (!PyWinObject_AsIID(obfmtid, &fmtid)) return NULL; PY_INTERFACE_PRECALL; err = (*pfnFmtIdToPropStgName)(&fmtid, oszName); PY_INTERFACE_POSTCALL; if (err!=S_OK) return PyCom_BuildPyException(err); return PyWinObject_FromWCHAR(oszName); }
// Converts a series of consecutive null terminated strings into a list // Note that a read overflow can result if the input is not properly terminated with an extra NULL. // Should probably also add a counted version, as win32api uses for REG_MULTI_SZ PyObject *PyWinObject_FromMultipleString(WCHAR *multistring) { PyObject *obelement, *ret=NULL; size_t elementlen; if (multistring==NULL){ Py_INCREF(Py_None); return Py_None; } ret=PyList_New(0); if (ret==NULL) return NULL; elementlen=wcslen(multistring); while (elementlen){ obelement=PyWinObject_FromWCHAR(multistring, elementlen); if ((obelement==NULL)||(PyList_Append(ret,obelement)==-1)){ Py_XDECREF(obelement); Py_DECREF(ret); return NULL; } Py_DECREF(obelement); multistring+=elementlen+1; elementlen=wcslen(multistring); } return ret; }
STDMETHODIMP PyGTransferSource::LinkItem( /* [in] */ IShellItem * psiSource, /* [in] */ IShellItem * psiParentDest, /* [in] */ LPCWSTR pszNewName, /* [in] */ TRANSFER_SOURCE_FLAGS flags, /* [out] */ IShellItem ** ppsiNewDest) { PY_GATEWAY_METHOD; if (ppsiNewDest==NULL) return E_POINTER; PyObject *obpsiSource; PyObject *obpsiParentDest; PyObject *obpszNewName; obpsiSource = PyCom_PyObjectFromIUnknown(psiSource, IID_IShellItem, TRUE); obpsiParentDest = PyCom_PyObjectFromIUnknown(psiParentDest, IID_IShellItem, TRUE); obpszNewName = PyWinObject_FromWCHAR(pszNewName); PyObject *result; HRESULT hr=InvokeViaPolicy("LinkItem", &result, "OOOi", obpsiSource, obpsiParentDest, obpszNewName, flags); Py_XDECREF(obpsiSource); Py_XDECREF(obpsiParentDest); Py_XDECREF(obpszNewName); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params PyObject *obppsiNewDest; if (!PyArg_Parse(result, "lO" , &hr, &obppsiNewDest)) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("LinkItem"); else if (!PyCom_InterfaceFromPyInstanceOrObject(obppsiNewDest, IID_IShellItem, (void **)ppsiNewDest, TRUE)) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("LinkItem"); Py_DECREF(result); return hr; }
// @pymethod str|PyITransferSource|GetDefaultDestinationName|Determines the name of an item as it would appear in a given folder PyObject *PyITransferSource::GetDefaultDestinationName(PyObject *self, PyObject *args) { ITransferSource *pITS = GetI(self); if ( pITS == NULL ) return NULL; // @pyparm <o PyIShellItem>|Source||The item whose name is wanted // @pyparm <o PyIShellItem>|ParentDest||The destination folder PyObject *obpsiSource; PyObject *obpsiParentDest; IShellItem * psiSource; IShellItem * psiParentDest; LPWSTR pszDestinationName; if ( !PyArg_ParseTuple(args, "OO:GetDefaultDestinationName", &obpsiSource, &obpsiParentDest) ) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiSource, IID_IShellItem, (void **)&psiSource, FALSE)) return NULL; if (!PyCom_InterfaceFromPyInstanceOrObject(obpsiParentDest, IID_IShellItem, (void **)&psiParentDest, FALSE)){ PYCOM_RELEASE(psiSource); return NULL; } HRESULT hr; PY_INTERFACE_PRECALL; hr = pITS->GetDefaultDestinationName( psiSource, psiParentDest, &pszDestinationName ); psiSource->Release(); psiParentDest->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pITS, IID_ITransferSource ); PyObject *ret = PyWinObject_FromWCHAR(pszDestinationName); CoTaskMemFree(pszDestinationName); return ret; }
// @pymethod |PyIFilter|GetText|Description of GetText. PyObject *PyIFilter::GetText(PyObject *self, PyObject *args) { IFilter *pIF = GetI(self); if ( pIF == NULL ) return NULL; // @pyparm <int>|nBufSize|size of text buffer to create ULONG nBufSize = 0; if ( !PyArg_ParseTuple(args, "|i:GetText", &nBufSize) ) return NULL; HRESULT hr; if (nBufSize == 0) nBufSize = 8192; // 8k default WCHAR *wBuffer = (WCHAR *)PyMem_Malloc((nBufSize+1)*sizeof(WCHAR)); if (!wBuffer){ PyErr_SetString(PyExc_MemoryError, "getting text"); return NULL; } PY_INTERFACE_PRECALL; hr = pIF->GetText( &nBufSize, wBuffer ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) { PyMem_Free(wBuffer); return PyCom_BuildPyException(hr, pIF, IID_IFilter ); } PyObject *obRet = PyWinObject_FromWCHAR(wBuffer, nBufSize); PyMem_Free(wBuffer); return obRet; }
PyObject *PyWinObject_FromTRUSTEE(TRUSTEE_W *ptrustee) { PyObject *obIdentifier=NULL; switch (ptrustee->TrusteeForm){ case TRUSTEE_IS_SID:{ obIdentifier=PyWinObject_FromSID(ptrustee->ptstrName); break; } case TRUSTEE_IS_NAME:{ obIdentifier=PyWinObject_FromWCHAR(ptrustee->ptstrName); break; } #if WINVER >= 0x0501 case TRUSTEE_IS_OBJECTS_AND_SID: case TRUSTEE_IS_OBJECTS_AND_NAME:{ PyErr_SetString(PyExc_NotImplementedError, "TrusteeForm not yet supported"); return FALSE; } #endif default:{ PyErr_SetString(PyExc_ValueError, "Invalid value for TrusteeForm"); return FALSE; } } if (!obIdentifier) return NULL; return Py_BuildValue("{s:O,s:l,s:l,s:l,s:N}", "MultipleTrustee",Py_None, "MultipleTrusteeOperation",NO_MULTIPLE_TRUSTEE, "TrusteeForm",ptrustee->TrusteeForm, "TrusteeType",ptrustee->TrusteeType, "Identifier",obIdentifier); }
// @pymethod |PyIExtractIconW|GetIconLocation|Description of GetIconLocation. PyObject *PyIExtractIconW::GetIconLocation(PyObject *self, PyObject *args) { IExtractIconW *pIEI = GetI(self); if ( pIEI == NULL ) return NULL; // @pyparm int|uFlags||Description for uFlags // @pyparm int|cchMax|MAX_PATH+MAX_FNAME|Buffer size to allocate for file name UINT uFlags; INT cchMax = MAX_PATH + _MAX_FNAME; if ( !PyArg_ParseTuple(args, "i|i:GetIconLocation", &uFlags, &cchMax)) return NULL; WCHAR *buf = (WCHAR *)malloc(cchMax * sizeof(WCHAR)); if (!buf) return PyErr_NoMemory(); INT iIndex; UINT flags; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIEI->GetIconLocation( uFlags, buf, cchMax, &iIndex, &flags); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) { free(buf); return PyCom_BuildPyException(hr, pIEI, IID_IExtractIconW ); } PyObject *retStr = PyWinObject_FromWCHAR(buf); free(buf); return Py_BuildValue("iNii", hr, retStr, iIndex, flags); }
// --------------------------------------------------- // // Gateway Implementation STDMETHODIMP PyGExtractIconW::Extract( /* [unique][in] */ LPCWSTR pszFile, /* [unique][in] */ UINT nIconIndex, /* [out] */ HICON * phiconLarge, /* [out] */ HICON * phiconSmall, /* [unique][in] */ UINT nIconSize) { PY_GATEWAY_METHOD; PyObject *obpszFile; obpszFile = PyWinObject_FromWCHAR((LPWSTR)pszFile); PyObject *result; HRESULT hr=InvokeViaPolicy("Extract", &result, "Oii", obpszFile, nIconIndex, nIconSize); Py_XDECREF(obpszFile); if (FAILED(hr)) return hr; if (PyInt_Check(result) || PyLong_Check(result)) hr = PyInt_AsLong(result); else { PyObject *oblarge, *obsmall; if (PyArg_ParseTuple(result, "OO", &oblarge, &obsmall) && PyWinObject_AsHANDLE(oblarge, (HANDLE *)phiconLarge) && PyWinObject_AsHANDLE(obsmall, (HANDLE *)phiconSmall)) { // we worked - no error should be present! assert(!PyErr_Occurred()); } hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("Extract"); } Py_DECREF(result); return hr; }
// @pymethod |PyIBackgroundCopyManager|GetErrorDescription|Description of GetErrorDescription. PyObject *PyIBackgroundCopyManager::GetErrorDescription(PyObject *self, PyObject *args) { IBackgroundCopyManager *pIBCM = GetI(self); if ( pIBCM == NULL ) return NULL; // @pyparm int|hResult||Description for hResult // @pyparm int|LanguageId||Description for LanguageId WCHAR* pszErrorDescription; PyObject *obpErrorDescription; HRESULT hResult; DWORD LanguageId; if ( !PyArg_ParseTuple(args, "ll:GetErrorDescription", &hResult, &LanguageId) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCM->GetErrorDescription( hResult, LanguageId, &pszErrorDescription ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCM, IID_IBackgroundCopyManager ); obpErrorDescription = PyWinObject_FromWCHAR(pszErrorDescription); return obpErrorDescription; }
// @pymethod str|PyIPropertySystem|FormatForDisplay|Formats a property into a string PyObject *PyIPropertySystem::FormatForDisplay(PyObject *self, PyObject *args) { IPropertySystem *pIPS = GetI(self); if ( pIPS == NULL ) return NULL; PROPERTYKEY key; PROPVARIANT *val; PROPDESC_FORMAT_FLAGS flags = PDFF_DEFAULT; WCHAR *buf=NULL; // @pyparm <o PyPROPERTYKEY>|Key||Fmtid and property id that identifies the property // @pyparm <o PyPROPVARIANT>|Value||The value to format // @pyparm int|Flags|PDFF_DEFAULT|Combination of PROPDESC_FORMAT_FLAGS (pscon.PDFF_*) indicating formatting options if (!PyArg_ParseTuple(args, "O&O&|i:FormatForDisplay", PyWinObject_AsPROPERTYKEY, &key, PyWinObject_AsPROPVARIANT, &val, &flags)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIPS->FormatForDisplayAlloc(key, *val, flags, &buf); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPS, IID_IPropertySystem ); PyObject *ret=PyWinObject_FromWCHAR(buf); CoTaskMemFree(buf); return ret; }
// @pymethod unicode|PyIExplorerCommand|GetToolTip|Description of GetToolTip. PyObject *PyIExplorerCommand::GetToolTip(PyObject *self, PyObject *args) { IExplorerCommand *pIEC = GetI(self); if ( pIEC == NULL ) return NULL; // @pyparm <o PyIShellItemArray>|psiItemArray||Description for psiItemArray PyObject *obpsiItemArray; IShellItemArray * psiItemArray; if ( !PyArg_ParseTuple(args, "O:GetToolTip", &obpsiItemArray) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpsiItemArray, IID_IShellItemArray, (void **)&psiItemArray, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; WCHAR *psz = 0; PY_INTERFACE_PRECALL; hr = pIEC->GetToolTip(psiItemArray, &psz); if (psiItemArray) psiItemArray->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEC, IID_IExplorerCommand ); PyObject *ret = PyWinObject_FromWCHAR(psz); CoTaskMemFree(psz); return ret; }
// DS_SELECTION_LIST helpers PyObject *PyStringAsDS_SELECTION_LIST(PyObject *self, PyObject *args) { char *sz; unsigned int cb; if (!PyArg_ParseTuple(args, "s#:PyStringAsDS_SELECTION_LIST", &sz, &cb)) return NULL; if (cb < sizeof(DS_SELECTION_LIST)) return PyErr_Format(PyExc_ValueError, "String must be at least %d bytes (got %d)", sizeof(DS_SELECTION_LIST), cb); DS_SELECTION_LIST *pSL = (DS_SELECTION_LIST *)sz; PyObject *ret = PyList_New(pSL->cItems); if (!ret) return NULL; for (unsigned int i=0;i<pSL->cItems;i++) { // get attrs for this item DS_SELECTION *pItem = pSL->aDsSelection+i; PyObject *obAttr; if (pItem->pvarFetchedAttributes) { obAttr = PyList_New(pSL->cFetchedAttributes); if (!obAttr) { Py_DECREF(ret); return NULL; } for (unsigned int ia=0;ia<pSL->cFetchedAttributes;ia++) PyList_SET_ITEM(obAttr, ia, PyCom_PyObjectFromVariant(pItem->pvarFetchedAttributes+ia)); } else { obAttr = Py_None; Py_INCREF(Py_None); } PyObject *sub = Py_BuildValue("NNNNNl", PyWinObject_FromWCHAR(pItem->pwzName), PyWinObject_FromWCHAR(pItem->pwzADsPath), PyWinObject_FromWCHAR(pItem->pwzClass), PyWinObject_FromWCHAR(pItem->pwzUPN), obAttr, pItem->flScopeType); if (!sub) { Py_DECREF(ret); return NULL; } PyList_SET_ITEM(ret, i, sub); } return ret; }
// @pymethod object|PyIEnumSTATPROPSTG|Next|Retrieves a specified number of items in the enumeration sequence. PyObject *PyIEnumSTATPROPSTG::Next(PyObject *self, PyObject *args) { long celt = 1; // @pyparm int|num|1|Number of items to retrieve. if ( !PyArg_ParseTuple(args, "|l:Next", &celt) ) return NULL; IEnumSTATPROPSTG *pIESTATPROPSTG = GetI(self); if ( pIESTATPROPSTG == NULL ) return NULL; STATPROPSTG *rgVar = new STATPROPSTG[celt]; if ( rgVar == NULL ) { PyErr_SetString(PyExc_MemoryError, "allocating result STATPROPSTGs"); return NULL; } int i; /* for ( i = celt; i--; ) // *** possibly init each structure element??? */ ULONG celtFetched = 0; PY_INTERFACE_PRECALL; HRESULT hr = pIESTATPROPSTG->Next(celt, rgVar, &celtFetched); PY_INTERFACE_POSTCALL; if ( HRESULT_CODE(hr) != ERROR_NO_MORE_ITEMS && FAILED(hr) ) { delete [] rgVar; return PyCom_BuildPyException(hr); } PyObject *result = PyTuple_New(celtFetched); if ( result != NULL ) { for ( i = celtFetched; i--; ) { PyObject *ob = Py_BuildValue("NkH", PyWinObject_FromWCHAR(rgVar[i].lpwstrName), rgVar[i].propid, rgVar[i].vt); if (ob == NULL){ Py_DECREF(result); result = NULL; break; } PyTuple_SET_ITEM(result, i, ob); } } for ( i = celtFetched; i--; ) CoTaskMemFree(rgVar[i].lpwstrName); delete [] rgVar; return result; }
// --------------------------------------------------- // // Gateway Implementation STDMETHODIMP PyGInitializeWithFile::Initialize( LPCWSTR pszFilePath, DWORD grfMode) { PY_GATEWAY_METHOD; PyObject *obpath = PyWinObject_FromWCHAR(pszFilePath); if (obpath==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("Initialize"); HRESULT hr=InvokeViaPolicy("Initialize", NULL, "Ok", obpath, grfMode); Py_DECREF(obpath); return hr; }
// @pymethod object|win32ts|WTSQueryUserConfig|Returns user configuration // @rdesc The type of the returned value is dependent on the config class requested static PyObject *PyWTSQueryUserConfig(PyObject *self, PyObject *args, PyObject *kwargs) { static char *keywords[]={"ServerName","UserName","WTSConfigClass",NULL}; WCHAR *ServerName=NULL, *UserName=NULL; PyObject *obServerName, *obUserName, *ret=NULL; WTS_CONFIG_CLASS WTSConfigClass; LPWSTR buf=NULL; DWORD bufsize=0; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOk:WTSQueryUserConfig", keywords, &obServerName, // @pyparm <o PyUnicode>|ServerName||Name ot terminal server &obUserName, // @pyparm <o PyUnicode>|UserName||Name of user &WTSConfigClass)) // @pyparm int|ConfigClass||Type of information to be returned, win32ts.WTSUserConfig* return NULL; if (PyWinObject_AsWCHAR(obServerName, &ServerName, TRUE) &&PyWinObject_AsWCHAR(obUserName, &UserName, FALSE)) if (!WTSQueryUserConfig(ServerName, UserName, WTSConfigClass, &buf, &bufsize)) PyWin_SetAPIError("WTSQueryUserConfig"); else switch(WTSConfigClass){ // @flagh ConfigClass|Returned value case WTSUserConfigInitialProgram: // @flag WTSUserConfigInitialProgram|Unicode string, program to be run when user logs on case WTSUserConfigWorkingDirectory: // @flag WTSUserConfigWorkingDirectory|Unicode string, working dir for initial program case WTSUserConfigModemCallbackPhoneNumber: // @flag WTSUserConfigModemCallbackPhoneNumber|Unicode string case WTSUserConfigTerminalServerProfilePath: // @flag WTSUserConfigTerminalServerProfilePath|Unicode string case WTSUserConfigTerminalServerHomeDir: // @flag WTSUserConfigTerminalServerHomeDir|Unicode string case WTSUserConfigTerminalServerHomeDirDrive: // @flag WTSUserConfigTerminalServerHomeDirDrive|Unicode string ret=PyWinObject_FromWCHAR(buf); break; case WTSUserConfigfInheritInitialProgram: // @flag WTSUserConfigfInheritInitialProgram|Int case WTSUserConfigfAllowLogonTerminalServer: // @flag WTSUserConfigfAllowLogonTerminalServer|Int, 1 if user can log on thru Terminal Service case WTSUserConfigTimeoutSettingsConnections: // @flag WTSUserConfigTimeoutSettingsConnections |Int, max connection time (ms) case WTSUserConfigTimeoutSettingsDisconnections:// @flag WTSUserConfigTimeoutSettingsDisconnections|Int case WTSUserConfigTimeoutSettingsIdle: // @flag WTSUserConfigTimeoutSettingsIdle|Int, max idle time (ms) case WTSUserConfigfDeviceClientDrives: // @flag WTSUserConfigfDeviceClientDrives|Int case WTSUserConfigfDeviceClientPrinters: // @flag WTSUserConfigfDeviceClientPrinters|Int case WTSUserConfigfDeviceClientDefaultPrinter: // @flag WTSUserConfigfDeviceClientDefaultPrinter|Int case WTSUserConfigBrokenTimeoutSettings: // @flag WTSUserConfigBrokenTimeoutSettings|Int case WTSUserConfigReconnectSettings: // @flag WTSUserConfigReconnectSettings|Int case WTSUserConfigModemCallbackSettings: // @flag WTSUserConfigModemCallbackSettings|Int case WTSUserConfigShadowingSettings: // @flag WTSUserConfigShadowingSettings|Int, indicates if user's session my be monitored case WTSUserConfigfTerminalServerRemoteHomeDir: // @flag WTSUserConfigfTerminalServerRemoteHomeDir|Int, ret=PyLong_FromUnsignedLong(*(DWORD *)buf); break; default: PyErr_SetString(PyExc_NotImplementedError,"Config class not supported yet"); } PyWinObject_FreeWCHAR(ServerName); PyWinObject_FreeWCHAR(UserName); if (buf) WTSFreeMemory(buf); return ret; }
// @pymethod |PyIBackgroundCopyJob2|GetNotifyCmdLine|Description of GetNotifyCmdLine. PyObject *PyIBackgroundCopyJob2::GetNotifyCmdLine(PyObject *self, PyObject *args) { IBackgroundCopyJob2 *pIBCJ2 = GetI(self); if ( pIBCJ2 == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetNotifyCmdLine") ) return NULL; LPWSTR pProgram; LPWSTR pParameters; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ2->GetNotifyCmdLine( &pProgram, &pParameters ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ2, IID_IBackgroundCopyJob2 ); PyObject *ret = Py_BuildValue("NN", PyWinObject_FromWCHAR(pProgram), PyWinObject_FromWCHAR(pParameters)); CoTaskMemFree(pProgram); CoTaskMemFree(pParameters); return ret; }
PyObject *PyObject_FromBINDINFO(BINDINFO *pPD) { BOOL bNewFormat = pPD->cbSize >= offsetof(BINDINFO, dwOptions); int tupleSize = bNewFormat ? 12 : 5; PyObject *obRet = PyTuple_New(tupleSize); PyTuple_SET_ITEM(obRet, 0, PyWinObject_FromWCHAR(pPD->szExtraInfo)); Py_INCREF(Py_None); PyTuple_SET_ITEM(obRet, 1, Py_None); // STGMEDUIM not yet supported. PyTuple_SET_ITEM(obRet, 2, PyInt_FromLong(pPD->grfBindInfoF)); PyTuple_SET_ITEM(obRet, 3, PyInt_FromLong(pPD->dwBindVerb)); PyTuple_SET_ITEM(obRet, 4, PyWinObject_FromWCHAR(pPD->szCustomVerb)); if (bNewFormat) { PyTuple_SET_ITEM(obRet, 5, PyInt_FromLong(pPD->dwOptions)); PyTuple_SET_ITEM(obRet, 6, PyInt_FromLong(pPD->dwOptionsFlags)); PyTuple_SET_ITEM(obRet, 7, PyInt_FromLong(pPD->dwCodePage)); PyTuple_SET_ITEM(obRet, 8, PyWinObject_FromSECURITY_ATTRIBUTES(pPD->securityAttributes)); PyTuple_SET_ITEM(obRet, 9, PyWinObject_FromIID(pPD->iid)); PyTuple_SET_ITEM(obRet, 10, PyCom_PyObjectFromIUnknown(pPD->pUnk, pPD->iid, /*bAddRef = */TRUE)); PyTuple_SET_ITEM(obRet, 11, PyInt_FromLong(pPD->dwReserved)); } return obRet; }
// @pymethod <o PyUnicode>|pywintypes|UnicodeFromRaw|Creates a new Unicode object from raw binary data static PyObject *PyWin_NewUnicodeFromRaw(PyObject *self, PyObject *args) { PyObject *ob; // @pyparm string/buffer|str||The string containing the binary data. if (!PyArg_ParseTuple(args, "O", &ob)) return NULL; void *buf; DWORD nbytes; if (!PyWinObject_AsReadBuffer(ob, &buf, &nbytes, FALSE)) return NULL; return PyWinObject_FromWCHAR((WCHAR *)buf, nbytes/sizeof(OLECHAR) ); }
// @pymethod |PyIBackgroundCopyJob|GetProxySettings|Description of GetProxySettings. PyObject *PyIBackgroundCopyJob::GetProxySettings(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetProxySettings") ) return NULL; BG_JOB_PROXY_USAGE ProxyUsage; WCHAR *proxyList, *bypassList; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetProxySettings( &ProxyUsage, &proxyList, &bypassList ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); PyObject *ret = Py_BuildValue("lNN", ProxyUsage, PyWinObject_FromWCHAR(proxyList), PyWinObject_FromWCHAR(bypassList)); CoTaskMemFree(proxyList); CoTaskMemFree(bypassList); return ret; }
PyADS_ATTR_INFO(const ADS_ATTR_INFO *pInfo) { ob_type = &Type; _Py_NewReference(this); bufName = NULL; bufValues = NULL; obName = PyWinObject_FromWCHAR(pInfo->pszAttrName); dwControlCode = pInfo->dwControlCode; dwADsType = pInfo->dwADsType; obValues = PyList_New(pInfo->dwNumValues); if (obValues) { for (DWORD i=0;i<pInfo->dwNumValues;i++) { PyList_SET_ITEM(obValues, i, PyADSIObject_FromADSVALUE(pInfo->pADsValues[i])); } } }
// @pymethod dict|PyIServerSecurity|QueryBlanket|Retrieves security settings specified by the client PyObject *PyIServerSecurity::QueryBlanket(PyObject *self, PyObject *args) { IServerSecurity *pISS = GetI(self); if ( pISS == NULL ) return NULL; // In many methods using pPrivs, it may be a variety of different structs // but for this particular one it's just WCHAR* containing client name void *pPrivs; DWORD AuthnSvc; DWORD AuthzSvc; WCHAR *ServerPrincipalName; DWORD AuthnLevel; DWORD ImpLevel; DWORD Capabilities = 0; // @pyparm int|Capabilities|0|Can be EOAC_MAKE_FULLSIC for SChannel provider if ( !PyArg_ParseTuple(args, "|k:QueryBlanket", &Capabilities)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISS->QueryBlanket( &AuthnSvc, &AuthzSvc, &ServerPrincipalName, &AuthnLevel, &ImpLevel, &pPrivs, &Capabilities); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISS, IID_IServerSecurity ); PyObject *pyretval = Py_BuildValue("{s:k, s:k, s:N, s:k, s:k, s:N, s:k}", "AuthnSvc", AuthnSvc, "AuthzSvc", AuthzSvc, "ServerPrincipalName", PyWinObject_FromWCHAR(ServerPrincipalName), "AuthnLevel", AuthnLevel, "ImpLevel", ImpLevel, "ClientName", PyWinObject_FromWCHAR((WCHAR *)pPrivs), "Capabilities", Capabilities); CoTaskMemFree(ServerPrincipalName); return pyretval; }
PyObject *PyWinObject_FromWCHARArray(const LPOLESTR names[], ULONG cnames) { PyObject *ret = PyTuple_New(cnames); if (ret == NULL) return NULL; PyObject *item; for (ULONG i=0; i<cnames; i++){ item = PyWinObject_FromWCHAR(names[i]); if (item == NULL){ Py_DECREF(ret); return NULL; } PyTuple_SET_ITEM(ret, i, item); } return ret; }
// @pymethod str|PyIShellLibrary|GetIcon|Returns the location of the library's icon // @rdesc Uses "module,resource" format PyObject *PyIShellLibrary::GetIcon(PyObject *self, PyObject *args) { IShellLibrary *pISL = GetI(self); if ( pISL == NULL ) return NULL; LPWSTR Icon; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISL->GetIcon(&Icon); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary ); PyObject *ret = PyWinObject_FromWCHAR(Icon); CoTaskMemFree(Icon); // Docs don't specify, but this doesn't leak return ret; }
// @pymethod |PyIBackgroundCopyJob2|GetReplyFileName|Description of GetReplyFileName. PyObject *PyIBackgroundCopyJob2::GetReplyFileName(PyObject *self, PyObject *args) { IBackgroundCopyJob2 *pIBCJ2 = GetI(self); if ( pIBCJ2 == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetReplyFileName") ) return NULL; HRESULT hr; WCHAR *rfn; PY_INTERFACE_PRECALL; hr = pIBCJ2->GetReplyFileName(&rfn); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ2, IID_IBackgroundCopyJob2 ); PyObject *ret = PyWinObject_FromWCHAR(rfn); CoTaskMemFree(rfn); return ret; }
// @pymethod |PyIBackgroundCopyFile|GetLocalName|Description of GetLocalName. PyObject *PyIBackgroundCopyFile::GetLocalName(PyObject *self, PyObject *args) { IBackgroundCopyFile *pIBCF = GetI(self); if ( pIBCF == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetLocalName") ) return NULL; WCHAR *pVal; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCF->GetLocalName( &pVal ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCF, IID_IBackgroundCopyFile ); PyObject *ret = PyWinObject_FromWCHAR(pVal); CoTaskMemFree(pVal); return ret; }
// @pymethod |PyIBackgroundCopyJob|GetDisplayName|Description of GetDisplayName. PyObject *PyIBackgroundCopyJob::GetDisplayName(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; LPWSTR pVal; if ( !PyArg_ParseTuple(args, ":GetDisplayName") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetDisplayName( &pVal ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); PyObject *ret = PyWinObject_FromWCHAR(pVal); CoTaskMemFree(pVal); return ret; }