Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Pythonwin/win32view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,8 +839,8 @@ static PyObject *ui_edit_window_save_file(PyObject *self, PyObject *args)
CDocument *pDocument = pView->GetDocument();
if (pDocument)
pDocument->SetModifiedFlag(FALSE); // start off with unmodified
PyWinObject_FreeTCHAR(fileName);
GUI_END_SAVE;
PyWinObject_FreeTCHAR(fileName);
RETURN_NONE;
}
// @pymethod tuple|PyCEditView|PreCreateWindow|Calls the underlying MFC PreCreateWindow method.
Expand Down
2 changes: 1 addition & 1 deletion Pythonwin/win32win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1654,9 +1654,9 @@ static PyObject *ui_window_message_box(PyObject *self, PyObject *args)
// @pyseemfc CWnd|MessageBox

rc = pWnd->MessageBox(message, title, style);
GUI_END_SAVE;
PyWinObject_FreeTCHAR(message);
PyWinObject_FreeTCHAR(title);
GUI_END_SAVE;
return Py_BuildValue("i", rc);
// @rdesc An integer identifying the button pressed to dismiss the dialog.
}
Expand Down
2 changes: 1 addition & 1 deletion com/win32com/src/extensions/PyIType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,8 +688,8 @@ PyObject *pythoncom_loadtypelib(PyObject *self, PyObject *args)
ITypeLib *ptl;
PY_INTERFACE_PRECALL;
SCODE sc = LoadTypeLib(bstrName, &ptl);
PyWinObject_FreeBstr(bstrName);
PY_INTERFACE_POSTCALL;
PyWinObject_FreeBstr(bstrName);
if (FAILED(sc))
return PyCom_BuildPyException(sc);

