From: <mha...@us...> - 2003-10-07 02:31:19
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1:/tmp/cvs-serv1960 Modified Files: shell.cpp PyIShellLink.cpp Log Message: Make unicode aware (but still built as ansi) Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** shell.cpp 6 Oct 2003 12:47:57 -0000 1.6 --- shell.cpp 7 Oct 2003 02:31:08 -0000 1.7 *************** *** 256,260 **** // WIN32_FIND_DATA implementation. // NOTE: Cloned from win32api.cpp ! PyObject *PyObject_FromWIN32_FIND_DATA(WIN32_FIND_DATAA &findData) { PyObject *obCreateTime = PyWinObject_FromFILETIME(findData.ftCreationTime); --- 256,260 ---- // WIN32_FIND_DATA implementation. // NOTE: Cloned from win32api.cpp ! PyObject *PyObject_FromWIN32_FIND_DATA(WIN32_FIND_DATA &findData) { PyObject *obCreateTime = PyWinObject_FromFILETIME(findData.ftCreationTime); *************** *** 264,268 **** return NULL; ! PyObject *ret = Py_BuildValue("lOOOllllss", // @rdesc The return value is a list of tuples, in the same format as the WIN32_FIND_DATA structure: findData.dwFileAttributes, // @tupleitem 0|int|attributes|File Attributes. A combination of the win32com.FILE_ATTRIBUTE_* flags. --- 264,268 ---- return NULL; ! PyObject *ret = Py_BuildValue("lOOOllllNN", // @rdesc The return value is a list of tuples, in the same format as the WIN32_FIND_DATA structure: findData.dwFileAttributes, // @tupleitem 0|int|attributes|File Attributes. A combination of the win32com.FILE_ATTRIBUTE_* flags. *************** *** 274,279 **** findData.dwReserved0, // @tupleitem 6|int|reserved0|Reserved. findData.dwReserved1, // @tupleitem 7|int|reserved1|Reserved. ! findData.cFileName, // @tupleitem 8|string|fileName|The name of the file. ! findData.cAlternateFileName ); // @tupleitem 9|string|alternateFilename|Alternative name of the file, expressed in 8.3 format. Py_DECREF(obCreateTime); Py_DECREF(obAccessTime); --- 274,279 ---- findData.dwReserved0, // @tupleitem 6|int|reserved0|Reserved. findData.dwReserved1, // @tupleitem 7|int|reserved1|Reserved. ! PyWinObject_FromTCHAR(findData.cFileName), // @tupleitem 8|string|fileName|The name of the file. ! PyWinObject_FromTCHAR(findData.cAlternateFileName) ); // @tupleitem 9|string|alternateFilename|Alternative name of the file, expressed in 8.3 format. Py_DECREF(obCreateTime); Py_DECREF(obAccessTime); *************** *** 346,350 **** static PyObject *PySHGetPathFromIDList(PyObject *self, PyObject *args) { ! char buffer[MAX_PATH]; PyObject *rc; LPITEMIDLIST pidl; --- 346,350 ---- static PyObject *PySHGetPathFromIDList(PyObject *self, PyObject *args) { ! TCHAR buffer[MAX_PATH]; PyObject *rc; LPITEMIDLIST pidl; *************** *** 387,391 **** // will be raised. If the function fails, a COM Exception with // HRESULT=E_FAIL will be raised. ! HMODULE hmod = GetModuleHandle("shell32.dll"); PFNSHGetSpecialFolderPath pfnSHGetSpecialFolderPath = (PFNSHGetSpecialFolderPath)GetProcAddress(hmod, "SHGetSpecialFolderPathW"); if (pfnSHGetSpecialFolderPath==NULL) --- 387,391 ---- // will be raised. If the function fails, a COM Exception with // HRESULT=E_FAIL will be raised. ! HMODULE hmod = GetModuleHandle(TEXT("shell32.dll")); PFNSHGetSpecialFolderPath pfnSHGetSpecialFolderPath = (PFNSHGetSpecialFolderPath)GetProcAddress(hmod, "SHGetSpecialFolderPathW"); if (pfnSHGetSpecialFolderPath==NULL) *************** *** 443,447 **** // @comm This method is only available if you have shfolder.dll installed, included with certain shell updates. ! HMODULE hmod = LoadLibrary("shfolder.dll"); PFNSHGetFolderPath pfnSHGetFolderPath = NULL; if (hmod) pfnSHGetFolderPath=(PFNSHGetFolderPath)GetProcAddress(hmod, "SHGetFolderPathW"); --- 443,447 ---- // @comm This method is only available if you have shfolder.dll installed, included with certain shell updates. ! HMODULE hmod = LoadLibrary(TEXT("shfolder.dll")); PFNSHGetFolderPath pfnSHGetFolderPath = NULL; if (hmod) pfnSHGetFolderPath=(PFNSHGetFolderPath)GetProcAddress(hmod, "SHGetFolderPathW"); *************** *** 486,490 **** // @comm This method is only available if you have a late version of shfolder.dll installed, included with certain shell updates. ! HMODULE hmod = LoadLibrary("shfolder.dll"); PFNSHGetFolderLocation pfnSHGetFolderLocation = NULL; if (hmod) pfnSHGetFolderLocation=(PFNSHGetFolderLocation)GetProcAddress(hmod, "SHGetFolderLocationW"); --- 486,490 ---- // @comm This method is only available if you have a late version of shfolder.dll installed, included with certain shell updates. ! HMODULE hmod = LoadLibrary(TEXT("shfolder.dll")); PFNSHGetFolderLocation pfnSHGetFolderLocation = NULL; if (hmod) pfnSHGetFolderLocation=(PFNSHGetFolderLocation)GetProcAddress(hmod, "SHGetFolderLocationW"); *************** *** 535,539 **** typedef HRESULT (* PFNSHEmptyRecycleBin)(HWND, LPSTR, DWORD ); // @comm This method is only available in shell version 4.71. If the function is not available, a COM Exception with HRESULT=E_NOTIMPL will be raised. ! HMODULE hmod = GetModuleHandle("shell32.dll"); PFNSHEmptyRecycleBin pfnSHEmptyRecycleBin = (PFNSHEmptyRecycleBin)GetProcAddress(hmod, "SHEmptyRecycleBinA"); if (pfnSHEmptyRecycleBin==NULL) --- 535,539 ---- typedef HRESULT (* PFNSHEmptyRecycleBin)(HWND, LPSTR, DWORD ); // @comm This method is only available in shell version 4.71. If the function is not available, a COM Exception with HRESULT=E_NOTIMPL will be raised. ! HMODULE hmod = GetModuleHandle(TEXT("shell32.dll")); PFNSHEmptyRecycleBin pfnSHEmptyRecycleBin = (PFNSHEmptyRecycleBin)GetProcAddress(hmod, "SHEmptyRecycleBinA"); if (pfnSHEmptyRecycleBin==NULL) *************** *** 566,574 **** static PyObject *PySHUpdateImage(PyObject *self, PyObject *args) { ! char *szHash; UINT flags; int index, imageIndex; ! if(!PyArg_ParseTuple(args, "siii:SHUpdateImage", ! &szHash, &index, &flags, --- 566,574 ---- static PyObject *PySHUpdateImage(PyObject *self, PyObject *args) { ! PyObject *obHash; UINT flags; int index, imageIndex; ! if(!PyArg_ParseTuple(args, "Oiii:SHUpdateImage", ! &obHash, &index, &flags, *************** *** 576,582 **** --- 576,586 ---- return NULL; + TCHAR *szHash; + if (!PyWinObject_AsTCHAR(obHash, &szHash)) + return NULL; PY_INTERFACE_PRECALL; SHUpdateImage(szHash, index, flags, imageIndex); PY_INTERFACE_POSTCALL; + PyWinObject_FreeTCHAR(szHash); Py_INCREF(Py_None); return Py_None; Index: PyIShellLink.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellLink.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyIShellLink.cpp 6 Oct 2003 12:47:57 -0000 1.4 --- PyIShellLink.cpp 7 Oct 2003 02:31:08 -0000 1.5 *************** *** 6,10 **** ! PyObject *PyObject_FromWIN32_FIND_DATA(WIN32_FIND_DATAA &findData); --- 6,10 ---- ! PyObject *PyObject_FromWIN32_FIND_DATA(WIN32_FIND_DATA &findData); *************** *** 35,39 **** if ( pISL == NULL ) return NULL; ! WIN32_FIND_DATAA fd; // @pyparm int|fFlags||One of the following values: // @flagh Value|Description --- 35,39 ---- if ( pISL == NULL ) return NULL; ! WIN32_FIND_DATA fd; // @pyparm int|fFlags||One of the following values: // @flagh Value|Description *************** *** 47,51 **** return NULL; HRESULT hr; ! char *pszFile = (char *)malloc(cchMaxPath); if (pszFile==NULL) { PyErr_SetString(PyExc_MemoryError, "allocating string buffer"); --- 47,51 ---- return NULL; HRESULT hr; ! TCHAR *pszFile = (TCHAR *)malloc(cchMaxPath * sizeof(TCHAR)); if (pszFile==NULL) { PyErr_SetString(PyExc_MemoryError, "allocating string buffer"); *************** *** 61,66 **** } PyObject *obFD = PyObject_FromWIN32_FIND_DATA(fd); ! PyObject *ret = Py_BuildValue("sO", pszFile, obFD); ! Py_XDECREF(obFD); free(pszFile); return ret; --- 61,66 ---- } PyObject *obFD = PyObject_FromWIN32_FIND_DATA(fd); ! PyObject *obFile = PyWinObject_FromTCHAR(pszFile); ! PyObject *ret = Py_BuildValue("NN", obFile, obFD); free(pszFile); return ret; *************** *** 123,127 **** return NULL; HRESULT hr; ! char *pszName = (char *)malloc(cchMaxName * sizeof(char) ); if (pszName==NULL) { PyErr_SetString(PyExc_MemoryError, "allocating string buffer"); --- 123,127 ---- return NULL; HRESULT hr; ! TCHAR *pszName = (TCHAR *)malloc(cchMaxName * sizeof(TCHAR) ); if (pszName==NULL) { PyErr_SetString(PyExc_MemoryError, "allocating string buffer"); *************** *** 136,140 **** ret = OleSetOleError(hr); else ! ret = PyString_FromString(pszName); free(pszName); return ret; --- 136,140 ---- ret = OleSetOleError(hr); else ! ret = PyWinObject_FromTCHAR(pszName); free(pszName); return ret; *************** *** 147,152 **** if ( pISL == NULL ) return NULL; ! char *pszName; ! if ( !PyArg_ParseTuple(args, "s:SetDescription", &pszName) ) return NULL; HRESULT hr; --- 147,155 ---- if ( pISL == NULL ) return NULL; ! PyObject *obName; ! if ( !PyArg_ParseTuple(args, "O:SetDescription", &obName) ) ! return NULL; ! TCHAR *pszName; ! if (!PyWinObject_AsTCHAR(obName, &pszName)) return NULL; HRESULT hr; *************** *** 154,157 **** --- 157,161 ---- hr = pISL->SetDescription( pszName ); PY_INTERFACE_POSTCALL; + PyWinObject_FreeTCHAR(pszName); if ( FAILED(hr) ) *************** *** 172,176 **** return NULL; HRESULT hr; ! char *pszName = (char *)malloc(cchMaxName * sizeof(char) ); if (pszName==NULL) { PyErr_SetString(PyExc_MemoryError, "allocating string buffer"); --- 176,180 ---- return NULL; HRESULT hr; ! TCHAR *pszName = (TCHAR *)malloc(cchMaxName * sizeof(TCHAR) ); if (pszName==NULL) { PyErr_SetString(PyExc_MemoryError, "allocating string buffer"); *************** *** 185,189 **** ret = OleSetOleError(hr); else ! ret = PyString_FromString(pszName); free(pszName); return ret; --- 189,193 ---- ret = OleSetOleError(hr); else ! ret = PyWinObject_FromTCHAR(pszName); free(pszName); return ret; *************** *** 196,206 **** if ( pISL == NULL ) return NULL; ! LPCSTR pszDir; ! if ( !PyArg_ParseTuple(args, "s:SetWorkingDirectory", &pszDir) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pISL->SetWorkingDirectory( pszDir ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) --- 200,214 ---- if ( pISL == NULL ) return NULL; ! PyObject *obName; ! if ( !PyArg_ParseTuple(args, "O:SetWorkingDirectory", &obName) ) ! return NULL; ! TCHAR *pszName; ! if (!PyWinObject_AsTCHAR(obName, &pszName)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pISL->SetWorkingDirectory( pszName ); PY_INTERFACE_POSTCALL; + PyWinObject_FreeTCHAR(pszName); if ( FAILED(hr) ) *************** *** 222,226 **** return NULL; HRESULT hr; ! char *pszName = (char *)malloc(cchMaxName * sizeof(char) ); if (pszName==NULL) { PyErr_SetString(PyExc_MemoryError, "allocating string buffer"); --- 230,234 ---- return NULL; HRESULT hr; ! TCHAR *pszName = (TCHAR *)malloc(cchMaxName * sizeof(TCHAR) ); if (pszName==NULL) { PyErr_SetString(PyExc_MemoryError, "allocating string buffer"); *************** *** 235,239 **** ret = OleSetOleError(hr); else ! ret = PyString_FromString(pszName); free(pszName); return ret; --- 243,247 ---- ret = OleSetOleError(hr); else ! ret = PyWinObject_FromTCHAR(pszName); free(pszName); return ret; *************** *** 246,252 **** if ( pISL == NULL ) return NULL; ! LPCSTR pszArgs; // @pyparm string|args||The new arguments. ! if ( !PyArg_ParseTuple(args, "s:SetArguments", &pszArgs) ) return NULL; HRESULT hr; --- 254,263 ---- if ( pISL == NULL ) return NULL; ! PyObject *obArgs; // @pyparm string|args||The new arguments. ! if ( !PyArg_ParseTuple(args, "O:SetArguments", &obArgs) ) ! return NULL; ! TCHAR *pszArgs; ! if (!PyWinObject_AsTCHAR(obArgs, &pszArgs)) return NULL; HRESULT hr; *************** *** 254,257 **** --- 265,269 ---- hr = pISL->SetArguments( pszArgs ); PY_INTERFACE_POSTCALL; + PyWinObject_FreeTCHAR(pszArgs); if ( FAILED(hr) ) *************** *** 356,360 **** if ( !PyArg_ParseTuple(args, "|i:GetIconLocation", &cchIconPath) ) return NULL; ! char *pszIconPath = (char *)malloc(cchIconPath * sizeof(char) ); if (pszIconPath==NULL) { PyErr_SetString(PyExc_MemoryError, "allocating string buffer"); --- 368,372 ---- if ( !PyArg_ParseTuple(args, "|i:GetIconLocation", &cchIconPath) ) return NULL; ! TCHAR *pszIconPath = (TCHAR *)malloc(cchIconPath * sizeof(TCHAR) ); if (pszIconPath==NULL) { PyErr_SetString(PyExc_MemoryError, "allocating string buffer"); *************** *** 371,375 **** ret = OleSetOleError(hr); else ! ret = Py_BuildValue("si", pszIconPath, iIcon); free(pszIconPath); return ret; --- 383,387 ---- ret = OleSetOleError(hr); else ! ret = Py_BuildValue("Ni", PyWinObject_FromTCHAR(pszIconPath), iIcon); free(pszIconPath); return ret; *************** *** 382,390 **** if ( pISL == NULL ) return NULL; ! LPCSTR pszIconPath; // @pyparm string|iconPath||Path to the file with the icon. // @pyparm int|iIcon||Index of the icon. int iIcon; ! if ( !PyArg_ParseTuple(args, "si:SetIconLocation", &pszIconPath, &iIcon) ) return NULL; HRESULT hr; --- 394,405 ---- if ( pISL == NULL ) return NULL; ! PyObject *obIconPath; // @pyparm string|iconPath||Path to the file with the icon. // @pyparm int|iIcon||Index of the icon. int iIcon; ! if ( !PyArg_ParseTuple(args, "Oi:SetIconLocation", &obIconPath, &iIcon) ) ! return NULL; ! TCHAR *pszIconPath; ! if (!PyWinObject_AsTCHAR(obIconPath, &pszIconPath)) return NULL; HRESULT hr; *************** *** 392,395 **** --- 407,411 ---- hr = pISL->SetIconLocation( pszIconPath, iIcon ); PY_INTERFACE_POSTCALL; + PyWinObject_FreeTCHAR(pszIconPath); if ( FAILED(hr) ) *************** *** 406,414 **** if ( pISL == NULL ) return NULL; ! LPCSTR pszPathRel; // @pyparm string|relPath||The relative path. // @pyparm int|reserved|0|Reserved - must be zero. DWORD dwReserved = 0; ! if ( !PyArg_ParseTuple(args, "s|l:SetRelativePath", &pszPathRel, &dwReserved) ) return NULL; HRESULT hr; --- 422,433 ---- if ( pISL == NULL ) return NULL; ! PyObject *obPathRel; // @pyparm string|relPath||The relative path. // @pyparm int|reserved|0|Reserved - must be zero. DWORD dwReserved = 0; ! if ( !PyArg_ParseTuple(args, "O|l:SetRelativePath", &obPathRel, &dwReserved) ) ! return NULL; ! TCHAR *pszPathRel; ! if (!PyWinObject_AsTCHAR(obPathRel, &pszPathRel)) return NULL; HRESULT hr; *************** *** 416,419 **** --- 435,439 ---- hr = pISL->SetRelativePath( pszPathRel, dwReserved ); PY_INTERFACE_POSTCALL; + PyWinObject_FreeTCHAR(pszPathRel); if ( FAILED(hr) ) *************** *** 475,485 **** if ( pISL == NULL ) return NULL; ! LPCSTR pszFile; ! // @pyparm string|path||The path and filename of the link. ! if ( !PyArg_ParseTuple(args, "s:SetPath", &pszFile) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pISL->SetPath( pszFile ); PY_INTERFACE_POSTCALL; --- 495,508 ---- if ( pISL == NULL ) return NULL; ! PyObject *obName; ! if ( !PyArg_ParseTuple(args, "O:SetDescription", &obName) ) return NULL; + TCHAR *pszName; + if (!PyWinObject_AsTCHAR(obName, &pszName)) + return NULL; + // @pyparm string|path||The path and filename of the link. HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pISL->SetPath( pszName ); PY_INTERFACE_POSTCALL; |