本文整理汇总了C++中PyWinObject_AsWCHAR函数的典型用法代码示例。如果您正苦于以下问题:C++ PyWinObject_AsWCHAR函数的具体用法?C++ PyWinObject_AsWCHAR怎么用?C++ PyWinObject_AsWCHAR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyWinObject_AsWCHAR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetI
// @pymethod |PyIBackgroundCopyJob|SetProxySettings|Description of SetProxySettings.
PyObject *PyIBackgroundCopyJob::SetProxySettings(PyObject *self, PyObject *args)
{
IBackgroundCopyJob *pIBCJ = GetI(self);
if ( pIBCJ == NULL )
return NULL;
BG_JOB_PROXY_USAGE ProxyUsage;
// @pyparm int|ProxyUsage||Description for ProxyUsage
WCHAR * ProxyList;
PyObject *obProxyList;
// @pyparm unicode|ProxyList||Description for ProxyList
WCHAR * ProxyBypassList;
PyObject *obProxyBypassList;
// @pyparm unicode|ProxyBypassList||Description for ProxyBypassList
if ( !PyArg_ParseTuple(args, "lOO:SetProxySettings", &ProxyUsage, &obProxyList, &obProxyBypassList) )
return NULL;
BOOL bPythonIsHappy = TRUE;
if (bPythonIsHappy && !PyWinObject_AsWCHAR( obProxyList, &ProxyList, TRUE )) bPythonIsHappy = FALSE;
if (bPythonIsHappy && !PyWinObject_AsWCHAR( obProxyBypassList, &ProxyBypassList, TRUE )) bPythonIsHappy = FALSE;
if (!bPythonIsHappy) return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIBCJ->SetProxySettings( ProxyUsage, ProxyList, ProxyBypassList );
PyWinObject_FreeWCHAR(ProxyList);
PyWinObject_FreeWCHAR(ProxyBypassList);
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob );
Py_INCREF(Py_None);
return Py_None;
}
示例2: returning
// @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;
}
示例3: PyNetUseEnum
// @pymethod ([dict, ...], total, resumeHandle)|win32net|NetUseEnum|Retrieves information about transport protocols that are currently managed by the redirector
// @rdesc The result is a list of items read (with each item being a dictionary of format
// <o PyUSE_INFO_*>, depending on the level parameter),
// the total available, and a new "resume handle". The first time you call
// this function, you should pass zero for the resume handle. If more data
// is available than what was returned, a new non-zero resume handle will be
// returned, which can be used to call the function again to fetch more data.
// This process may repeat, each time with a new resume handle, until zero is
// returned for the new handle, indicating all the data has been read.
PyObject *
PyNetUseEnum(PyObject *self, PyObject *args)
{
WCHAR *szServer = NULL, *szDomain = NULL;
PyObject *obServer, *obDomain = Py_None;
PyObject *ret = NULL;
PyNET_STRUCT *pInfo;
DWORD err;
DWORD dwPrefLen = MAX_PREFERRED_LENGTH;
DWORD level;
BOOL ok = FALSE;
DWORD resumeHandle = 0;
DWORD numRead, i;
PyObject *list;
BYTE *buf = NULL;
DWORD totalEntries = 0;
// @pyparm string/<o PyUnicode>|server||The name of the server to execute on, or None.
// @pyparm int|level||The level of data required. Currently levels 0, 1 and
// 2 are supported.
// @pyparm int|resumeHandle|0|A resume handle. See the return description for more information.
// @pyparm int|prefLen|MAX_PREFERRED_LENGTH|The preferred length of the data buffer.
if (!PyArg_ParseTuple(args, "Oi|ii", &obServer, &level, &resumeHandle, &dwPrefLen))
return NULL;
if (!PyWinObject_AsWCHAR(obServer, &szServer, TRUE))
goto done;
if (!PyWinObject_AsWCHAR(obDomain, &szDomain, TRUE))
goto done;
if (!FindNET_STRUCT(level, use_infos, &pInfo))
goto done;
err = NetUseEnum(szServer, level, &buf, dwPrefLen, &numRead, &totalEntries, &resumeHandle);
if (err!=0 && err != ERROR_MORE_DATA) {
ReturnNetError("NetUseEnum",err);
goto done;
}
list = PyList_New(numRead);
if (list==NULL) goto done;
for (i=0;i<numRead;i++) {
PyObject *sub = PyObject_FromNET_STRUCT(pInfo, buf+(i*pInfo->structsize));
if (sub==NULL) goto done;
PyList_SetItem(list, i, sub);
}
resumeHandle = err==0 ? 0 : resumeHandle;
ret = Py_BuildValue("Oll", list, totalEntries, resumeHandle);
Py_DECREF(list);
ok = TRUE;
done:
if (buf) NetApiBufferFree(buf);
if (!ok) {
Py_XDECREF(ret);
ret = NULL;
}
PyWinObject_FreeWCHAR(szServer);
return ret;
// @pyseeapi NetUseEnum
}
示例4: time
// @pymethod object|win32ts|WTSQueryUserConfig|Returns user configuration
// @rdesc The type of the returned value is dependent on the config class requested
static PyObject *PyWTSQueryUserConfig(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *keywords[]={"ServerName","UserName","WTSConfigClass",NULL};
WCHAR *ServerName=NULL, *UserName=NULL;
PyObject *obServerName, *obUserName, *ret=NULL;
WTS_CONFIG_CLASS WTSConfigClass;
LPWSTR buf=NULL;
DWORD bufsize=0;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOk:WTSQueryUserConfig", keywords,
&obServerName, // @pyparm <o PyUnicode>|ServerName||Name ot terminal server
&obUserName, // @pyparm <o PyUnicode>|UserName||Name of user
&WTSConfigClass)) // @pyparm int|ConfigClass||Type of information to be returned, win32ts.WTSUserConfig*
return NULL;
if (PyWinObject_AsWCHAR(obServerName, &ServerName, TRUE)
&&PyWinObject_AsWCHAR(obUserName, &UserName, FALSE))
if (!WTSQueryUserConfig(ServerName, UserName, WTSConfigClass, &buf, &bufsize))
PyWin_SetAPIError("WTSQueryUserConfig");
else
switch(WTSConfigClass){
// @flagh ConfigClass|Returned value
case WTSUserConfigInitialProgram: // @flag WTSUserConfigInitialProgram|Unicode string, program to be run when user logs on
case WTSUserConfigWorkingDirectory: // @flag WTSUserConfigWorkingDirectory|Unicode string, working dir for initial program
case WTSUserConfigModemCallbackPhoneNumber: // @flag WTSUserConfigModemCallbackPhoneNumber|Unicode string
case WTSUserConfigTerminalServerProfilePath: // @flag WTSUserConfigTerminalServerProfilePath|Unicode string
case WTSUserConfigTerminalServerHomeDir: // @flag WTSUserConfigTerminalServerHomeDir|Unicode string
case WTSUserConfigTerminalServerHomeDirDrive: // @flag WTSUserConfigTerminalServerHomeDirDrive|Unicode string
ret=PyWinObject_FromWCHAR(buf);
break;
case WTSUserConfigfInheritInitialProgram: // @flag WTSUserConfigfInheritInitialProgram|Int
case WTSUserConfigfAllowLogonTerminalServer: // @flag WTSUserConfigfAllowLogonTerminalServer|Int, 1 if user can log on thru Terminal Service
case WTSUserConfigTimeoutSettingsConnections: // @flag WTSUserConfigTimeoutSettingsConnections |Int, max connection time (ms)
case WTSUserConfigTimeoutSettingsDisconnections:// @flag WTSUserConfigTimeoutSettingsDisconnections|Int
case WTSUserConfigTimeoutSettingsIdle: // @flag WTSUserConfigTimeoutSettingsIdle|Int, max idle time (ms)
case WTSUserConfigfDeviceClientDrives: // @flag WTSUserConfigfDeviceClientDrives|Int
case WTSUserConfigfDeviceClientPrinters: // @flag WTSUserConfigfDeviceClientPrinters|Int
case WTSUserConfigfDeviceClientDefaultPrinter: // @flag WTSUserConfigfDeviceClientDefaultPrinter|Int
case WTSUserConfigBrokenTimeoutSettings: // @flag WTSUserConfigBrokenTimeoutSettings|Int
case WTSUserConfigReconnectSettings: // @flag WTSUserConfigReconnectSettings|Int
case WTSUserConfigModemCallbackSettings: // @flag WTSUserConfigModemCallbackSettings|Int
case WTSUserConfigShadowingSettings: // @flag WTSUserConfigShadowingSettings|Int, indicates if user's session my be monitored
case WTSUserConfigfTerminalServerRemoteHomeDir: // @flag WTSUserConfigfTerminalServerRemoteHomeDir|Int,
ret=PyLong_FromUnsignedLong(*(DWORD *)buf);
break;
default:
PyErr_SetString(PyExc_NotImplementedError,"Config class not supported yet");
}
PyWinObject_FreeWCHAR(ServerName);
PyWinObject_FreeWCHAR(UserName);
if (buf)
WTSFreeMemory(buf);
return ret;
}
示例5: PyWinObject_FromHKEY
// IEmptyVolumeCache2
// @object PyIEmptyVolumeCache2|See also <o PyIEmptyVolumeCache>
// @pymeth PyIEmptyVolumeCache|Deactivate
// @pymethod |PyIEmptyVolumeCache2|InitializeEx|
STDMETHODIMP PyGEmptyVolumeCache2::InitializeEx(
/* [in] */ HKEY hkRegKey,
/* [in] */ LPCWSTR pcwszVolume,
/* [in] */ LPCWSTR pcwszKeyName,
/* [out] */ LPWSTR * ppwszDisplayName,
/* [out] */ LPWSTR * ppwszDescription,
/* [out] */ LPWSTR * ppwszBtnText,
/* [out] */ DWORD * pdwFlags)
{
PY_GATEWAY_METHOD;
BOOL bPythonIsHappy = TRUE;
ULONG dwFlags;
HRESULT hr;
PyObject *result;
PyObject *obppwszDisplayName;
PyObject *obppwszDescription;
PyObject *obppwszBtnText;
PyObject *obpcwszVolume = NULL;
PyObject *obpcwszKeyName = NULL;
PyObject *obhkRegKey = PyWinObject_FromHKEY(hkRegKey);
if (!obhkRegKey) goto args_failed;
if (!(obpcwszVolume = MakeOLECHARToObj(pcwszVolume))) goto args_failed;
if (!(obpcwszKeyName = MakeOLECHARToObj(pcwszKeyName))) goto args_failed;
hr=InvokeViaPolicy("InitializeEx", &result, "NNNk", obhkRegKey, obpcwszVolume, obpcwszKeyName, *pdwFlags);
// NOTE: From here, do *not* exit via args_failed - the args have been cleaned up
if (FAILED(hr)) return hr;
// Process the Python results, and convert back to the real params
if (!PyTuple_Check(result)) {
PyErr_Format(PyExc_TypeError,
"Initialize must return a tuple of (unicode, unicode, unicode, long) - got '%s'",
result->ob_type->tp_name);
bPythonIsHappy = FALSE;
}
if (bPythonIsHappy && !PyArg_ParseTuple(result, "OOOl" , &obppwszDisplayName, &obppwszDescription, &obppwszBtnText, &dwFlags))
bPythonIsHappy = FALSE;
if (bPythonIsHappy && !PyWinObject_AsWCHAR(obppwszDisplayName, ppwszDisplayName)) bPythonIsHappy = FALSE;
if (bPythonIsHappy && !PyWinObject_AsWCHAR(obppwszDescription, ppwszDescription)) bPythonIsHappy = FALSE;
if (bPythonIsHappy && !PyWinObject_AsWCHAR(obppwszBtnText, ppwszBtnText)) bPythonIsHappy = FALSE;
if (!bPythonIsHappy) hr = PyCom_SetAndLogCOMErrorFromPyException("InitializeEx", IID_IEmptyVolumeCache);
if (pdwFlags) *pdwFlags = dwFlags;
Py_DECREF(result);
return hr;
args_failed:
// only hit on error convering input args, not normal exit.
Py_XDECREF(obhkRegKey);
Py_XDECREF(obpcwszVolume);
Py_XDECREF(obpcwszKeyName);
return MAKE_PYCOM_GATEWAY_FAILURE_CODE("InitializeEx");
}
示例6: PyWinObject_AsMAPIStr
BOOL PyWinObject_AsMAPIStr(PyObject *stringObject, LPTSTR *pResult, BOOL asUnicode, BOOL bNoneOK /*= FALSE*/, DWORD *pResultLen /* = NULL */)
{
#if PY_MAJOR_VERSION >= 3
if (asUnicode)
return PyWinObject_AsWCHAR(stringObject, (LPWSTR *)pResult, bNoneOK, pResultLen);
else
return PyWinObject_AsString(stringObject, (LPSTR *)pResult, bNoneOK, pResultLen);
#else
if (asUnicode && PyUnicode_Check(stringObject))
return PyWinObject_AsWCHAR(stringObject, (LPWSTR *)pResult, bNoneOK, pResultLen);
// allows already encoded string pass-through workaround (backwards compat)
return PyWinObject_AsString(stringObject, (LPSTR *)pResult, bNoneOK, pResultLen);
#endif
}
示例7: GetI
// @pymethod |PyICustomDestinationList|AppendCategory|Adds a custom category to the jump list
PyObject *PyICustomDestinationList::AppendCategory(PyObject *self, PyObject *args)
{
ICustomDestinationList *pICDL = GetI(self);
if ( pICDL == NULL )
return NULL;
TmpWCHAR Category;
PyObject *obCategory, *obItems;
IObjectArray *Items;
// @pyparm str|Category||Display name of the category, can also be a dll and resource id for localization
// @pyparm <o PyIObjectArray>|Items||Collection of IShellItem and/or IShellLink interfaces
if ( !PyArg_ParseTuple(args, "OO:AppendCategory", &obCategory, &obItems))
return NULL;
if (!PyWinObject_AsWCHAR(obCategory, &Category, FALSE))
return NULL;
if (!PyCom_InterfaceFromPyInstanceOrObject(obItems, IID_IObjectArray, (void **)&Items, FALSE))
return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pICDL->AppendCategory(Category, Items);
Items->Release();
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pICDL, IID_ICustomDestinationList );
Py_INCREF(Py_None);
return Py_None;
}
示例8: GetI
// @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;
}
示例9: HRESULT
// @pymethod <o PyIID>|pythoncom|PropStgNameToFmtId|Converts a property set name to its format id (GUID)
PyObject *pythoncom_PropStgNameToFmtId(PyObject *self, PyObject *args)
{
// @pyparm string/unicode|Name||Storage stream name
FMTID fmtid;
WCHAR *oszName=NULL;
HRESULT err;
PyObject *obName=NULL;
typedef HRESULT (WINAPI * PFNPropStgNameToFmtId)(const LPOLESTR, FMTID*);
static PFNPropStgNameToFmtId pfnPropStgNameToFmtId=NULL;
static BOOL pfnchecked=FALSE;
if (!pfnchecked){
if (ole32==NULL)
ole32=GetModuleHandle(_T("Ole32.dll"));
if (ole32!=NULL)
pfnPropStgNameToFmtId = (PFNPropStgNameToFmtId)GetProcAddress(ole32, "PropStgNameToFmtId");
pfnchecked=TRUE;
}
if (pfnPropStgNameToFmtId==NULL)
return PyErr_Format(PyExc_NotImplementedError,"PropStgNameToFmtId is not available on this platform");
if (!PyArg_ParseTuple(args, "O:PropStgNameToFmtId", &obName))
return NULL;
if (!PyWinObject_AsWCHAR(obName,&oszName))
return NULL;
PY_INTERFACE_PRECALL;
err = (*pfnPropStgNameToFmtId)(oszName, &fmtid);
PY_INTERFACE_POSTCALL;
PyWinObject_FreeWCHAR(oszName);
if (err!=S_OK)
return PyCom_BuildPyException(err);
return PyWinObject_FromIID(fmtid);
}
示例10: GetI
// @pymethod |PyIActiveScriptDebug|GetScriptletTextAttributes|Description of GetScriptletTextAttributes.
PyObject *PyIActiveScriptDebug::GetScriptletTextAttributes(PyObject *self, PyObject *args)
{
PY_INTERFACE_METHOD;
IActiveScriptDebug *pIASD = GetI(self);
if ( pIASD == NULL )
return NULL;
// @pyparm string|pstrCode||The script block text.
// @pyparm string|pstrDelimiter||See <om PyIActiveScriptParse::ParseScriptText> for a description of this argument.
// @pyparm int|dwFlags||See <om PyIActiveScriptParse::ParseScriptText> for a description of this argument.
DWORD dwFlags;
PyObject *obCode, *obDelim;
if ( !PyArg_ParseTuple(args, "OOi:GetScriptletTextAttributes", &obCode, &obDelim, &dwFlags) )
return NULL;
BOOL bPythonIsHappy = TRUE;
WCHAR *pstrDelimiter;
BSTR bstr;
if (!PyWinObject_AsWCHAR(obDelim, &pstrDelimiter)) bPythonIsHappy = FALSE;
if (!PyCom_BstrFromPyObject(obCode, &bstr)) bPythonIsHappy = FALSE;
if (!bPythonIsHappy) return NULL;
ULONG uNumCodeChars = SysStringLen(bstr);
SOURCE_TEXT_ATTR *pattr = new SOURCE_TEXT_ATTR[uNumCodeChars];
PY_INTERFACE_PRECALL;
HRESULT hr = pIASD->GetScriptletTextAttributes( bstr, uNumCodeChars, pstrDelimiter, dwFlags, pattr );
PY_INTERFACE_POSTCALL;
SysFreeString(bstr);
PyWinObject_FreeWCHAR(pstrDelimiter);
if ( FAILED(hr) )
return SetPythonCOMError(self,hr);
return PyAXDebug_PyObject_FromSOURCE_TEXT_ATTR(pattr, uNumCodeChars);
}
示例11: GetI
// @pymethod |PyIPropertySystem|UnregisterPropertySchema|Removes a set of registered properties
PyObject *PyIPropertySystem::UnregisterPropertySchema(PyObject *self, PyObject *args)
{
IPropertySystem *pIPS = GetI(self);
if ( pIPS == NULL )
return NULL;
WCHAR *path;
PyObject *obpath;
// @pyparm str|Path||Path to a property schema XML file (.propdesc)
if ( !PyArg_ParseTuple(args, "O:UnregisterPropertySchema", &obpath))
return NULL;
if (!PyWinObject_AsWCHAR(obpath, &path, FALSE))
return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIPS->UnregisterPropertySchema(path);
PY_INTERFACE_POSTCALL;
PyWinObject_FreeWCHAR(path);
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pIPS, IID_IPropertySystem );
Py_INCREF(Py_None);
return Py_None;
}
示例12: GetI
// @pymethod |PyIDocHostUIHandler|TranslateUrl|Description of TranslateUrl.
PyObject *PyIDocHostUIHandler::TranslateUrl(PyObject *self, PyObject *args)
{
IDocHostUIHandler *pIDHUIH = GetI(self);
if ( pIDHUIH == NULL )
return NULL;
// @pyparm int|dwTranslate||Description for dwTranslate
// @pyparm <o unicode>|pchURLIn||Description for pchURLIn
PyObject *obpchURLIn;
DWORD dwTranslate;
OLECHAR *pchURLIn;
OLECHAR *pchURLOut = 0;
if ( !PyArg_ParseTuple(args, "lO:TranslateUrl", &dwTranslate, &obpchURLIn) )
return NULL;
if (!PyWinObject_AsWCHAR(obpchURLIn, &pchURLIn))
return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIDHUIH->TranslateUrl( dwTranslate, pchURLIn, &pchURLOut);
PyWinObject_FreeWCHAR(pchURLIn);
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pIDHUIH, IID_IDocHostUIHandler );
PyObject *pyretval = MakeOLECHARToObj(pchURLOut);
CoTaskMemFree(pchURLOut);
return pyretval;
}
示例13: PyCom_BuildPyException
// @pymethod <o PyPROPVARIANT>|propsys|PSGetNamedPropertyFromPropertyStorage|Extracts a property value from a serialized buffer by name
static PyObject *PyPSGetNamedPropertyFromPropertyStorage(PyObject *self, PyObject *args)
{
TmpWCHAR name;
void *buf;
DWORD bufsize;
PROPVARIANT val;
PyObject *obname, *obbuf;
// @pyparm buffer|ps||Bytes or buffer (or str in python 2) containing a serialized property set (see <om PyIPersistSerializedPropStorage.GetPropertyStorage>)
// @pyparm str|name||Property to return
if (!PyArg_ParseTuple(args, "OO:PSGetNamedPropertyFromPropertyStorage",
&obbuf, &obname))
return NULL;
if (!PyWinObject_AsReadBuffer(obbuf, &buf, &bufsize, FALSE))
return NULL;
if (!PyWinObject_AsWCHAR(obname, &name, FALSE))
return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = PSGetNamedPropertyFromPropertyStorage((PCUSERIALIZEDPROPSTORAGE)buf, bufsize, name, &val);
PY_INTERFACE_POSTCALL;
if (FAILED(hr))
return PyCom_BuildPyException(hr);
return PyWinObject_FromPROPVARIANT(val);
}
示例14: GetI
// @pymethod |PyIPropertyBag|Write|Called by the control to write each property in turn to the storage provided by the container.
PyObject *PyIPropertyBag::Write(PyObject *self, PyObject *args)
{
PyObject *obName;
PyObject *obValue;
// @pyparm str|propName||Name of the property to read.
// @pyparm object|value||The value for the property. The value must be able to be converted to a COM VARIANT.
if ( !PyArg_ParseTuple(args, "OO:Write", &obName, &obValue) )
return NULL;
IPropertyBag *pIPB = GetI(self);
if ( pIPB == NULL )
return NULL;
TmpWCHAR Name;
if ( !PyWinObject_AsWCHAR(obName, &Name))
return NULL;
VARIANT var;
if ( !PyCom_VariantFromPyObject(obValue, &var) )
return NULL;
PY_INTERFACE_PRECALL;
HRESULT hr = pIPB->Write(Name, &var);
VariantClear(&var);
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pIPB, IID_IPropertyBag);
Py_INCREF(Py_None);
return Py_None;
}
示例15: GetI
// @pymethod <o PyIShellItem>|PyIShellLibrary|SaveInKnownFolder|Saves the library in a known folder
PyObject *PyIShellLibrary::SaveInKnownFolder(PyObject *self, PyObject *args)
{
IShellLibrary *pISL = GetI(self);
if ( pISL == NULL )
return NULL;
KNOWNFOLDERID FolderToSaveIn;
TmpWCHAR LibraryName;
PyObject *obLibraryName;
LIBRARYSAVEFLAGS Flags;
IShellItem *SavedTo;
// @pyparm <o PyIID>|FolderToSaveIn||The destination folder, shell.FOLDERID_*
// @pyparm str|LibraryName||Filename for the new library, without file extension
// @pyparm int|Flags||Determines behaviour if file already exists, shellcon.LSF_*
if (!PyArg_ParseTuple(args, "O&Oi:SaveInKnownFolder",
PyWinObject_AsIID, &FolderToSaveIn,
&obLibraryName, &Flags))
return NULL;
if (!PyWinObject_AsWCHAR(obLibraryName, &LibraryName, FALSE))
return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pISL->SaveInKnownFolder(FolderToSaveIn, LibraryName, Flags, &SavedTo);
PY_INTERFACE_POSTCALL;
if ( FAILED(hr) )
return PyCom_BuildPyException(hr, pISL, IID_IShellLibrary );
return PyCom_PyObjectFromIUnknown(SavedTo, IID_IShellItem, FALSE);
}