コード例 #1
0
// @pymethod |PyIBackgroundCopyJob|AddFile|Description of AddFile.
PyObject *PyIBackgroundCopyJob::AddFile(PyObject *self, PyObject *args)
{
	IBackgroundCopyJob *pIBCJ = GetI(self);
	if ( pIBCJ == NULL )
		return NULL;
	// @pyparm <o unicode>|RemoteUrl||Description for RemoteUrl
	// @pyparm <o unicode>|LocalName||Description for LocalName
	PyObject *obRemoteUrl;
	PyObject *obLocalName;
	LPWSTR RemoteUrl;
	LPWSTR LocalName;
	if ( !PyArg_ParseTuple(args, "OO:AddFile", &obRemoteUrl, &obLocalName) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyWinObject_AsBstr(obRemoteUrl, &RemoteUrl)) bPythonIsHappy = FALSE;
	if (bPythonIsHappy && !PyWinObject_AsBstr(obLocalName, &LocalName)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIBCJ->AddFile( RemoteUrl, LocalName );
	SysFreeString(RemoteUrl);
	SysFreeString(LocalName);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob );
	Py_INCREF(Py_None);
	return Py_None;

}
コード例 #2
0
// @pymethod |PyICreateTypeInfo|DefineFuncAsDllEntry|Description of DefineFuncAsDllEntry.
PyObject *PyICreateTypeInfo::DefineFuncAsDllEntry(PyObject *self, PyObject *args)
{
	ICreateTypeInfo *pICTI = GetI(self);
	if ( pICTI == NULL )
		return NULL;
	// @pyparm int|index||Description for index
	// @pyparm <o unicode>|szDllName||Description for szDllName
	// @pyparm <o unicode>|szProcName||Description for szProcName
	PyObject *obszDllName;
	PyObject *obszProcName;
	UINT index;
	LPOLESTR szDllName;
	LPOLESTR szProcName;
	if ( !PyArg_ParseTuple(args, "iOO:DefineFuncAsDllEntry", &index, &obszDllName, &obszProcName) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (!PyWinObject_AsBstr(obszDllName, &szDllName)) bPythonIsHappy = FALSE;
	if (!PyWinObject_AsBstr(obszProcName, &szProcName)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pICTI->DefineFuncAsDllEntry( index, szDllName, szProcName );
	PY_INTERFACE_POSTCALL;
	SysFreeString(szDllName);
	SysFreeString(szProcName);

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICTI, IID_ICreateTypeInfo);
	Py_INCREF(Py_None);
	return Py_None;

}
コード例 #3
0
// @pymethod |PyIBackgroundCopyJob2|SetNotifyCmdLine|Description of SetNotifyCmdLine.
PyObject *PyIBackgroundCopyJob2::SetNotifyCmdLine(PyObject *self, PyObject *args)
{
	IBackgroundCopyJob2 *pIBCJ2 = GetI(self);
	if ( pIBCJ2 == NULL )
		return NULL;
	// @pyparm <o unicode>|Program||Description for Program
	// @pyparm <o unicode>|Parameters||Description for Parameters
	PyObject *obProgram;
	PyObject *obParameters;
	LPWSTR Program;
	LPWSTR Parameters;
	if ( !PyArg_ParseTuple(args, "OO:SetNotifyCmdLine", &obProgram, &obParameters) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyWinObject_AsBstr(obProgram, &Program)) bPythonIsHappy = FALSE;
	if (bPythonIsHappy && !PyWinObject_AsBstr(obParameters, &Parameters)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIBCJ2->SetNotifyCmdLine( Program, Parameters );
	SysFreeString(Program);
	SysFreeString(Parameters);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIBCJ2, IID_IBackgroundCopyJob2 );
	Py_INCREF(Py_None);
	return Py_None;
}
コード例 #4
0
// @pymethod |PyIStorage|RenameElement|Renames the specified substorage or stream in this storage object.
PyObject *PyIStorage::RenameElement(PyObject *self, PyObject *args)
{
	IStorage *pIS = GetI(self);
	if ( pIS == NULL )
		return NULL;
	// @pyparm string|oldName||The name of the substorage or stream to be changed.
	// @pyparm string|newName||The new name for the specified sustorage or stream.
	PyObject *obNewName, *obOldName;
	if ( !PyArg_ParseTuple(args, "OO:RenameElement", &obOldName, &obNewName) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	BSTR bstrNewName, bstrOldName;
	bPythonIsHappy = PyWinObject_AsBstr(obOldName, &bstrOldName);
	if (!PyWinObject_AsBstr(obNewName, &bstrNewName))
		bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIS->RenameElement( bstrOldName, bstrNewName );
	PyWinObject_FreeBstr(bstrOldName);
	PyWinObject_FreeBstr(bstrNewName);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIS, IID_IStorage);
	Py_INCREF(Py_None);
	return Py_None;

}
コード例 #5
0
// @pymethod |PyIBackgroundCopyJob3|ReplaceRemotePrefix|Description of ReplaceRemotePrefix.
PyObject *PyIBackgroundCopyJob3::ReplaceRemotePrefix(PyObject *self, PyObject *args)
{
	IBackgroundCopyJob3 *pIBCJ3 = GetI(self);
	if ( pIBCJ3 == NULL )
		return NULL;
	// @pyparm <o unicode>|OldPrefix||Description for OldPrefix
	// @pyparm <o unicode>|NewPrefix||Description for NewPrefix
	PyObject *obOldPrefix;
	PyObject *obNewPrefix;
	LPWSTR OldPrefix;
	LPWSTR NewPrefix;
	if ( !PyArg_ParseTuple(args, "OO:ReplaceRemotePrefix", &obOldPrefix, &obNewPrefix) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyWinObject_AsBstr(obOldPrefix, &OldPrefix)) bPythonIsHappy = FALSE;
	if (bPythonIsHappy && !PyWinObject_AsBstr(obNewPrefix, &NewPrefix)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIBCJ3->ReplaceRemotePrefix( OldPrefix, NewPrefix );
	SysFreeString(OldPrefix);
	SysFreeString(NewPrefix);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIBCJ3, IID_IBackgroundCopyJob3 );
	return PyInt_FromLong(hr);
}
コード例 #6
0
// @pymethod |PyIStorage|MoveElementTo|Copies or moves a substorage or stream from this storage object to another storage object.
PyObject *PyIStorage::MoveElementTo(PyObject *self, PyObject *args)
{
	IStorage *pIS = GetI(self);
	if ( pIS == NULL )
		return NULL;
	// @pyparm string|name||A string that contains the name of the element in this storage object to be moved or copied.
	// @pyparm <o PyIStorage>|stgDest||<o PyIStorage> for the destination storage object.
	// @pyparm string|newName||A string that contains the new name for the element in its new storage object.
	// @pyparm int|grfFlags||Specifies whether the operation should be a move (STGMOVE_MOVE) or a copy (STGMOVE_COPY). See the STGMOVE enumeration.
	PyObject *obName, *obNewName;
	PyObject *obpstgDest;
	DWORD grfFlags;
	if ( !PyArg_ParseTuple(args, "OOOi:MoveElementTo", &obName, &obpstgDest, &obNewName, &grfFlags) )
		return NULL;
	IStorage *pstgDest;
	BOOL bPythonIsHappy = TRUE;
	BSTR bstrName, bstrNewName;
	bPythonIsHappy = PyWinObject_AsBstr(obName, &bstrName);
	if (!PyWinObject_AsBstr(obNewName, &bstrNewName))
		bPythonIsHappy = FALSE;
	if (!PyCom_InterfaceFromPyObject(obpstgDest, IID_IStorage, (void **)&pstgDest, FALSE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIS->MoveElementTo( bstrName, pstgDest, bstrNewName, grfFlags );
	pstgDest->Release();
	PY_INTERFACE_POSTCALL;
	PyWinObject_FreeBstr(bstrName);
	PyWinObject_FreeBstr(bstrNewName);
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIS, IID_IStorage);
	Py_INCREF(Py_None);
	return Py_None;

}
コード例 #7
0
// @pymethod |PyIBackgroundCopyJob3|AddFileWithRanges|Description of AddFileWithRanges.
PyObject *PyIBackgroundCopyJob3::AddFileWithRanges(PyObject *self, PyObject *args)
{
	IBackgroundCopyJob3 *pIBCJ3 = GetI(self);
	if ( pIBCJ3 == NULL )
		return NULL;
	// @pyparm <o unicode>|RemoteUrl||Description for RemoteUrl
	// @pyparm <o unicode>|LocalName||Description for LocalName
	BG_FILE_RANGE *Ranges;
	PyObject *obRanges;
	// @pyparm <o PyBG_FILE_RANGE>|Ranges||Description for Ranges
	PyObject *obRemoteUrl;
	PyObject *obLocalName;
	LPWSTR RemoteUrl;
	LPWSTR LocalName;
	if ( !PyArg_ParseTuple(args, "OOO:AddFileWithRanges", &obRemoteUrl, &obLocalName, &obRanges) )
		return NULL;
	DWORD RangeCount;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyWinObject_AsBstr(obRemoteUrl, &RemoteUrl)) bPythonIsHappy = FALSE;
	if (bPythonIsHappy && !PyWinObject_AsBstr(obLocalName, &LocalName)) bPythonIsHappy = FALSE;
	if (bPythonIsHappy && !PyObject_AsBG_FILE_RANGE_LIST( obRanges, &RangeCount, &Ranges )) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIBCJ3->AddFileWithRanges( RemoteUrl, LocalName, RangeCount, Ranges );
	SysFreeString(RemoteUrl);
	SysFreeString(LocalName);
	PyObject_FreeBG_FILE_RANGE_LIST(RangeCount, Ranges);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIBCJ3, IID_IBackgroundCopyJob3 );
	return PyInt_FromLong(hr);
}
コード例 #8
0
// @pymethod |PyICreateTypeInfo|SetFuncAndParamNames|Description of SetFuncAndParamNames.
PyObject *PyICreateTypeInfo::SetFuncAndParamNames(PyObject *self, PyObject *args)
{
	ICreateTypeInfo *pICTI = GetI(self);
	if ( pICTI == NULL )
		return NULL;
	// @pyparm int|index||Index of the item to set.
	// @pyparm (<o unicode>, ...)|rgszNames||A sequence of unicode or String objects.
	PyObject *obrgszNames;
	UINT index;
	if ( !PyArg_ParseTuple(args, "iO:SetFuncAndParamNames", &index, &obrgszNames) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;

	// String and Unicode will pass the "is sequence" test, so we reject these!
	BSTR bstrTemp;
	if (PyWinObject_AsBstr(obrgszNames, &bstrTemp)) {
		PyWinObject_FreeBstr(bstrTemp);
		PyErr_SetString(PyExc_TypeError, "The names param must be a sequence of strings/unicodes");
		return NULL;
	}
	PyErr_Clear(); // clear the exception set by PyWinObject_AsBstr
	if (!PySequence_Check(obrgszNames)) {
		PyErr_SetString(PyExc_TypeError, "The names param must be a sequence of strings/unicodes");
		return NULL;
	}
	UINT cNames = PySequence_Length(obrgszNames);
	OLECHAR **pNames = new OLECHAR *[cNames];
	memset(pNames, sizeof(OLECHAR *) * cNames, 0);
	UINT i;
	for (i=0;bPythonIsHappy && i<cNames;i++) {
		PyObject *item = PySequence_GetItem(obrgszNames, i);
		if (item==NULL) 
			bPythonIsHappy = FALSE;
		else
			bPythonIsHappy = PyWinObject_AsBstr(item, pNames+i);
		Py_DECREF(item);
	}
	if (!bPythonIsHappy) {
		for (i=0;i<cNames;i++)
				PyWinObject_FreeBstr(pNames[i]);
		delete pNames;
		return NULL;
	}
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pICTI->SetFuncAndParamNames( index, pNames, cNames );
	PY_INTERFACE_POSTCALL;

	for (i=0;i<cNames;i++)
			PyWinObject_FreeBstr(pNames[i]);
	delete pNames;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICTI, IID_ICreateTypeInfo);
	Py_INCREF(Py_None);
	return Py_None;
}
コード例 #9
0
// @pymethod |pythoncom|RegisterTypeLib|Adds information about a type library to the system registry.
PyObject *pythoncom_registertypelib(PyObject *self, PyObject *args)
{
	PyObject *obTypeLib, *obPath, *obHelpDir = Py_None;
	// @pyparm <o PyITypeLib>|typelib||The type library being registered.
	// @pyparm string|fullPath||Fully qualified path specification for the type library being registered
	// @pyparm string|helpDir|None|Directory in which the Help file for the library being registered can be found. Can be None.
	// @pyparm int|lcid|LOCALE_USER_DEFAULT|The locale ID to use.
	if (!PyArg_ParseTuple(args, "OO|O:RegisterTypeLib", &obTypeLib, &obPath, &obHelpDir))
		return NULL;

	PyObject *result = NULL;
	BSTR bstrPath = NULL;
	BSTR bstrHelpDir = NULL;
	ITypeLib *pLib = NULL;
	SCODE sc;
	if (!PyWinObject_AsBstr(obPath, &bstrPath, FALSE))
		goto done;
	if (!PyWinObject_AsBstr(obHelpDir, &bstrHelpDir, TRUE))
		goto done;

	if (!PyCom_InterfaceFromPyInstanceOrObject(obTypeLib, IID_ITypeLib, (void **)&pLib, FALSE))
		goto done;

	{ // scope to avoid warning about var decl and goto.
	PY_INTERFACE_PRECALL;
	sc = RegisterTypeLib(pLib, bstrPath, bstrHelpDir);
	PY_INTERFACE_POSTCALL;
	}
	if (FAILED(sc))
		return PyCom_BuildPyException(sc);

	result = Py_None;
	Py_INCREF(result);
done:
	if (bstrPath) SysFreeString(bstrPath);
	if (bstrHelpDir) SysFreeString(bstrHelpDir);
	if (pLib) {
		PY_INTERFACE_PRECALL;
		pLib->Release();
		PY_INTERFACE_POSTCALL;
	}
	return result;
	// @comm This function can be used during application initialization to register the application's type 
	// library correctly. When RegisterTypeLib is called to register a type library, 
	// both the minor and major version numbers are registered in hexadecimal.
	// <nl> In addition to filling in a complete registry entry under the type library key, 
	// RegisterTypeLib adds entries for each of the dispinterfaces and Automation-compatible 
	// interfaces, including dual interfaces. This information is required to create 
	// instances of these interfaces. Coclasses are not registered (that is, 
	// RegisterTypeLib does not write any values to the CLSID key of the coclass). 
}
コード例 #10
0
ファイル: PyIADs.cpp プロジェクト: malrsrch/pywin32
// @pymethod object|PyIADs|Get|Description of Get.
// @rdesc The result is a Python object converted from a COM variant.  It
// may be an array, or any types supported by COM variant.
PyObject *PyIADs::Get(PyObject *self, PyObject *args)
{
	IADs *pIAD = GetI(self);
	if ( pIAD == NULL )
		return NULL;
	VARIANT val;
	VariantInit(&val);
	// @pyparm <o PyUnicode>|prop||The name of the property to fetch
	PyObject *obbstrName;
	BSTR bstrName;
	if ( !PyArg_ParseTuple(args, "O:Get", &obbstrName) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyWinObject_AsBstr(obbstrName, &bstrName)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIAD->Get( bstrName, &val );
	SysFreeString(bstrName);
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIAD, IID_IADs );
	PyObject *ret = PyCom_PyObjectFromVariant(&val);
	{
	PY_INTERFACE_PRECALL;
	VariantClear(&val);
	PY_INTERFACE_POSTCALL;
	}
	return ret;
}
コード例 #11
0
ファイル: PyIADs.cpp プロジェクト: malrsrch/pywin32
// @pymethod |PyIADs|Put|Description of Put.
PyObject *PyIADs::Put(PyObject *self, PyObject *args)
{
	IADs *pIAD = GetI(self);
	if ( pIAD == NULL )
		return NULL;
	// @pyparm <o PyUnicode>|property||The property name to set
	// @pyparm object|val||The value to set.
	PyObject *obbstrName;
	PyObject *obvProp;
	BSTR bstrName;
	VARIANT vProp;
	VariantInit(&vProp);
	if ( !PyArg_ParseTuple(args, "OO:Put", &obbstrName, &obvProp) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyWinObject_AsBstr(obbstrName, &bstrName)) bPythonIsHappy = FALSE;
	if ( !PyCom_VariantFromPyObject(obvProp, &vProp) )
		bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIAD->Put( bstrName, vProp );
	SysFreeString(bstrName);
	VariantClear(&vProp);
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIAD, IID_IADs );
	Py_INCREF(Py_None);
	return Py_None;

}
コード例 #12
0
// @pymethod <o PyIStream>|PyIStorage|OpenStream|Opens an existing stream object within this storage object in the specified access mode.
PyObject *PyIStorage::OpenStream(PyObject *self, PyObject *args)
{
	IStorage *pIS = GetI(self);
	if ( pIS == NULL )
		return NULL;
	// @pyparm string|pwcsName||Description for pwcsName
	// @pyparm object|reserved1||A reserved param.  Always pass None.  NULL is always passed to the COM function
	// @pyparm int|grfMode||Specifies the access mode to be assigned to the open stream. See the STGM enumeration values for descriptions of the possible values. . Whatever other modes you may choose, you must at least specify STGM_SHARE_EXCLUSIVE when calling this method.
	// @pyparm int|reserved2|0|Reserved - must be zero.
	PyObject *obName;
	DWORD grfMode;
	PyObject *obreserved1;
	DWORD reserved2 = 0;
	if ( !PyArg_ParseTuple(args, "OOi|i:OpenStream", &obName, &obreserved1, &grfMode, &reserved2) )
		return NULL;
	if (obreserved1 != Py_None) {
		PyErr_SetString(PyExc_TypeError, "The 'reserved' parameter (param 2) must be None");
		return NULL;
	}
	IStream *ppstm;
	BOOL bPythonIsHappy = TRUE;
	BSTR name;
	bPythonIsHappy = PyWinObject_AsBstr(obName, &name);
	if (!bPythonIsHappy) return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIS->OpenStream( name, NULL, grfMode, reserved2, &ppstm );
	PyWinObject_FreeBstr(name);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIS, IID_IStorage);

	return PyCom_PyObjectFromIUnknown(ppstm, IID_IStream, FALSE);
}
コード例 #13
0
// @pymethod <o PyIStream>|PyIStorage|CreateStream|Creates and opens a stream object with the specified name contained in this storage object. All elements within a storage object — both streams and other storage objects — are kept in the same name space.
PyObject *PyIStorage::CreateStream(PyObject *self, PyObject *args)
{
	IStorage *pIS = GetI(self);
	if ( pIS == NULL )
		return NULL;
	// @pyparm string|pwcsName||Name of the new stream
	// @pyparm int|grfMode||Specifies the access mode to use when opening the newly created stream.
	// @pyparm int|reserved1|0|Reserved - must be zero.
	// @pyparm int|reserved2|0|Reserved - must be zero.
	DWORD grfMode;
	DWORD reserved1 = 0;
	DWORD reserved2 = 0;
	PyObject *obName;
	if ( !PyArg_ParseTuple(args, "Oi|ii:CreateStream", &obName, &grfMode, &reserved1, &reserved2) )
		return NULL;
	IStream *ppstm;
	BOOL bPythonIsHappy = TRUE;
	BSTR bstrName;
	bPythonIsHappy = PyWinObject_AsBstr(obName, &bstrName);
	if (!bPythonIsHappy) return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIS->CreateStream( bstrName, grfMode, reserved1, reserved2, &ppstm );
	PyWinObject_FreeBstr(bstrName);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIS, IID_IStorage);

	return PyCom_PyObjectFromIUnknown(ppstm, IID_IStream, FALSE);
}
コード例 #14
0
// @pymethod |PyIInternetSecurityManager|GetSecurityId|Description of GetSecurityId.
PyObject *PyIInternetSecurityManager::GetSecurityId(PyObject *self, PyObject *args)
{
	IInternetSecurityManager *pIISM = GetI(self);
	if ( pIISM == NULL )
		return NULL;
	// @pyparm <o unicode>|pwszUrl||Description for pwszUrl
	// @pyparm int|pcbSecurityId||Description for pcbSecurityId
	DWORD_PTR dwReserved = 0;
	PyObject *obdwReserved = Py_None;
	// ACK - 'reserved' docs appears to indicate its actually a string.
	// so ignore it for now.
	PyObject *obpwszUrl;
	LPWSTR pwszUrl;
	if ( !PyArg_ParseTuple(args, "O:GetSecurityId", &obpwszUrl) )
		return NULL;
	if (!PyWinObject_AsBstr(obpwszUrl, &pwszUrl))
		return NULL;
	BYTE buf[1024]; // big enough?
	DWORD cbSecurityId = sizeof(buf);
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIISM->GetSecurityId( pwszUrl, buf, &cbSecurityId, 0);
	SysFreeString(pwszUrl);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIISM, IID_IInternetSecurityManager );
	return PyString_FromStringAndSize((char *)buf, cbSecurityId);
}
コード例 #15
0
// @pymethod <o PyIStorage>|PyIStorage|CreateStorage|Creates and opens a new storage object nested within this storage object.
PyObject *PyIStorage::CreateStorage(PyObject *self, PyObject *args)
{
	IStorage *pIS = GetI(self);
	if ( pIS == NULL )
		return NULL;
	// @pyparm string|pwcsName||The name of the newly created stream.
	// @pyparm int|grfMode||Specifies the access mode to use when opening the newly created storage object.
	// @pyparm int|dwStgFmt||Documented as "reserved"!
	// @pyparm int|reserved2|0|Description for reserved2
	PyObject *obName;
	DWORD grfMode;
	DWORD dwStgFmt;
	DWORD reserved2 = 0;
	if ( !PyArg_ParseTuple(args, "Oii|i:CreateStorage", &obName, &grfMode, &dwStgFmt, &reserved2) )
		return NULL;
	IStorage *ppstg;
	BOOL bPythonIsHappy = TRUE;
	BSTR name;
	bPythonIsHappy = PyWinObject_AsBstr(obName, &name);
	if (!bPythonIsHappy) return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIS->CreateStorage( name, grfMode, dwStgFmt, reserved2, &ppstg );
	PY_INTERFACE_POSTCALL;
	PyWinObject_FreeBstr(name);
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIS, IID_IStorage);

	return PyCom_PyObjectFromIUnknown(ppstg, IID_IStorage, FALSE);
}
コード例 #16
0
// @pymethod |PyICreateTypeInfo|SetDocString|Description of SetDocString.
PyObject *PyICreateTypeInfo::SetDocString(PyObject *self, PyObject *args)
{
	ICreateTypeInfo *pICTI = GetI(self);
	if ( pICTI == NULL )
		return NULL;
	// @pyparm <o unicode>|pStrDoc||Description for pStrDoc
	PyObject *obpStrDoc;
	LPOLESTR pStrDoc;
	if ( !PyArg_ParseTuple(args, "O:SetDocString", &obpStrDoc) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (!PyWinObject_AsBstr(obpStrDoc, &pStrDoc)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pICTI->SetDocString( pStrDoc );
	PY_INTERFACE_POSTCALL;
	SysFreeString(pStrDoc);

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICTI, IID_ICreateTypeInfo);
	Py_INCREF(Py_None);
	return Py_None;

}
コード例 #17
0
// @pymethod |PyICreateTypeInfo|SetMops|Description of SetMops.
PyObject *PyICreateTypeInfo::SetMops(PyObject *self, PyObject *args)
{
	ICreateTypeInfo *pICTI = GetI(self);
	if ( pICTI == NULL )
		return NULL;
	// @pyparm int|index||Description for index
	// @pyparm <o unicode>|bstrMops||Description for bstrMops
	PyObject *obbstrMops;
	UINT index;
	BSTR bstrMops;
	if ( !PyArg_ParseTuple(args, "iO:SetMops", &index, &obbstrMops) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (!PyWinObject_AsBstr(obbstrMops, &bstrMops)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pICTI->SetMops( index, bstrMops );
	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICTI, IID_ICreateTypeInfo);
	Py_INCREF(Py_None);
	return Py_None;

}
コード例 #18
0
// @pymethod |PyIInternetSecurityManager|SetZoneMapping|Description of SetZoneMapping.
PyObject *PyIInternetSecurityManager::SetZoneMapping(PyObject *self, PyObject *args)
{
	IInternetSecurityManager *pIISM = GetI(self);
	if ( pIISM == NULL )
		return NULL;
	// @pyparm int|dwZone||Description for dwZone
	// @pyparm <o unicode>|lpszPattern||Description for lpszPattern
	// @pyparm int|dwFlags||Description for dwFlags
	PyObject *oblpszPattern;
	DWORD dwZone;
	LPWSTR lpszPattern;
	DWORD dwFlags;
	if (!PyArg_ParseTuple(args, "lOl:SetZoneMapping", &dwZone, &oblpszPattern, &dwFlags))
		return NULL;
	if (!PyWinObject_AsBstr(oblpszPattern, &lpszPattern))
		return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIISM->SetZoneMapping( dwZone, lpszPattern, dwFlags );
	SysFreeString(lpszPattern);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIISM, IID_IInternetSecurityManager );
	Py_INCREF(Py_None);
	return Py_None;

}
コード例 #19
0
// @pymethod |PyICreateTypeLib|CreateTypeInfo|Description of CreateTypeInfo.
PyObject *PyICreateTypeLib::CreateTypeInfo(PyObject *self, PyObject *args)
{
	ICreateTypeLib *pICTL = GetI(self);
	if ( pICTL == NULL )
		return NULL;
	// @pyparm <o unicode>|szName||Description for szName

	long tkind;
	PyObject *obszName;
	LPOLESTR szName;
	ICreateTypeInfo * ppCTInfo;
	if ( !PyArg_ParseTuple(args, "Ol:CreateTypeInfo", &obszName, &tkind) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (!PyWinObject_AsBstr(obszName, &szName)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pICTL->CreateTypeInfo( szName, (TYPEKIND)tkind, &ppCTInfo );
	PY_INTERFACE_POSTCALL;
	SysFreeString(szName);

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICTL, IID_ICreateTypeLib);
	return PyCom_PyObjectFromIUnknown(ppCTInfo, IID_ICreateTypeInfo, FALSE);
}
コード例 #20
0
// @pymethod |PyICreateTypeLib|SetName|Description of SetName.
PyObject *PyICreateTypeLib::SetName(PyObject *self, PyObject *args)
{
	ICreateTypeLib *pICTL = GetI(self);
	if ( pICTL == NULL )
		return NULL;
	// @pyparm <o unicode>|szName||Description for szName
	PyObject *obszName;
	LPOLESTR szName;
	if ( !PyArg_ParseTuple(args, "O:SetName", &obszName) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (!PyWinObject_AsBstr(obszName, &szName)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pICTL->SetName( szName );
	PY_INTERFACE_POSTCALL;
	SysFreeString(szName);

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pICTL, IID_ICreateTypeLib);
	Py_INCREF(Py_None);
	return Py_None;

}
コード例 #21
0
// @pymethod |PyIBackgroundCopyManager|CreateJob|Description of CreateJob.
PyObject *PyIBackgroundCopyManager::CreateJob(PyObject *self, PyObject *args)
{
	IBackgroundCopyManager *pIBCM = GetI(self);
	if ( pIBCM == NULL )
		return NULL;
	// @pyparm <o unicode>|DisplayName||Description for DisplayName
	BG_JOB_TYPE Type;
	// @pyparm int|Type||Job Type (See BG_JOB_TYPE_*)
	GUID pJobId;
	PyObject *obDisplayName;
	LPWSTR DisplayName;
	IBackgroundCopyJob *ppJob;
	if ( !PyArg_ParseTuple(args, "Ol:CreateJob", &obDisplayName, &Type) )
		return NULL;
	BOOL bPythonIsHappy = TRUE;
	if (bPythonIsHappy && !PyWinObject_AsBstr(obDisplayName, &DisplayName)) bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	HRESULT hr;
	PY_INTERFACE_PRECALL;
	hr = pIBCM->CreateJob( DisplayName, Type, &pJobId, &ppJob );
	SysFreeString(DisplayName);

	PY_INTERFACE_POSTCALL;

	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIBCM, IID_IBackgroundCopyManager );
	return PyCom_PyObjectFromIUnknown(ppJob, IID_IBackgroundCopyJob, FALSE);
}
コード例 #22
0
/* static */ PyObject *PyIActiveScript::GetScriptDispatch(PyObject *self, PyObject *args)
{
	PY_INTERFACE_METHOD;
	PyObject *obItemName = Py_None;
	if ( !PyArg_ParseTuple(args, "|O:GetScriptDispatch", &obItemName) )
		return NULL;

	IActiveScript *pIAS = GetI(self);
	if ( pIAS == NULL )
		return NULL;

	BSTR pstrItemName = NULL;
	if (!PyWinObject_AsBstr(obItemName, &pstrItemName, TRUE))
		return NULL;

	IDispatch *pdisp;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIAS->GetScriptDispatch(pstrItemName, &pdisp);
	PY_INTERFACE_POSTCALL;
	PyWinObject_FreeBstr(pstrItemName);
	if ( FAILED(hr) )
		return SetPythonCOMError(self, hr);

	if ( !pdisp )
	{
		Py_INCREF(Py_None);
		return Py_None;
	}

	return PyCom_PyObjectFromIUnknown((IUnknown *)pdisp, IID_IDispatch, FALSE);
}
コード例 #23
0
// @object PROPSPEC|Identifies a property.  Can be either an int property id, or a str/unicode property name.
BOOL PyObject_AsPROPSPECs( PyObject *ob, PROPSPEC **ppRet, ULONG *pcRet)
{
	BOOL ret=FALSE;
	DWORD len, i;
	PyObject *tuple=PyWinSequence_Tuple(ob, &len);
	if (tuple==NULL)
		return FALSE;

	// First count the items, and the total string space we need.
	size_t cChars = 0;
	for (i=0;i<len;i++) {
		PyObject *sub = PyTuple_GET_ITEM(tuple, i);
		if (PyUnicode_Check(sub))
			cChars += PyUnicode_GET_SIZE(sub) + 1;
		else if (PyString_Check(sub))
			cChars += PyString_Size(sub) + 1;
		else if (PyInt_Check(sub))
			;	// PROPID is a ULONG, so this may fail for values that require a python long
		else {
			PyErr_SetString(PyExc_TypeError, "PROPSPECs must be a sequence of strings or integers");
			goto cleanup;
		}
	}
	size_t numBytes;
	numBytes = (sizeof(PROPSPEC) * len) + (sizeof(WCHAR) * cChars);
	PROPSPEC *pRet;
	pRet = (PROPSPEC *)malloc(numBytes);
	if (pRet==NULL) {
		PyErr_SetString(PyExc_MemoryError, "allocating PROPSPECs");
		goto cleanup;
	}
	WCHAR *curBuf;
	curBuf = (WCHAR *)(pRet+len);
	for (i=0;i<len;i++) {
		PyObject *sub = PyTuple_GET_ITEM(tuple, i);
		BSTR bstr;
		if (PyWinObject_AsBstr(sub, &bstr)) {
			pRet[i].ulKind = PRSPEC_LPWSTR;
			pRet[i].lpwstr = curBuf;
			wcscpy( curBuf, bstr);
			curBuf += wcslen(curBuf) + 1;
			PyWinObject_FreeBstr(bstr);
		} else {
			PyErr_Clear();
			pRet[i].ulKind = PRSPEC_PROPID;
			pRet[i].propid = PyInt_AsLong(sub);
		}
	}
	ret=TRUE;
	*ppRet = pRet;
	*pcRet = len;
cleanup:
	Py_DECREF(tuple);
	return ret;
}
コード例 #24
0
ファイル: PyIType.cpp プロジェクト: malrsrch/pywin32
// @pymethod <o DESCKIND>|PyITypeComp|BindType|binds to a type
static PyObject *typecomp_bindtype(PyObject *self, PyObject *args)
{
	PyObject *obS;
	// @pyparm string|szName||The name to bind to
	if (!PyArg_ParseTuple(args, "O:BindType", &obS))
		return NULL;
	BSTR bstrS;
	if (!PyWinObject_AsBstr(obS, &bstrS))
		return NULL;
	PyObject *rc = ((PyITypeComp*)self)->BindType(bstrS);
	PyWinObject_FreeBstr(bstrS);
	return rc;
}
コード例 #25
0
BOOL PyObject_AsPROPVARIANT(PyObject *ob, PROPVARIANT *pVar)
{
	if (ob==Py_None) {
		PropVariantInit(pVar);
	} else if (ob==Py_True) {
		pVar->boolVal = -1;
		pVar->vt = VT_BOOL;
	} else if (ob==Py_False) {
		pVar->boolVal = 0;
		pVar->vt = VT_BOOL;
	} else if (PyLong_Check(ob)) {
		pVar->hVal.QuadPart = PyLong_AsLongLong(ob);
		if (pVar->hVal.QuadPart == -1 && PyErr_Occurred()){
		// Could still fit in an unsigned long long
			PyErr_Clear();
			pVar->uhVal.QuadPart = PyLong_AsUnsignedLongLong(ob);
			if (pVar->uhVal.QuadPart == -1 && PyErr_Occurred())
				return FALSE;
			pVar->vt = VT_UI8;
		}
		else{
			pVar->vt=VT_I8;
			// Could still fit in a regular long
			if (pVar->hVal.QuadPart >= LONG_MIN && pVar->hVal.QuadPart <= LONG_MAX){
				pVar->lVal = (long)pVar->hVal.QuadPart;
				pVar->vt = VT_I4;
			}
			// ... or an unsigned long
			else if (pVar->hVal.QuadPart >=0 && pVar->hVal.QuadPart <= ULONG_MAX){
				pVar->ulVal = (unsigned long)pVar->hVal.QuadPart;
				pVar->vt = VT_UI4;
			}
		}
#if (PY_VERSION_HEX < 0x03000000)
	// Not needed in Py3k, as PyInt_Check is defined to PyLong_Check
	} else if (PyInt_Check(ob)) {
		pVar->lVal = PyInt_AsLong(ob);
		pVar->vt = VT_I4;
#endif
	} else if (PyFloat_Check(ob)) {
		pVar->dblVal = PyFloat_AsDouble(ob);
		pVar->vt = VT_R8;
	} else if (PyUnicode_Check(ob) || PyString_Check(ob)) {
		PyWinObject_AsBstr(ob, &pVar->bstrVal);
		pVar->vt = VT_BSTR;
	} else {
		PyErr_SetString(PyExc_TypeError, "Unsupported object for PROPVARIANT");
		return FALSE;
	}
	return TRUE;
}
コード例 #26
0
STDMETHODIMP PyGActiveScriptError::GetSourceLineText(BSTR *pbstrSourceLine)
{
	if (pbstrSourceLine==NULL) return E_POINTER;
	PY_GATEWAY_METHOD;
	PyObject *result;
	HRESULT hr = InvokeViaPolicy("GetSourceLineText", &result, NULL);
	if (FAILED(hr))
		return hr;

	if (!PyWinObject_AsBstr(result, pbstrSourceLine, TRUE))
		hr = PyCom_SetCOMErrorFromPyException(GetIID());

	Py_DECREF(result);
	return hr;
}
コード例 #27
0
ファイル: PyIType.cpp プロジェクト: malrsrch/pywin32
// @pymethod <o DESCKIND>|PyITypeComp|Bind|binds to a variable/type
static PyObject *typecomp_bind(PyObject *self, PyObject *args)
{
	PyObject *obS;
	int		w=0;
	// @pyparm string|szName||The name to bind to
	// @pyparm int|wflags|0|the bind flags
	if (!PyArg_ParseTuple(args, "O|i:Bind", &obS, &w))
		return NULL;
	BSTR bstrS;
	if (!PyWinObject_AsBstr(obS, &bstrS))
		return NULL;
	PyObject *rc = ((PyITypeComp*)self)->Bind(bstrS,w);
	PyWinObject_FreeBstr(bstrS);
	return rc;
}
コード例 #28
0
// @pymethod |PyIStorage|SetElementTimes|Sets the modification, access, and creation times of the specified storage element, if supported by the underlying file system.
PyObject *PyIStorage::SetElementTimes(PyObject *self, PyObject *args)
{
	IStorage *pIS = GetI(self);
	if ( pIS == NULL )
		return NULL;
	// @pyparm string|name||The name of the storage object element whose times are to be modified. If NULL, the time is set on the root storage rather than one of its elements. 
	// @pyparm <o PyTime>|ctime||Either the new creation time for the element or None if the creation time is not to be modified.
	// @pyparm <o PyTime>|atime||Either the new access time for the element or None if the access time is not to be modified.
	// @pyparm <o PyTime>|mtime||Either the new modification time for the element or None if the modification time is not to be modified.
	PyObject *obName;
	PyObject *obpctime;
	PyObject *obpatime;
	PyObject *obpmtime;
	if ( !PyArg_ParseTuple(args, "OOOO:SetElementTimes", &obName, &obpctime, &obpatime, &obpmtime) )
		return NULL;
	FILETIME *pctime=NULL, ctime;
	FILETIME *patime=NULL, atime;
	FILETIME *pmtime=NULL, mtime;
	if (obpctime!=Py_None) {
		if (!PyWinObject_AsFILETIME(obpctime, &ctime))
			return NULL;
		pctime = &ctime;
	}
	if (obpatime != Py_None) {
		if (!PyWinObject_AsFILETIME(obpatime, &atime))
			return NULL;
		patime = &atime;
	}
	if (obpmtime != Py_None) {
		if (!PyWinObject_AsFILETIME(obpmtime, &mtime))
			return NULL;
		pmtime = &mtime;
	}
	BSTR bstrName;
	if (!PyWinObject_AsBstr(obName, &bstrName))
		return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIS->SetElementTimes( bstrName, pctime, patime, pmtime );
	PyWinObject_FreeBstr(bstrName);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIS, IID_IStorage);
	Py_INCREF(Py_None);
	return Py_None;
}
コード例 #29
0
ファイル: PyIType.cpp プロジェクト: malrsrch/pywin32
// @pymethod <o PyITypeLib>|pythoncom|LoadTypeLib|Loads a registered type library.
PyObject *pythoncom_loadtypelib(PyObject *self, PyObject *args)
{
	PyObject *obName;
	// @pyparm string|libFileName||The path to the file containing the type information.
	if (!PyArg_ParseTuple(args, "O:LoadTypeLib", &obName))
		return NULL;

	BSTR bstrName;
	if (!PyWinObject_AsBstr(obName, &bstrName))
		return NULL;

	ITypeLib *ptl;
	PY_INTERFACE_PRECALL;
	SCODE sc = LoadTypeLib(bstrName, &ptl);
	PyWinObject_FreeBstr(bstrName);
	PY_INTERFACE_POSTCALL;
	if (FAILED(sc))
		return PyCom_BuildPyException(sc);

	return PyCom_PyObjectFromIUnknown(ptl, IID_ITypeLib);
}
コード例 #30
0
// @pymethod <o PyIStorage>|PyIStorage|OpenStorage|Opens an existing storage object with the specified name in the specified access mode.
PyObject *PyIStorage::OpenStorage(PyObject *self, PyObject *args)
{
	IStorage *pIS = GetI(self);
	if ( pIS == NULL )
		return NULL;
	// @pyparm string|pwcsName||Name of the storage, or None.
	// @pyparm <o PyIStorage>|pstgPriority||If the pstgPriority parameter is not None, it is a <o PyIStorage> object to a previous opening of an element of the storage object, 
	// usually one that was opened in priority mode. The storage object should be closed and re-opened 
	// according to grfMode. When the <om PyIStorage.OpenStorage> method returns, pstgPriority is no longer valid - use the result value. 
	// If the pstgPriority parameter is None, it is ignored.
	// @pyparm int|grfMode||Specifies the access mode to use when opening the storage object. See the STGM enumeration values for descriptions of the possible values. Whatever other modes you may choose, you must at least specify STGM_SHARE_EXCLUSIVE when calling this method. 
	// @pyparm <o SNB>|snbExclude||Reserved for later - Must be None
	// @pyparm int|reserved|0|Reserved integer param.
	PyObject *obName;
	PyObject *obpstgPriority;
	DWORD grfMode;
	DWORD reserved = 0;
	char *temp = NULL;
	if ( !PyArg_ParseTuple(args, "OOi|zi:OpenStorage", &obName, &obpstgPriority, &grfMode, &temp, &reserved) )
		return NULL;
	IStorage *pstgPriority;
	IStorage *ppstg;
	BOOL bPythonIsHappy = TRUE;
	BSTR bstrName;
	bPythonIsHappy = PyWinObject_AsBstr(obName, &bstrName, TRUE);
	if (!PyCom_InterfaceFromPyObject(obpstgPriority, IID_IStorage, (void **)&pstgPriority, TRUE /* bNoneOK */))
		 bPythonIsHappy = FALSE;
	if (!bPythonIsHappy) return NULL;
	PY_INTERFACE_PRECALL;
	HRESULT hr = pIS->OpenStorage( bstrName, pstgPriority, grfMode, NULL, reserved, &ppstg );
	if ( pstgPriority != NULL )
		pstgPriority->Release();
	PyWinObject_FreeBstr(bstrName);
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pIS, IID_IStorage);

	return PyCom_PyObjectFromIUnknown(ppstg, IID_IStorage, FALSE);
}