Expand Down
2 changes: 1 addition & 1 deletion com/win32comext/bits/src/PyIBackgroundCopyJob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,9 +620,9 @@ PyObject *PyIBackgroundCopyJob::SetProxySettings(PyObject *self, PyObject *args)
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIBCJ->SetProxySettings(ProxyUsage, ProxyList, ProxyBypassList);
PY_INTERFACE_POSTCALL;
PyWinObject_FreeWCHAR(ProxyList);
PyWinObject_FreeWCHAR(ProxyBypassList);
PY_INTERFACE_POSTCALL;
if (FAILED(hr))
return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob);
Py_INCREF(Py_None);
Expand Down
2 changes: 1 addition & 1 deletion com/win32comext/internet/src/PyIDocHostUIHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ PyObject *PyIDocHostUIHandler::TranslateUrl(PyObject *self, PyObject *args)
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIDHUIH->TranslateUrl(dwTranslate, pchURLIn, &pchURLOut);
PyWinObject_FreeWCHAR(pchURLIn);
PY_INTERFACE_POSTCALL;
PyWinObject_FreeWCHAR(pchURLIn);
if (FAILED(hr))
return PyCom_BuildPyException(hr, pIDHUIH, IID_IDocHostUIHandler);
PyObject *pyretval = MakeOLECHARToObj(pchURLOut);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ PyObject *PyIInternetSecurityManager::ProcessUrlAction(PyObject *self, PyObject
PY_INTERFACE_PRECALL;
hr = pIISM->ProcessUrlAction(pwszUrl, dwAction, (BYTE *)&dwPolicy, sizeof(dwPolicy), (BYTE *)context, cbcontext,
dwFlags, 0);
PyWinObject_FreeWCHAR(pwszUrl);
PY_INTERFACE_POSTCALL;
PyWinObject_FreeWCHAR(pwszUrl);
if (FAILED(hr))
return PyCom_BuildPyException(hr, pIISM, IID_IInternetSecurityManager);
return Py_BuildValue("ll", hr, dwPolicy);
Expand Down
7 changes: 3 additions & 4 deletions com/win32comext/shell/src/PyICopyHook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ PyObject *PyICopyHookA::CopyCallback(PyObject *self, PyObject *args)
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pICH->CopyCallback(hwnd, wFunc, wFlags, srcFile, srcAttribs, destFile, destAttribs);
PY_INTERFACE_POSTCALL;
PyWinObject_FreeChars(srcFile);
PyWinObject_FreeChars(destFile);

PY_INTERFACE_POSTCALL;

if (FAILED(hr))
return PyCom_BuildPyException(hr, pICH, IID_IShellCopyHook);
Py_INCREF(Py_None);
Expand Down Expand Up @@ -143,10 +142,10 @@ PyObject *PyICopyHookW::CopyCallback(PyObject *self, PyObject *args)
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pICH->CopyCallback(hwnd, wFunc, wFlags, srcFile, srcAttribs, destFile, destAttribs);
PyWinObject_FreeWCHAR(srcFile);
PyWinObject_FreeWCHAR(destFile);

PY_INTERFACE_POSTCALL;
PyWinObject_FreeWCHAR(srcFile);
PyWinObject_FreeWCHAR(destFile);

if (FAILED(hr))
return PyCom_BuildPyException(hr, pICH, IID_IShellCopyHook);
Expand Down
3 changes: 2 additions & 1 deletion com/win32comext/shell/src/PyIExtractIcon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ PyObject *PyIExtractIcon::Extract(PyObject *self, PyObject *args)
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIEI->Extract(pszFile, nIconIndex, &hiconLarge, &hiconSmall, nIconSize);
PyWinObject_FreeChars(pszFile);
PY_INTERFACE_POSTCALL;
PyWinObject_FreeChars(pszFile);

if (FAILED(hr))
return PyCom_BuildPyException(hr, pIEI, IID_IExtractIcon);
if (hr == S_FALSE)
Expand Down
3 changes: 2 additions & 1 deletion com/win32comext/shell/src/PyIExtractIconW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ PyObject *PyIExtractIconW::Extract(PyObject *self, PyObject *args)
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIEI->Extract(pszFile, nIconIndex, &hiconLarge, &hiconSmall, nIconSize);
PyWinObject_FreeWCHAR(pszFile);
PY_INTERFACE_POSTCALL;
PyWinObject_FreeWCHAR(pszFile);

if (FAILED(hr))
return PyCom_BuildPyException(hr, pIEI, IID_IExtractIconW);
if (hr == S_FALSE)
Expand Down
279 changes: 140 additions & 139 deletions com/win32comext/shell/src/PyIQueryAssociations.cpp
Original file line number Diff line number Diff line change
@@ -1,139 +1,140 @@
// This file implements the IQueryAssociations Interface and Gateway for Python.
// Generated by makegw.py

#include "shell_pch.h"
#include "PyIQueryAssociations.h"

// @doc - This file contains autoduck documentation
// ---------------------------------------------------
//
// Interface Implementation

PyIQueryAssociations::PyIQueryAssociations(IUnknown *pdisp) : PyIUnknown(pdisp) { ob_type = &type; }

PyIQueryAssociations::~PyIQueryAssociations() {}

/* static */ IQueryAssociations *PyIQueryAssociations::GetI(PyObject *self)
{
return (IQueryAssociations *)PyIUnknown::GetI(self);
}

// @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;
}

// XXX - GetData not implemented - memory management unclear - XXX

// @pymethod int|PyIQueryAssociations|GetKey|Searches for and retrieves a file association-related key from the
// registry.
PyObject *PyIQueryAssociations::GetKey(PyObject *self, PyObject *args)
{
IQueryAssociations *pIQA = GetI(self);
if (pIQA == NULL)
return NULL;
// @pyparm int|flags||Used to control the search.
// @pyparm int|assocKey||Specifies the type of key that is to be returned.
// @pyparm string||extra|Optional string with information about the location of the key.
// It is normally set to a shell verb such as 'open'. Set this parameter to None if it is not used.
int flags, assoc;
PyObject *obExtra = Py_None;
HKEY ret = NULL;
WCHAR *pszExtra = NULL;
if (!PyArg_ParseTuple(args, "ii|O:GetKey", &flags, &assoc, &obExtra))
return NULL;
if (!PyWinObject_AsWCHAR(obExtra, &pszExtra, TRUE))
return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIQA->GetKey(flags, (ASSOCKEY)assoc, pszExtra, &ret);
PyWinObject_FreeWCHAR(pszExtra);
PY_INTERFACE_POSTCALL;
if (FAILED(hr))
return PyCom_BuildPyException(hr, pIQA, IID_IQueryAssociations);
// observation of the "open handles" count in task-manager indicates
// this key needs to be closed!
return PyWinObject_FromHKEY(ret);
}

