// --------------------------------------------------- // // Gateway Implementation STDMETHODIMP PyGExtractIcon::Extract( /* [unique][in] */ LPCSTR pszFile, /* [unique][in] */ UINT nIconIndex, /* [out] */ HICON * phiconLarge, /* [out] */ HICON * phiconSmall, /* [unique][in] */ UINT nIconSize) { PY_GATEWAY_METHOD; PyObject *obpszFile; obpszFile = PyString_FromString(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 |PyIShellBrowser|SetMenuSB|Attaches a shared menu to a shell view window PyObject *PyIShellBrowser::SetMenuSB(PyObject *self, PyObject *args) { IShellBrowser *pISB = GetI(self); if ( pISB == NULL ) return NULL; HMENU hmenuShared; HOLEMENU holemenuRes; HWND hwndActiveObject; PyObject *obhmenuShared, *obholemenuRes, *obhwndActiveObject; if (!PyArg_ParseTuple(args, "OOO:SetMenuSB", &obhmenuShared, // @pyparm <o PyHANDLE>|hmenuShared||Handle to the shared menu &obholemenuRes, // @pyparm <o PyHANDLE>|holemenuRes||Reserved, use only None (or 0) &obhwndActiveObject)) // @pyparm <o PyHANDLE>|hwndActiveObject||Handle to the shell window return NULL; if (!PyWinObject_AsHANDLE(obhmenuShared, (HANDLE *)&hmenuShared)) return NULL; if (!PyWinObject_AsHANDLE(obholemenuRes, (HANDLE *)&holemenuRes)) return NULL; if (!PyWinObject_AsHANDLE(obhwndActiveObject, (HANDLE *)&hwndActiveObject)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISB->SetMenuSB( hmenuShared, holemenuRes, hwndActiveObject ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); Py_INCREF(Py_None); return Py_None; }
// @pymethod int|PyCImageList|Add|Adds an image to the list. PyObject *PyCImageList_Add( PyObject *self, PyObject *args ) { PyObject *obbmp1, *obbmp2; int mask; CImageList *pList = PyCImageList::GetImageList(self); int rc; if (!pList) return NULL; if (PyArg_ParseTuple(args, "(OO)", &obbmp1, &obbmp2)) {// @pyparm (int,int)|bitmap, bitmapMask||2 Bitmaps to use (primary and mask) HBITMAP bmp1, bmp2; if (!PyWinObject_AsHANDLE(obbmp1, (HANDLE *)&bmp1) || !PyWinObject_AsHANDLE(obbmp2, (HANDLE *)&bmp2)) return NULL; if (!IsGdiHandleValid(bmp1) || !IsGdiHandleValid(bmp2)) RETURN_ERR("One of the bitmap handles is invalid"); GUI_BGN_SAVE; rc = pList->Add(CBitmap::FromHandle(bmp1), CBitmap::FromHandle(bmp2)); GUI_END_SAVE; } else { PyErr_Clear(); HBITMAP bmp1; if (PyArg_ParseTuple(args, "Oi", &obbmp1, // @pyparmalt1 int|bitmap||Bitmap to use &mask)) { // @pyparmalt1 int|color||Color to use for the mask. if (!PyWinObject_AsHANDLE(obbmp1, (HANDLE *)&bmp1)) return NULL; if (!IsGdiHandleValid(bmp1)) RETURN_ERR("The bitmap handle is invalid"); GUI_BGN_SAVE; rc = pList->Add(CBitmap::FromHandle(bmp1), (COLORREF)mask); GUI_END_SAVE; } else { PyErr_Clear(); PyObject *obIcon; if (PyArg_ParseTuple(args, "O", &obIcon)) {// @pyparmalt2 int|hIcon||Handle of an icon to add. HICON hIcon; if (!PyWinObject_AsHANDLE(obIcon, (HANDLE *)&hIcon)) return NULL; GUI_BGN_SAVE; rc = pList->Add(hIcon); GUI_END_SAVE; } else { PyErr_Clear(); RETURN_ERR("Add requires '(hbitmap, hbitmap)', 'hbitmap, color' or 'hicon'"); } } } if (rc==-1) RETURN_ERR("Add failed"); return Py_BuildValue("i", rc); // @rdesc Zero-based index of the first new image. }
// @pymethod |PyIShellBrowser|RemoveMenusSB|Asks container to remove any items it added to a composite menu PyObject *PyIShellBrowser::RemoveMenusSB(PyObject *self, PyObject *args) { IShellBrowser *pISB = GetI(self); if ( pISB == NULL ) return NULL; PyObject *obhmenuShared; HMENU hmenuShared; if (!PyArg_ParseTuple(args, "O:RemoveMenusSB", &obhmenuShared)) // @pyparm <o PyHANDLE>|hmenuShared||Handle to the composite menu return NULL; if (!PyWinObject_AsHANDLE(obhmenuShared, (HANDLE *)&hmenuShared)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISB->RemoveMenusSB( hmenuShared ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser ); Py_INCREF(Py_None); return Py_None; }
// @pymethod <o TV_ITEM>|PyCTreeCtrl|GetItem|Retrieves the details of an items attributes. PyObject *PyCTreeCtrl_GetItem( PyObject *self, PyObject *args ) { PyObject *obItem; UINT mask = TVIF_CHILDREN | TVIF_HANDLE | TVIF_IMAGE | TVIF_PARAM | TVIF_SELECTEDIMAGE | TVIF_STATE | TVIF_TEXT; if (!PyArg_ParseTuple( args, "O|i:GetItem", &obItem, // @pyparm HTREEITEM|item||The item whose attributes are to be retrieved. &mask)) // @pyparm int|mask|(all flags set)|The requested attributes. return NULL; CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; HTREEITEM item; if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item)) return NULL; TCHAR textBuf[256]; TV_ITEM tvItem; tvItem.hItem = item; tvItem.pszText = textBuf; tvItem.cchTextMax = sizeof(textBuf)/sizeof(TCHAR); tvItem.mask = mask; GUI_BGN_SAVE; BOOL ok = pList->GetItem( &tvItem); GUI_END_SAVE; if (!ok) RETURN_ERR("GetItem failed"); return PyWinObject_FromTV_ITEM(&tvItem); }
// @pymethod int|PyCTreeCtrl|SetItemText|Changes the text of a list view item or subitem. PyObject *PyCTreeCtrl_SetItemText( PyObject *self, PyObject *args ) { CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; PyObject *obItem; TCHAR *text; PyObject *obtext; if (!PyArg_ParseTuple( args, "OO:SetItemText", &obItem, // @pyparm HTREEITEM|item||The item whose text is to be retrieved. &obtext)) // @pyparm string|text||String that contains the new item text. return NULL; HTREEITEM item; if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item)) return NULL; if (!PyWinObject_AsTCHAR(obtext, &text, FALSE)) return NULL; GUI_BGN_SAVE; BOOL ok = pList->SetItemText(item, text); GUI_END_SAVE; PyWinObject_FreeTCHAR(text); if (!ok) RETURN_ERR("SetItemText failed"); RETURN_NONE; }
// @pymethod int|win32ts|WTSSendMessage|Sends a popup message to a terminal services session // @rdesc Returns one of IDABORT,IDCANCEL,IDIGNORE,IDNO,IDOK,IDRETRY,IDYES,IDASYNC,IDTIMEOUT, static PyObject *PyWTSSendMessage(PyObject *self, PyObject *args, PyObject *kwargs) { static char *keywords[]={"Server","SessionId","Title","Message","Style","Timeout","Wait", NULL}; PyObject *obh=NULL; HANDLE h; DWORD SessionId, TitleLen, MessageLen, Style, Timeout, Response; WCHAR *Title=NULL, *Message=NULL; PyObject *obTitle, *obMessage, *ret=NULL; BOOL Wait; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OkOOkkl:WTSSendMessage", keywords, &obh, // @pyparm <o PyHANDLE>|Server|WTS_CURRENT_SERVER_HANDLE|Handle to a terminal server, or WTS_CURRENT_SERVER_HANDLE &SessionId, // @pyparm int|SessionId||Terminal services session id &obTitle, // @pyparm <o PyUnicode>|Title||Title of dialog &obMessage, // @pyparm <o PyUnicode>|Message||Message to be displayed &Style, // @pyparm int|Style||Usually MB_OK &Timeout, // @pyparm int|Timeout||Seconds to wait before returning (only used if Wait is True) &Wait)) // @pyparm boolean|Wait||Specifies if function should wait for user input before returning return NULL; if (PyWinObject_AsHANDLE(obh, &h) &&PyWinObject_AsWCHAR(obTitle, &Title, FALSE, &TitleLen) &&PyWinObject_AsWCHAR(obMessage, &Message, FALSE, &MessageLen)){ if (WTSSendMessage(h, SessionId, Title, TitleLen*sizeof(WCHAR), Message, MessageLen*sizeof(WCHAR), Style, Timeout, &Response, Wait)) ret=PyLong_FromUnsignedLong(Response); else PyWin_SetAPIError("WTSSendMessage"); } PyWinObject_FreeWCHAR(Title); PyWinObject_FreeWCHAR(Message); return ret; }
STDMETHODIMP PyGShellView::CreateViewWindow( /* [in] */ IShellView * psvPrevious, /* [in] */ LPCFOLDERSETTINGS pfs, /* [in] */ IShellBrowser * psb, /* [out] */ RECT * prcView, /* [out] */ HWND * phWnd) { PY_GATEWAY_METHOD; PyObject *obpfs = PyObject_FromFOLDERSETTINGS(pfs); if (obpfs==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("CreateViewWindow"); PyObject *obrect = PyObject_FromRECT(prcView); if (obrect==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("CreateViewWindow"); PyObject *obpsvPrevious; PyObject *obpsb; obpsvPrevious = PyCom_PyObjectFromIUnknown(psvPrevious, IID_IShellView, TRUE); obpsb = PyCom_PyObjectFromIUnknown(psb, IID_IShellBrowser, TRUE); PyObject *result; HRESULT hr=InvokeViaPolicy("CreateViewWindow", &result, "OOOO", obpsvPrevious, obpfs, obpsb, obrect); Py_XDECREF(obpsvPrevious); Py_DECREF(obpfs); Py_XDECREF(obpsb); Py_DECREF(obrect); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params if (!PyWinObject_AsHANDLE(result, (HANDLE *)phWnd)) hr=MAKE_PYCOM_GATEWAY_FAILURE_CODE("CreateViewWindow"); Py_DECREF(result); return hr; }
// @pymethod |PyIQueryAssociations|Init|Initializes the IQueryAssociations interface and sets the root key to the appropriate ProgID. PyObject *PyIQueryAssociations::Init(PyObject *self, PyObject *args) { IQueryAssociations *pIQA = GetI(self); if ( pIQA == NULL ) return NULL; // @pyparm int|flags||One of shellcon.ASSOCF_* flags // @pyparm string|assoc||The string data (ie, extension, prog-id, etc) // @pyparm <o PyHKEY>|hkeyProgId|None|Root registry key, can be None // @pyparm <o PyHANDLE>|hwnd|None|Reserved, must be 0 or None int flags; HWND hwnd; HKEY hkProgid; PyObject *obAssoc, *obhwnd=Py_None, *obhkProgid=Py_None; WCHAR *pszAssoc = NULL; if (!PyArg_ParseTuple(args, "lO|OO:Init", &flags, &obAssoc, &obhkProgid, &obhwnd)) return NULL; if (!PyWinObject_AsWCHAR(obAssoc, &pszAssoc, TRUE)) return NULL; if (!PyWinObject_AsHKEY(obhkProgid, &hkProgid)) return NULL; if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIQA->Init( flags, pszAssoc, hkProgid, hwnd); PyWinObject_FreeWCHAR(pszAssoc); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIQA, IID_IQueryAssociations ); Py_INCREF(Py_None); return Py_None; }
// @pymethod list|win32api|EnumDisplayMonitors|Lists display monitors for a given device context and area // @rdesc Returns a sequence of tuples. For each monitor found, returns a handle to the monitor, // device context handle, and intersection rectangle: (hMonitor, hdcMonitor, <o PyRECT>) // @comm Accepts keyword arguments PyObject *PyEnumDisplayMonitors(PyObject *self, PyObject *args, PyObject *kwargs) { CHECK_PFN(EnumDisplayMonitors); static char *keywords[]={"hdc", "rcClip", NULL}; HDC hdc=NULL; RECT rect; LPRECT prect; PyObject *obhdc=Py_None, *obrect=Py_None; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:EnumDisplayMonitors", keywords, &obhdc, // @pyparm <o PyHANDLE>|hdc|None|Handle to device context, use None for virtual desktop &obrect)) // @pyparm <o PyRECT>|rcClip|None|Clipping rectangle, can be None return NULL; if (!PyWinObject_AsHANDLE(obhdc, (HANDLE *)&hdc)) return NULL; if (obrect==Py_None) prect=NULL; else{ if (!PyWinObject_AsRECT(obrect, &rect)) return NULL; prect=▭ } PyObject *ret=PyList_New(0); if (ret==NULL) return NULL; if (!(*pfnEnumDisplayMonitors)(hdc, prect, EnumDisplayMonitors_Callback, (LPARAM)ret)){ Py_DECREF(ret); return NULL; } return ret; }
static PyObject * py_change_clipboard_chain(PyObject* self, PyObject* args) { // @pyparm int|hWndRemove||Integer handle to the window to be removed from // the chain. The handle must have been passed to the SetClipboardViewer // function. // @pyparm int|hWndNewNext||Integer handle to the window that follows the // hWndRemove window in the clipboard viewer chain. (This is the handle // returned by SetClipboardViewer, unless the sequence was changed in // response to a WM_CHANGECBCHAIN message.) HWND hWndRemove; HWND hWndNewNext; PyObject *obhWndRemove, *obhWndNewNext; if (!PyArg_ParseTuple(args, "OO:ChangeClipboardChain", &obhWndRemove, &obhWndNewNext)) { return NULL; } if (!PyWinObject_AsHANDLE(obhWndRemove, (HANDLE *)&hWndRemove)) return NULL; if (!PyWinObject_AsHANDLE(obhWndNewNext, (HANDLE *)&hWndNewNext)) return NULL; BOOL rc; Py_BEGIN_ALLOW_THREADS; rc = ChangeClipboardChain(hWndRemove, hWndNewNext); Py_END_ALLOW_THREADS; return (Py_BuildValue("i", (int)rc)); // @comm The window identified by hWndNewNext replaces the hWndRemove window // in the chain. The SetClipboardViewer function sends a WM_CHANGECBCHAIN // message to the first window in the clipboard viewer chain. // @pyseeapi ChangeClipboardChain // @rdesc The return value indicates the result of passing the // WM_CHANGECBCHAIN message to the windows in the clipboard viewer chain. // Because a window in the chain typically returns FALSE when it processes // WM_CHANGECBCHAIN, the return value from ChangeClipboardChain is typically // FALSE. If there is only one window in the chain, the return value is // typically TRUE. }
// @pymethod |win32ts|WTSCloseServer|Closes a terminal server handle static PyObject *PyWTSCloseServer(PyObject *self, PyObject *args, PyObject *kwargs) { static char *keywords[]={"Server",NULL}; PyObject *obh; HANDLE h; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:WTSCloseServer", keywords, &obh)) // @pyparm <o PyHANDLE>|Server||Terminal Server handle return NULL; if (!PyWinObject_AsHANDLE(obh, &h)) return NULL; WTSCloseServer(h); Py_INCREF(Py_None); return Py_None; }
STDMETHODIMP PyGShellBrowser::GetControlWindow( /* [in] */ UINT id, /* [out] */ HWND * phwnd) { static const char *method_name = "GetControlWindow"; PY_GATEWAY_METHOD; PyObject *result; HRESULT hr=InvokeViaPolicy(method_name, &result, "I", id); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params if (!PyWinObject_AsHANDLE(result, (HANDLE *)phwnd)) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE(method_name); Py_DECREF(result); return hr; }
// @pymethod (int,int)|PyCTreeCtrl|GetItemState|Retrieves the state and mask of an item. // @pyparm HTREEITEM|item||The specified item // @pyparm int|stateMask||The mask for the result. PyObject *PyCTreeCtrl_GetItemState( PyObject *self, PyObject *args ) { PyObject *obItem; UINT stateMask; if (!PyArg_ParseTuple( args, "Ok:GetItemState", &obItem, &stateMask)) return NULL; CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; HTREEITEM item; if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item)) return NULL; GUI_BGN_SAVE; long state = pList->GetItemState(item, stateMask); GUI_END_SAVE; return PyInt_FromLong(state); }
// @pymethod |PyCPrintInfo|SetHDC|Sets the printer DC compatible with the users choices, call after the print dialog DoModal finishes. // @pyseemfc CPrintInfo|m_pPD // @pyseemfc CPrintDialog|m_pd.hDC static PyObject *ui_set_hdc(PyObject * self, PyObject * args) { PyObject *obdc; // @pyparm int|hdc||The DC. if (!PyArg_ParseTuple(args, "O:SetHDC", &obdc)) return NULL; HDC dc; if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&dc)) return NULL; CPrintInfo *pInfo = ui_prinfo_object::GetPrintInfo(self); if (!pInfo) return NULL; pInfo->m_pPD->m_pd.Flags |= PD_RETURNDC; pInfo->m_pPD->m_pd.hDC = dc; RETURN_NONE; }
BOOL CVirtualHelper::retval( HANDLE &ret ) { ASSERT(retVal); if (!retVal) return FALSE; // failed - assume didnt work in non debug if (retVal==Py_None) { ret = 0; return TRUE; } CEnterLeavePython _celp; if (!PyWinObject_AsHANDLE(retVal, &ret)) { gui_print_error(); return FALSE; } return TRUE; }
// @object PyMSG|A tuple representing a win32 MSG structure. BOOL PyWinObject_AsMSG(PyObject *ob, MSG *pMsg) { PyObject *obhwnd, *obwParam, *oblParam; if (!PyArg_ParseTuple(ob, "OiOOi(ii):MSG param", &obhwnd, // @tupleitem 0|<o PyHANDLE>|hwnd|Handle to the window whose window procedure receives the message. &pMsg->message, // @tupleitem 1|int|message|Specifies the message identifier. &obwParam, // @tupleitem 2|int|wParam|Specifies additional information about the message. &oblParam, // @tupleitem 3|int|lParam|Specifies additional information about the message. &pMsg->time, // @tupleitem 4|int|time|Specifies the time at which the message was posted (retrieved via GetTickCount()). &pMsg->pt.x, // @tupleitem 5|(int, int)|point|Specifies the cursor position, in screen coordinates, when the message was posted. &pMsg->pt.y)) return FALSE; return PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&pMsg->hwnd) &&PyWinObject_AsPARAM(obwParam, &pMsg->wParam) &&PyWinObject_AsPARAM(oblParam, &pMsg->lParam); }
// @pymethod |win32ts|WTSUnRegisterSessionNotification|Disables terminal service window messages static PyObject *PyWTSUnRegisterSessionNotification(PyObject *self, PyObject *args, PyObject *kwargs) { CHECK_PFN(WTSUnRegisterSessionNotification); static char *keywords[]={"Wnd", NULL}; PyObject *obhwnd; HWND hwnd; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:WTSUnRegisterSessionNotification", keywords, &obhwnd)) // @pyparm <o PyHANDLE>|Wnd||Window previously registered to receive session notifications return NULL; if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd)) return NULL; if (!(*pfnWTSUnRegisterSessionNotification)(hwnd)) PyWin_SetAPIError("WTSUnRegisterSessionNotification"); Py_INCREF(Py_None); return Py_None; }
// @pymethod int|PyCTreeCtrl|GetItemText|Retrieves the text of a list view item or subitem. PyObject *PyCTreeCtrl_GetItemText( PyObject *self, PyObject *args ) { PyObject *obItem; if (!PyArg_ParseTuple( args, "O:GetItemText", &obItem)) // @pyparm HTREEITEM|item||The item whose text is to be retrieved. return NULL; CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; HTREEITEM item; if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item)) return NULL; GUI_BGN_SAVE; CString csText = pList->GetItemText(item); GUI_END_SAVE; return PyWinObject_FromTCHAR(csText); }
// @pymethod object|PyCTreeCtrl|GetItemData|Retrieves the application-specific value associated with an item. PyObject *PyCTreeCtrl_GetItemData( PyObject *self, PyObject *args ) { PyObject *obItem; if (!PyArg_ParseTuple( args, "O:GetItemData", &obItem)) // @pyparm HTREEITEM|item||The index of the item whose data is to be retrieved. return NULL; CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; HTREEITEM item; if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item)) return NULL; GUI_BGN_SAVE; DWORD_PTR rc = pList->GetItemData(item); GUI_END_SAVE; return PyWinObject_FromDWORD_PTR(rc); }
// @pymethod int|win32ts|WTSWaitSystemEvent|Waits for an event to occur // @rdesc Returns a bitmask of WTS_EVENT_* flags indication which event(s) occurred static PyObject *PyWTSWaitSystemEvent(PyObject *self, PyObject *args, PyObject *kwargs) { static char *keywords[]={"Server", "EventMask", NULL}; PyObject *obh=NULL; HANDLE h=WTS_CURRENT_SERVER_HANDLE; DWORD EventMask=WTS_EVENT_ALL, EventFlags; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Ok:WTSWaitSystemEvent", keywords, &obh, // @pyparm <o PyHANDLE>|Server|WTS_CURRENT_SERVER_HANDLE|Handle to a terminal server, or WTS_CURRENT_SERVER_HANDLE &EventMask)) // @pyparm int|EventMask|WTS_EVENT_ALL|Combination of WTS_EVENT_* values return NULL; if (obh) if (!PyWinObject_AsHANDLE(obh, &h)) return NULL; if (!WTSWaitSystemEvent(h, EventMask, &EventFlags)) return PyWin_SetAPIError("WTSWaitSystemEvent"); return PyLong_FromUnsignedLong(EventFlags); }
// @pymethod |win32ts|WTSShutdownSystem|Issues a shutdown request to a terminal server static PyObject *PyWTSShutdownSystem(PyObject *self, PyObject *args, PyObject *kwargs) { static char *keywords[]={"Server", "ShutdownFlag", NULL}; PyObject *obh; HANDLE h; DWORD flags; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Ok:WTSShutdownSystem", keywords, &obh, // @pyparm <o PyHANDLE>|Server||Handle to a terminal server &flags)) // @pyparm int|ShutdownFlag||One of the win32ts.WTS_WSD_* values return NULL; if (!PyWinObject_AsHANDLE(obh, &h)) return NULL; if (!WTSShutdownSystem(h, flags)) return PyWin_SetAPIError("WTSShutdownSystem"); Py_INCREF(Py_None); return Py_None; }
// @pymethod |win32ts|WTSRegisterSessionNotification|Registers a window to receive terminal service notifications static PyObject *PyWTSRegisterSessionNotification(PyObject *self, PyObject *args, PyObject *kwargs) { CHECK_PFN(WTSRegisterSessionNotification); static char *keywords[]={"Wnd","Flags", NULL}; PyObject *obhwnd; HWND hwnd; DWORD flags; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Ok:WTSRegisterSessionNotification", keywords, &obhwnd, // @pyparm <o PyHANDLE>|Wnd||Window handle to receive terminal service messages &flags)) // @pyparm int|Flags||NOTIFY_FOR_THIS_SESSION or NOTIFY_FOR_ALL_SESSIONS return NULL; if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd)) return NULL; if (!(*pfnWTSRegisterSessionNotification)(hwnd, flags)) PyWin_SetAPIError("WTSRegisterSessionNotification"); Py_INCREF(Py_None); return Py_None; }
// @pymethod |win32ts|WTSTerminateProcess|Kills a process on a terminal server static PyObject *PyWTSTerminateProcess(PyObject *self, PyObject *args, PyObject *kwargs) { static char *keywords[]={"Server", "ProcessId", "ExitCode", NULL}; PyObject *obh; HANDLE h; DWORD ProcessId, ExitCode; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Okk:WTSTerminateProcess", keywords, &obh, // @pyparm <o PyHANDLE>|Server||Handle to a terminal server &ProcessId, // @pyparm int|ProcessId||Id of a process as returned by <om win32ts.WTSEnumerateProcesses> &ExitCode)) // @pyparm int|ExitCode||Exit code for the process return NULL; if (!PyWinObject_AsHANDLE(obh, &h)) return NULL; if (!WTSTerminateProcess(h, ProcessId, ExitCode)) return PyWin_SetAPIError("WTSTerminateProcess"); Py_INCREF(Py_None); return Py_None; }
// @pymethod <o PyCEdit>|PyCTreeCtrl|EditLabel|Edits a specified tree view item in-place. PyObject *PyCTreeCtrl_EditLabel( PyObject *self, PyObject *args ) { CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; PyObject *obItem; // @pyparm HTREEITEM|item||The item to edit. if (!PyArg_ParseTuple( args, "O:EditLabel", &obItem)) return NULL; HTREEITEM item; if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item)) return NULL; GUI_BGN_SAVE; CEdit *pEdit = pList->EditLabel(item); GUI_END_SAVE; if (pEdit==NULL) RETURN_ERR("EditLabel failed"); return ui_assoc_object::make(UITypeFromCObject(pEdit), pEdit)->GetGoodRet(); }
// @pymethod int|PyCTreeCtrl|EnsureVisible|Ensures that a tree view item is visible in its tree view control. PyObject *PyCTreeCtrl_EnsureVisible( PyObject *self, PyObject *args ) { CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; PyObject *obItem; // @pyparm HTREEITEM|item||The item to edit. if (!PyArg_ParseTuple( args, "O:EnsureVisible", &obItem)) return NULL; HTREEITEM item; if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item)) return NULL; GUI_BGN_SAVE; BOOL ok = pList->EnsureVisible(item); GUI_END_SAVE; if (!ok) RETURN_ERR("EnsureVisible failed"); RETURN_NONE; }
// @pymethod <o PyCImageList>|PyCTreeCtrl|CreateDragImage|Creates a dragging bitmap for the specified tree view item. PyObject *PyCTreeCtrl_CreateDragImage( PyObject *self, PyObject *args ) { CTreeCtrl *pList = GetTreeCtrl(self); if (!pList) return NULL; PyObject *obItem; // @pyparm HTREEITEM|item||The item to edit. if (!PyArg_ParseTuple( args, "O:CreateDragImage", &obItem)) return NULL; HTREEITEM item; if (!PyWinObject_AsHANDLE(obItem, (HANDLE *)&item)) return NULL; GUI_BGN_SAVE; CImageList *pIL = pList->CreateDragImage(item); GUI_END_SAVE; if (pIL==NULL) RETURN_ERR("CreateDragImage failed"); return ui_assoc_object::make(PyCImageList::type, pIL)->GetGoodRet(); }
// @pymethod |PyIDirectSound|SetCooperativeLevel|The IDirectSound::SetCooperativeLevel method sets the cooperative level of the application for this sound device. PyObject *PyIDirectSound::SetCooperativeLevel(PyObject *self, PyObject *args) { int level; PyObject *obHWND = NULL; HWND hwnd; IDirectSound *pIDS = GetI(self); if ( pIDS == NULL ) return NULL; if ( !PyArg_ParseTuple(args, "Oi:SetCooperativeLevel", &obHWND, // @pyparm int|hwnd||Window handle to the application or None. &level) ) // @pyparm int|level||Requested priority level. Specify one of the following values: // @flagh Level|Description // @flag DSSCL_NORMAL|Sets the application to a fully cooperative status. Most applications should use this level, because it has the smoothest multitasking and resource-sharing behavior. // @flag DSSCL_PRIORITY|Sets the application to the priority level. Applications with this cooperative level can call the DirectSoundBuffer.setFormat and DirectSound.compact methods. // @flag DSSCL_EXCLUSIVE|Sets the application to the exclusive level. When it has the input focus, the application will be the only one audible (sounds from applications with the DSBCAPS_GLOBALFOCUS flag set will be muted). With this level, it also has all the privileges of the DSSCL_PRIORITY level. DirectSound will restore the hardware format, as specified by the most recent call to the DirectSoundBuffer.setFormat method, once the application gains the input focus. (Note that DirectSound will always restore the wave format, no matter what priority level is set.) // @flag DSSCL_WRITEPRIMARY|This is the highest priority level. The application has write access to the primary sound buffers. No secondary sound buffers in any application can be played. return NULL; if (!PyWinObject_AsHANDLE(obHWND, (HANDLE *)&hwnd)) return NULL; if (hwnd == NULL) { hwnd = GetForegroundWindow(); if (hwnd == NULL) { hwnd = GetDesktopWindow(); } } HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDS->SetCooperativeLevel(hwnd, level); PY_INTERFACE_POSTCALL; if (FAILED(hr)) { PyWin_SetAPIError("SetCooperativeLevel", hr); return NULL; } Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyICopyHookA|CopyCallback|Description of CopyCallback. PyObject *PyICopyHookA::CopyCallback(PyObject *self, PyObject *args) { ICopyHookA *pICH = GetI(self); if ( pICH == NULL ) return NULL; // @pyparm HWND|hwnd||Description for hwnd // @pyparm int|wFunc||Description for wFunc // @pyparm int|wFlags||Description for wFlags // @pyparm string/<o unicode>|srcFile||Description for srcFile // @pyparm int|srcAttribs||Description for srcAttribs // @pyparm string/<o unicode>|destFile||Description for destFile // @pyparm int|destAttribs||Description for destAttribs PyObject *obsrcFile; PyObject *obdestFile; HWND hwnd; PyObject *obhwnd; UINT wFunc; UINT wFlags; LPSTR srcFile; DWORD srcAttribs; LPSTR destFile; DWORD destAttribs; if ( !PyArg_ParseTuple(args, "OiiOlOl:CopyCallback", &obhwnd, &wFunc, &wFlags, &obsrcFile, &srcAttribs, &obdestFile, &destAttribs) ) return NULL; if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd)) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyWinObject_AsString(obsrcFile, &srcFile)) bPythonIsHappy = FALSE; if (bPythonIsHappy && !PyWinObject_AsString(obdestFile, &destFile)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pICH->CopyCallback( hwnd, wFunc, wFlags, srcFile, srcAttribs, destFile, destAttribs ); PyWinObject_FreeString(srcFile); PyWinObject_FreeString(destFile); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pICH, IID_IShellCopyHook ); Py_INCREF(Py_None); return Py_None; }
// @pymethod |PyIShellLink|Resolve|Resolves a shell link by searching for the shell link object and updating the // shell link path and its list of identifiers (if necessary) PyObject *PyIShellLink::Resolve(PyObject *self, PyObject *args) { IShellLink *pISL = GetI(self); if ( pISL == NULL ) return NULL; // @pyparm HWND|hwnd||The parent window of a dialog which will pop up if resolution fails. // @pyparm int|fFlags||One of the following constants: // @flagh Value|Description // @flag SLR_INVOKE_MSI|Call the Microsoft Windows Installer. // @flag SLR_NOLINKINFO |Disable distributed link tracking. By default, distributed // link tracking tracks removable media across multiple devices based on the // volume name. It also uses the UNC path to track remote file systems whose // drive letter has changed. Setting SLR_NOLINKINFO disables both types of tracking. // @flag SLR_NO_UI|Do not display a dialog box if the link cannot be resolved. When // SLR_NO_UI is set, the high-order word of fFlags can be set to a time-out value // that specifies the maximum amount of time to be spent resolving the link. The // function returns if the link cannot be resolved within the time-out duration. // If the high-order word is set to zero, the time-out duration will be set to the // default value of 3,000 milliseconds (3 seconds). To specify a value, set the high // word of fFlags to the desired time-out duration, in milliseconds. // @flag SLR_NOUPDATE|Do not update the link information. // @flag SLR_NOSEARCH|Do not execute the search heuristics. // @flag SLR_NOTRACK|Do not use distributed link tracking. // @flag SLR_UPDATE|If the link object has changed, update its path and list of identifiers. If SLR_UPDATE is set, you do not need to call IPersistFile::IsDirty to determine whether or not the link object has changed. HWND hwnd; PyObject *obhwnd; DWORD fFlags; if ( !PyArg_ParseTuple(args, "Ol:Resolve", &obhwnd, &fFlags) ) return NULL; if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&hwnd)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pISL->Resolve( hwnd, fFlags ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return OleSetOleError(hr); Py_INCREF(Py_None); return Py_None; }