Update of /cvsroot/pywin32/pywin32/com/win32com/src
In directory sc8-pr-cvs1:/tmp/cvs-serv19738/com/win32com/src
Modified Files:
PyComHelpers.cpp PyStorage.cpp PythonCOM.cpp Register.cpp
Log Message:
Add StgOpenStorageEx and IEnumSTATPROPSETSTG
Index: PyComHelpers.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyComHelpers.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PyComHelpers.cpp 14 Feb 2001 02:27:28 -0000 1.3
--- PyComHelpers.cpp 30 Oct 2003 06:28:28 -0000 1.4
***************
*** 291,292 ****
--- 291,354 ----
return TRUE;
}
+
+ BOOL PyCom_PyObjectAsSTGOPTIONS(PyObject *obstgoptions, STGOPTIONS **ppstgoptions)
+ {
+ static char *stgmembers[]={"Version","reserved","SectorSize","TemplateFile",0};
+ char *explain_format="STGOPTIONS must be a dictionary containing "\
+ "{Version:int,reserved:0,SectorSize:int,TemplateFile:unicode}";
+ PyObject *dummy_tuple=NULL;
+ BOOL ret;
+
+ if ((obstgoptions==Py_None)||(obstgoptions==NULL)){
+ *ppstgoptions=NULL;
+ return TRUE;
+ }
+ if (!PyDict_Check(obstgoptions)){
+ PyErr_SetString(PyExc_TypeError,explain_format);
+ return FALSE;
+ }
+
+ *ppstgoptions=new(STGOPTIONS);
+ if (*ppstgoptions==NULL){
+ PyErr_SetString(PyExc_MemoryError,"PyObjectAsSTGOPTIONS: Out of memory");
+ return FALSE;
+ }
+ (*ppstgoptions)->usVersion=2;
+ (*ppstgoptions)->reserved=0;
+ (*ppstgoptions)->ulSectorSize=512;
+ (*ppstgoptions)->pwcsTemplateFile=NULL;
+ dummy_tuple=PyTuple_New(0);
+ ret=PyArg_ParseTupleAndKeywords(dummy_tuple, obstgoptions, "|lllu", stgmembers,
+ &(*ppstgoptions)->usVersion,
+ &(*ppstgoptions)->reserved,
+ &(*ppstgoptions)->ulSectorSize,
+ &(*ppstgoptions)->pwcsTemplateFile);
+ Py_DECREF(dummy_tuple);
+ if (!ret){
+ PyErr_Clear();
+ PyErr_SetString(PyExc_TypeError,explain_format);
+ delete(*ppstgoptions);
+ *ppstgoptions=NULL;
+ }
+ return ret;
+ }
+
+ PyObject *PyCom_PyObjectFromSTATPROPSETSTG(STATPROPSETSTG *pStg)
+ {
+ if (pStg==NULL) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ PyObject *obfmtid = PyWinObject_FromIID(pStg->fmtid);
+ PyObject *obclsid = PyWinObject_FromIID(pStg->clsid);
+ PyObject *obmtime = PyWinObject_FromFILETIME(pStg->mtime);
+ PyObject *obctime = PyWinObject_FromFILETIME(pStg->ctime);
+ PyObject *obatime = PyWinObject_FromFILETIME(pStg->atime);
+ PyObject *ret = Py_BuildValue("OOiOOO", obfmtid, obclsid, pStg->grfFlags, obmtime, obctime, obatime);
+ Py_XDECREF(obfmtid);
+ Py_XDECREF(obclsid);
+ Py_XDECREF(obmtime);
+ Py_XDECREF(obctime);
+ Py_XDECREF(obatime);
+ return ret;
+ }
\ No newline at end of file
Index: PyStorage.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyStorage.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PyStorage.cpp 19 Nov 1999 04:01:45 -0000 1.2
--- PyStorage.cpp 30 Oct 2003 06:28:28 -0000 1.3
***************
*** 4,10 ****
#include "stdafx.h"
-
#include "PythonCOM.h"
#include "PythonCOMServer.h"
// @doc
--- 4,14 ----
#include "stdafx.h"
#include "PythonCOM.h"
#include "PythonCOMServer.h"
+
+
+ HRESULT (WINAPI *myStgOpenStorageEx)(WCHAR *, DWORD, DWORD, DWORD,
+ STGOPTIONS *, void *, REFIID, void **);
+
// @doc
***************
*** 153,155 ****
--- 157,202 ----
return PyCom_PyObjectFromIUnknown(pResult, IID_IStorage, FALSE);
}
+
+ // @pymethod <o PyIStorage>|pythoncom|StgOpenStorageEx|Advanced version of StgOpenStorage, win2k or better
+ PyObject *pythoncom_StgOpenStorageEx(PyObject *self, PyObject *args)
+ {
+ if (myStgOpenStorageEx==NULL){
+ PyErr_SetString(PyExc_NotImplementedError,"StgOpenStorageEx not supported by this version of Windows");
+ return NULL;
+ }
+ PyObject *obfname=NULL, *obriid=NULL, *obstgoptions=NULL;
+ WCHAR *fname;
+ DWORD mode=0, attrs=0;
+ VOID *reserved=NULL;
+ DWORD stgfmt;
+ IID riid;
+ STGOPTIONS *pstgoptions=NULL;
+ HRESULT err;
+ void *intptr;
+ if (!PyArg_ParseTuple(args, "OiiiO|O:StgOpenStorageEx",
+ &obfname, //@pyparm string|name||Name of the stream or file to open
+ &mode, // @pyparm int|grfmode||open flags
+ &stgfmt, // @pyparm int|stgfmt||Storage format (STGFMT_STORAGE,STGFMT_FILE,STGFMT_ANY, or STGFMT_DOCFILE)
+ &attrs, // @pyparm int|grfAttrs||Reserved, must be 0
+ &obriid, // @pyparm IID|riid||Interface id to return, IStorage or IPropertySetStorage
+ &obstgoptions)) //@pyparm <o dict>|pStgOptions||Dictionary representing STGOPTIONS struct (only used with STGFMT_DOCFILE)
+ return NULL;
+ if (!PyWinObject_AsIID(obriid, &riid))
+ return NULL;
+ if(!PyCom_PyObjectAsSTGOPTIONS(obstgoptions, &pstgoptions))
+ return NULL;
+ if (!PyWinObject_AsWCHAR(obfname,&fname))
+ return NULL;
+
+ PY_INTERFACE_PRECALL;
+ err = (*myStgOpenStorageEx)(fname, mode, stgfmt, attrs, NULL, reserved, riid, &intptr);
+ PY_INTERFACE_POSTCALL;
+ if (pstgoptions)
+ delete(pstgoptions);
+ PyWinObject_FreeWCHAR(fname);
+ if (FAILED(err))
+ return PyCom_BuildPyException(err);
+ return PyCom_PyObjectFromIUnknown((IUnknown *)intptr, riid, FALSE);
+ }
+
Index: PythonCOM.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** PythonCOM.cpp 9 Oct 2003 13:26:33 -0000 1.23
--- PythonCOM.cpp 30 Oct 2003 06:28:28 -0000 1.24
***************
*** 16,20 ****
--- 16,24 ----
#include "PyFactory.h"
+ extern HRESULT (WINAPI *myStgOpenStorageEx)(WCHAR *, DWORD, DWORD, DWORD,
+ STGOPTIONS *, void *, REFIID, void **);
+
extern int PyCom_RegisterCoreIIDs(PyObject *dict);
+
extern int PyCom_RegisterCoreSupport(void);
***************
*** 32,35 ****
--- 36,40 ----
// Storage related functions.
extern PyObject *pythoncom_StgOpenStorage(PyObject *self, PyObject *args);
+ extern PyObject *pythoncom_StgOpenStorageEx(PyObject *self, PyObject *args);
#ifndef MS_WINCE
extern PyObject *pythoncom_StgIsStorageFile(PyObject *self, PyObject *args);
***************
*** 1467,1470 ****
--- 1472,1476 ----
{ "STGMEDIUM", Py_NewSTGMEDIUM, 1}, // @pymeth STGMEDIUM|Creates a new <o PySTGMEDIUM> object suitable for the <o PyIDataObject> interface.
{ "StgOpenStorage", pythoncom_StgOpenStorage, 1 }, // @pymeth StgOpenStorage|Opens an existing root storage object in the file system.
+ { "StgOpenStorageEx", pythoncom_StgOpenStorageEx, 1 }, // @pymeth StgOpenStorageEx|Access IStorage and IPropertySetStorage interfaces for normal files
{ "TYPEATTR", Py_NewTYPEATTR, 1}, // @pymeth TYPEATTR|Returns a new <o TYPEATTR> object.
{ "VARDESC", Py_NewVARDESC, 1}, // @pymeth VARDESC|Returns a new <o VARDESC> object.
***************
*** 1868,1871 ****
--- 1874,1901 ----
AddConstant(dict, "dcom", 0 );
}
+
+ PyObject *obfmtid=NULL;
+ obfmtid=PyWinObject_FromIID(FMTID_DocSummaryInformation);
+ PyDict_SetItemString(dict,"FMTID_DocSummaryInformation",obfmtid);
+ Py_DECREF(obfmtid);
+ obfmtid=PyWinObject_FromIID(FMTID_SummaryInformation);
+ PyDict_SetItemString(dict,"FMTID_SummaryInformation",obfmtid);
+ Py_DECREF(obfmtid);
+ obfmtid=PyWinObject_FromIID(FMTID_UserDefinedProperties);
+ PyDict_SetItemString(dict,"FMTID_UserDefinedProperties",obfmtid);
+ Py_DECREF(obfmtid);
+ // obfmtid=PyWinObject_FromIID(FMTID_MediaFileSummaryInfo);
+ // PyDict_SetItemString(dict,"FMTID_MediaFileSummaryInfo",obfmtid);
+ // Py_DECREF(obfmtid);
+
+ myStgOpenStorageEx=NULL;
+ HMODULE hmodule=GetModuleHandle("Ole32.dll");
+ if (hmodule!=NULL){
+ FARPROC fp = GetProcAddress(hmodule,"StgOpenStorageEx");
+ if (fp!=NULL)
+ myStgOpenStorageEx=(HRESULT (WINAPI *)(WCHAR *, DWORD, DWORD, DWORD,
+ STGOPTIONS *, void *, REFIID, void **))(fp);
+ }
+
// @prop int|dcom|1 if the system is DCOM aware, else 0. Only Win95 without DCOM extensions should return 0
***************
*** 1874,1875 ****
--- 1904,1906 ----
// @property int|pythoncom|dcom|1 if the system is DCOM aware, else 0. Only Win95 without DCOM extensions should return 0
}
+
Index: Register.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/Register.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** Register.cpp 9 Oct 2003 00:26:23 -0000 1.10
--- Register.cpp 30 Oct 2003 06:28:28 -0000 1.11
***************
*** 46,49 ****
--- 46,50 ----
#include "PyIPropertySetStorage.h"
#include "PyIEnumSTATPROPSTG.h"
+ #include "PyIEnumSTATPROPSETSTG.h"
#include "PyIEnumFORMATETC.h"
#include "PyIDataObject.h"
***************
*** 238,241 ****
--- 239,243 ----
#ifndef NO_PYCOM_ENUMSTATPROPSTG
PYCOM_INTERFACE_CLIENT_ONLY( EnumSTATPROPSTG),
+ PYCOM_INTERFACE_CLIENT_ONLY( EnumSTATPROPSETSTG),
#endif // NO_PYCOM_ENUMSTATPROPSTG
PYCOM_INTERFACE_FULL ( EnumSTATSTG),
|