// @pymethod int|PyIQueryAssociations|GetString|Searches for and retrieves a file association-related string from the
// registry.
PyObject *PyIQueryAssociations::GetString(PyObject *self, PyObject *args)
{
IQueryAssociations *pIQA = GetI(self);
if (pIQA == NULL)
return NULL;
// @pyparm int|flags||Used to control the search.
// @pyparm int|assocStr||Specifies the type of string that is to be returned.
// @pyparm string||extra|Optional string with information about the location of the key.
// It is normally set to a shell verb such as 'open'. Set this parameter to None if it is not used.
int flags, assoc;
PyObject *obExtra = Py_None;
HKEY *ret = NULL;
WCHAR *pszExtra = NULL;
if (!PyArg_ParseTuple(args, "ll|O:GetString", &flags, &assoc, &obExtra))
return NULL;
// @comm Note that ASSOCF_NOTRUNCATE semantics are currently not supported -
// the buffer passed is 2048 bytes long, and will be truncated by the
// shell if too small.
WCHAR result_buf[2048];
DWORD result_size = sizeof(result_buf) / sizeof(result_buf[0]);
if (flags & ASSOCF_NOTRUNCATE)
return PyErr_Format(PyExc_ValueError, "Can not set ASSOCF_NOTRUNCATE - these semantics are not supported");
if (!PyWinObject_AsWCHAR(obExtra, &pszExtra, TRUE))
return NULL;

HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIQA->GetString(flags, (ASSOCSTR)assoc, pszExtra, result_buf, &result_size);
PyWinObject_FreeWCHAR(pszExtra);
PY_INTERFACE_POSTCALL;
if (FAILED(hr))
return PyCom_BuildPyException(hr, pIQA, IID_IQueryAssociations);
// docs don't explicitly say if result_size includes NULL. It says:
// "will be set to the number of characters actually placed in the buffer"
return PyWinObject_FromWCHAR(result_buf, result_size - 1);
}

// @object PyIQueryAssociations|Description of the interface
static struct PyMethodDef PyIQueryAssociations_methods[] = {
{"Init", PyIQueryAssociations::Init,
1}, // @pymeth Init|Initializes the IQueryAssociations interface and sets the root key to the appropriate ProgID.
{"GetKey", PyIQueryAssociations::GetKey,
1}, // @pymeth GetKey|Searches for and retrieves a file association-related key from the registry.
{"GetString", PyIQueryAssociations::GetString,
1}, // @pymeth GetString|Searches for and retrieves a file association-related string from the registry.
{NULL}};

PyComTypeObject PyIQueryAssociations::type("PyIQueryAssociations", &PyIUnknown::type, sizeof(PyIQueryAssociations),
PyIQueryAssociations_methods, GET_PYCOM_CTOR(PyIQueryAssociations));
// This file implements the IQueryAssociations Interface and Gateway for Python.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you may have accidentally changed line endings or something in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, downloading the raw File shows CRLF instead of LF of all the other files. I will try to fix it.

// Generated by makegw.py

#include "shell_pch.h"
#include "PyIQueryAssociations.h"

// @doc - This file contains autoduck documentation
// ---------------------------------------------------
//
// Interface Implementation

PyIQueryAssociations::PyIQueryAssociations(IUnknown *pdisp) : PyIUnknown(pdisp) { ob_type = &type; }

PyIQueryAssociations::~PyIQueryAssociations() {}

/* static */ IQueryAssociations *PyIQueryAssociations::GetI(PyObject *self)
{
return (IQueryAssociations *)PyIUnknown::GetI(self);
}

// @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);
PY_INTERFACE_POSTCALL;
PyWinObject_FreeWCHAR(pszAssoc);

if (FAILED(hr))
return PyCom_BuildPyException(hr, pIQA, IID_IQueryAssociations);
Py_INCREF(Py_None);
return Py_None;
}

// XXX - GetData not implemented - memory management unclear - XXX

