[pywin32-checkins] pywin32/com/win32comext/shell/src shell.cpp,1.37,1.38
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Roger U. <ru...@us...> - 2005-10-17 00:16:00
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28472/com/win32comext/shell/src Modified Files: shell.cpp Log Message: Add SHSetFolderPath, some autoduck fixes Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** shell.cpp 16 May 2005 07:09:39 -0000 1.37 --- shell.cpp 17 Oct 2005 00:15:51 -0000 1.38 *************** *** 60,63 **** --- 60,66 ---- static PFNSHGetFolderPath pfnSHGetFolderPath = NULL; + typedef HRESULT (WINAPI *PFNSHSetFolderPath)(int, HANDLE, DWORD, LPCWSTR); + static PFNSHSetFolderPath pfnSHSetFolderPath = NULL; + typedef HRESULT (WINAPI *PFNSHQueryRecycleBin)(LPCWSTR, LPSHQUERYRBINFO); static PFNSHQueryRecycleBin pfnSHQueryRecycleBin = NULL; *************** *** 72,75 **** --- 75,81 ---- static PFNAssocCreate pfnAssocCreate = NULL; + typedef LRESULT (WINAPI *PFNSHShellFolderView_Message)(HWND, UINT, LPARAM); + static PFNSHShellFolderView_Message pfnSHShellFolderView_Message = NULL; + void PyShell_FreeMem(void *p) { *************** *** 1134,1137 **** --- 1140,1176 ---- } + // @pymethod |shell|SHSetFolderPath|Sets the location of one of the special folders + // @comm This function is only available on Windows 2000 or later + static PyObject *PySHSetFolderPath(PyObject *self, PyObject *args) + { + int csidl; + HANDLE hToken; + DWORD Flags=0; // Flags is reserved + PyObject *obToken=Py_None, *obPath; + WCHAR *Path; + + if (pfnSHSetFolderPath==NULL) + return OleSetOleError(E_NOTIMPL); + if(!PyArg_ParseTuple(args, "lO|O:SHSetFolderPath", + &csidl, // @pyparm int|csidl||One of the shellcon.CSIDL_* values + &obPath, // @pyparm str/unicode|Path||The full path to be set + &obToken)) // @pyparm <o PyHANDLE>|hToken|None|Handle to an access token, can be None + return NULL; + if (!PyWinObject_AsHANDLE(obToken, &hToken, TRUE)) + return NULL; + if (!PyWinObject_AsWCHAR(obPath, &Path, FALSE)) + return NULL; + + PY_INTERFACE_PRECALL; + HRESULT hr = (*pfnSHSetFolderPath)(csidl, hToken, Flags, Path); + PY_INTERFACE_POSTCALL; + + PyWinObject_FreeWCHAR(Path); + if (FAILED(hr)) + return OleSetOleError(hr); + Py_INCREF(Py_None); + return Py_None; + } + // @pymethod <o PyIDL>|shell|SHGetFolderLocation|Retrieves the PIDL of a folder. static PyObject *PySHGetFolderLocation(PyObject *self, PyObject *args) *************** *** 1256,1260 **** static PyObject *PySHGetDesktopFolder(PyObject *self, PyObject *args) { ! if (!PyArg_ParseTuple(args, ":SHGetPathFromIDList")) return NULL; IShellFolder *psf; --- 1295,1299 ---- static PyObject *PySHGetDesktopFolder(PyObject *self, PyObject *args) { ! if (!PyArg_ParseTuple(args, ":SHGetDesktopFolder")) return NULL; IShellFolder *psf; *************** *** 1274,1281 **** int index, imageIndex; if(!PyArg_ParseTuple(args, "Oiii:SHUpdateImage", ! &obHash, ! &index, ! &flags, ! &imageIndex)) return NULL; --- 1313,1320 ---- int index, imageIndex; if(!PyArg_ParseTuple(args, "Oiii:SHUpdateImage", ! &obHash, // @pyparm string|HashItem||Full path of file containing the icon as returned by <om PyIExtractIcon.GetIconLocation> ! &index, // @pyparm int|Index||Index of the icon in the above file ! &flags, // @pyparm int|Flags||GIL_NOTFILENAME or GIL_SIMULATEDOC ! &imageIndex)) // @pyparm int|ImageIndex||Index of the icon in the system image list return NULL; *************** *** 1298,1305 **** PyObject *ob1, *ob2 = Py_None; if(!PyArg_ParseTuple(args, "iiO|O:SHChangeNotify", ! &wEventID, ! &flags, ! &ob1, ! &ob2)) return NULL; --- 1337,1345 ---- PyObject *ob1, *ob2 = Py_None; if(!PyArg_ParseTuple(args, "iiO|O:SHChangeNotify", ! &wEventID, // @pyparm int|EventId||Combination of shellcon.SHCNE_* constants ! &flags, // @pyparm int|Flags||Combination of shellcon.SHCNF_* constants that specify type of last 2 parameters ! // Only one of the type flags may be specified, combined with one of the SHCNF_FLUSH* flags ! &ob1, // @pyparm object|Item1||Type is dependent on the event to be signalled ! &ob2)) // @pyparm object|Item2||Type is dependent on the event to be signalled return NULL; *************** *** 2070,2073 **** --- 2110,2114 ---- } + /* List of module functions */ // @module shell|A module, encapsulating the ActiveX Control interfaces *************** *** 2081,2085 **** { "SHGetFileInfo", PySHGetFileInfo, 1}, // @pymeth SHGetFileInfo|Retrieves information about an object in the file system, such as a file, a folder, a directory, or a drive root. { "SHGetFolderPath", PySHGetFolderPath, 1 }, // @pymeth SHGetFolderPath|Retrieves the path of a folder. ! { "SHGetFolderLocation", PySHGetFolderLocation, 1 }, // @pymeth SHGetFolderLocation|Retrieves the <o PyIDL> of a folder. { "SHGetSpecialFolderPath", PySHGetSpecialFolderPath, 1 }, // @pymeth SHGetSpecialFolderPath|Retrieves the path of a special folder. { "SHGetSpecialFolderLocation", PySHGetSpecialFolderLocation, 1 }, // @pymeth SHGetSpecialFolderLocation|Retrieves the <o PyIDL> of a special folder. --- 2122,2127 ---- { "SHGetFileInfo", PySHGetFileInfo, 1}, // @pymeth SHGetFileInfo|Retrieves information about an object in the file system, such as a file, a folder, a directory, or a drive root. { "SHGetFolderPath", PySHGetFolderPath, 1 }, // @pymeth SHGetFolderPath|Retrieves the path of a folder. ! { "SHSetFolderPath", PySHSetFolderPath, 1 }, // @pymeth SHSetFolderPath|Sets the location of a special folder ! { "SHGetFolderLocation", PySHGetFolderLocation, 1 }, // @pymeth SHGetFolderLocation|Retrieves the <o PyIDL> of a folder. { "SHGetSpecialFolderPath", PySHGetSpecialFolderPath, 1 }, // @pymeth SHGetSpecialFolderPath|Retrieves the path of a special folder. { "SHGetSpecialFolderLocation", PySHGetSpecialFolderLocation, 1 }, // @pymeth SHGetSpecialFolderLocation|Retrieves the <o PyIDL> of a special folder. *************** *** 2189,2193 **** --- 2231,2238 ---- pfnSHGetSettings = (PFNSHGetSettings)GetProcAddress(shell32, "SHGetSettings"); pfnSHGetFolderPath=(PFNSHGetFolderPath)GetProcAddress(shell32, "SHGetFolderPathW"); + // For some reason, SHSetFolderPath is only exported by ordinal SHSetFolderPathA is 231 + pfnSHSetFolderPath=(PFNSHSetFolderPath)GetProcAddress(shell32, (LPCSTR)232); pfnSHILCreateFromPath=(PFNSHILCreateFromPath)GetProcAddress(shell32, "SHILCreateFromPath"); + pfnSHShellFolderView_Message=(PFNSHShellFolderView_Message)GetProcAddress(shell32, "SHShellFolderView_Message"); } // SHGetFolderPath comes from shfolder.dll on older systems |