#54 Windows 98 Icon problem

closed-fixed
nobody
None
5
2004-07-13
2004-06-17
Rene Aguirre
No

I think this is a known bug, I succeed to fix this problem
changing the MapExistingFile function, the idea is to use
the standard CreateFile function only for Windows 98.
Hope this helps, I don't know if already fixed in CVS.

======== Code starts =========
static char *MapExistingFile (Py_UNICODE *pathname,
DWORD *psize)
{
HANDLE hFile, hFileMapping;
DWORD nSizeLow, nSizeHigh;
char *data;
size_t npathsize;
LPSTR lpPathNameA[512]; /*up to 255 chars */

if (GetVersion() & 0x80000000) {
/* Win 95, 98, Me */
/* Get the size of the Unicode string */
npathsize = wcslen(pathname)+1;

/* Allocate enough space for the Ansi string, doesn't
work w/ Windows 98 and MingW */
/*LPSTR lpPathNameA = _alloca((npathsize + 1) * 2);
*/

/* Convert the string from Unicode */
WideCharToMultiByte(CP_ACP, 0, pathname,
npathsize,
lpPathNameA, npathsize * 2, NULL,
NULL);
hFile = CreateFileA(lpPathNameA,
GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING,
NULL, NULL);
}
else {
/* Win NT, 2000, XP */
hFile = CreateFileW(pathname,
GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
}
if (hFile == INVALID_HANDLE_VALUE)
return NULL;
nSizeLow = GetFileSize(hFile, &nSizeHigh);
hFileMapping = CreateFileMapping(hFile,
NULL,
PAGE_READONLY, 0, 0, NULL);
CloseHandle (hFile);

if (hFileMapping == INVALID_HANDLE_VALUE)
return NULL;

data = MapViewOfFile(hFileMapping,
FILE_MAP_READ, 0, 0, 0);

CloseHandle(hFileMapping);
*psize = nSizeLow;
return data;
}
====== code ends =========

Discussion

  • Rene Aguirre
    Rene Aguirre
    2004-06-18

    Logged In: YES
    user_id=524653

    My icon.rc file for mingw

     
  • Thomas Heller
    Thomas Heller
    2004-07-13

    • status: open --> closed-fixed
     
  • Thomas Heller
    Thomas Heller
    2004-07-13

    Logged In: YES
    user_id=11105

    Rene, I think py2exe 0.5.2 fixes this.

    Thanks.