// @pymethod int|PyIQueryAssociations|GetKey|Searches for and retrieves a file association-related key from the
// registry.
PyObject *PyIQueryAssociations::GetKey(PyObject *self, PyObject *args)
{
IQueryAssociations *pIQA = GetI(self);
if (pIQA == NULL)
return NULL;
// @pyparm int|flags||Used to control the search.
// @pyparm int|assocKey||Specifies the type of key that is to be returned.
// @pyparm string||extra|Optional string with information about the location of the key.
// It is normally set to a shell verb such as 'open'. Set this parameter to None if it is not used.
int flags, assoc;
PyObject *obExtra = Py_None;
HKEY ret = NULL;
WCHAR *pszExtra = NULL;
if (!PyArg_ParseTuple(args, "ii|O:GetKey", &flags, &assoc, &obExtra))
return NULL;
if (!PyWinObject_AsWCHAR(obExtra, &pszExtra, TRUE))
return NULL;
HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIQA->GetKey(flags, (ASSOCKEY)assoc, pszExtra, &ret);
PY_INTERFACE_POSTCALL;
PyWinObject_FreeWCHAR(pszExtra);
if (FAILED(hr))
return PyCom_BuildPyException(hr, pIQA, IID_IQueryAssociations);
// observation of the "open handles" count in task-manager indicates
// this key needs to be closed!
return PyWinObject_FromHKEY(ret);
}

// @pymethod int|PyIQueryAssociations|GetString|Searches for and retrieves a file association-related string from the
// registry.
PyObject *PyIQueryAssociations::GetString(PyObject *self, PyObject *args)
{
IQueryAssociations *pIQA = GetI(self);
if (pIQA == NULL)
return NULL;
// @pyparm int|flags||Used to control the search.
// @pyparm int|assocStr||Specifies the type of string that is to be returned.
// @pyparm string||extra|Optional string with information about the location of the key.
// It is normally set to a shell verb such as 'open'. Set this parameter to None if it is not used.
int flags, assoc;
PyObject *obExtra = Py_None;
HKEY *ret = NULL;
WCHAR *pszExtra = NULL;
if (!PyArg_ParseTuple(args, "ll|O:GetString", &flags, &assoc, &obExtra))
return NULL;
// @comm Note that ASSOCF_NOTRUNCATE semantics are currently not supported -
// the buffer passed is 2048 bytes long, and will be truncated by the
// shell if too small.
WCHAR result_buf[2048];
DWORD result_size = sizeof(result_buf) / sizeof(result_buf[0]);
if (flags & ASSOCF_NOTRUNCATE)
return PyErr_Format(PyExc_ValueError, "Can not set ASSOCF_NOTRUNCATE - these semantics are not supported");
if (!PyWinObject_AsWCHAR(obExtra, &pszExtra, TRUE))
return NULL;

HRESULT hr;
PY_INTERFACE_PRECALL;
hr = pIQA->GetString(flags, (ASSOCSTR)assoc, pszExtra, result_buf, &result_size);
PY_INTERFACE_POSTCALL;
PyWinObject_FreeWCHAR(pszExtra);
if (FAILED(hr))
return PyCom_BuildPyException(hr, pIQA, IID_IQueryAssociations);
// docs don't explicitly say if result_size includes NULL. It says:
// "will be set to the number of characters actually placed in the buffer"
return PyWinObject_FromWCHAR(result_buf, result_size - 1);
}

// @object PyIQueryAssociations|Description of the interface
static struct PyMethodDef PyIQueryAssociations_methods[] = {
{"Init", PyIQueryAssociations::Init,
1}, // @pymeth Init|Initializes the IQueryAssociations interface and sets the root key to the appropriate ProgID.
{"GetKey", PyIQueryAssociations::GetKey,
1}, // @pymeth GetKey|Searches for and retrieves a file association-related key from the registry.
{"GetString", PyIQueryAssociations::GetString,
1}, // @pymeth GetString|Searches for and retrieves a file association-related string from the registry.
{NULL}};

PyComTypeObject PyIQueryAssociations::type("PyIQueryAssociations", &PyIUnknown::type, sizeof(PyIQueryAssociations),
PyIQueryAssociations_methods, GET_PYCOM_CTOR(PyIQueryAssociations));
Loading