Update of /cvsroot/pywin32/pywin32/win32/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28067/win32/src
Modified Files:
win32apimodule.cpp
Log Message:
LoadString takes nbr of characters as input instead of nbr of bytes
Index: win32apimodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** win32apimodule.cpp 5 Mar 2005 04:42:38 -0000 1.47
--- win32apimodule.cpp 2 May 2005 03:31:11 -0000 1.48
***************
*** 3795,3799 ****
{
HMODULE hModule;
! int numChars = 1024;
UINT stringId;
if ( !PyArg_ParseTuple(args, "ii|i",
--- 3795,3799 ----
{
HMODULE hModule;
! int numChars = 1024, gotChars=0;
UINT stringId;
if ( !PyArg_ParseTuple(args, "ii|i",
***************
*** 3802,3817 ****
&numChars)) // @pyparm int|numChars|1024|Number of characters to allocate for the return buffer.
return NULL;
! UINT numBytes = sizeof(WCHAR) * numChars;
WCHAR *buffer = (WCHAR *)malloc(numBytes);
! if (buffer==NULL) {
! PyErr_SetString(PyExc_MemoryError, "Allocating buffer for LoadString");
! return NULL;
! }
! int gotBytes = LoadStringW(hModule, stringId, buffer, numBytes);
PyObject *rc;
! if (gotBytes==0)
rc = ReturnAPIError("LoadString");
else
! rc = PyWinObject_FromWCHAR(buffer, gotBytes);
free(buffer);
return rc;
--- 3802,3815 ----
&numChars)) // @pyparm int|numChars|1024|Number of characters to allocate for the return buffer.
return NULL;
! int numBytes = sizeof(WCHAR) * numChars;
WCHAR *buffer = (WCHAR *)malloc(numBytes);
! if (buffer==NULL)
! return PyErr_Format(PyExc_MemoryError, "Allocating buffer of %d bytes for LoadString", numBytes);
! gotChars = LoadStringW(hModule, stringId, buffer, numChars);
PyObject *rc;
! if (gotChars==0)
rc = ReturnAPIError("LoadString");
else
! rc = PyWinObject_FromWCHAR(buffer, gotChars);
free(buffer);
return rc;
|