[pywin32-checkins] pywin32/win32/src PyWinTypes.h,1.21,1.22 win32apimodule.cpp,1.36,1.37
OLD project page for the Python extensions for Windows
                
                Brought to you by:
                
                    mhammond
                    
                
            
            
        
        
        
    | 
      
      
      From: Mark H. <mha...@us...> - 2004-06-12 07:46:03
      
     | 
| Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13361 Modified Files: PyWinTypes.h win32apimodule.cpp Log Message: Allow an extension to register a hmodule that provides error messages for our standard API error. Used by the win32inet and win32net modules, both of which return error codes with their own range, and with the corresponding messages in their own hmodule. Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** win32apimodule.cpp 9 Apr 2004 11:08:37 -0000 1.36 --- win32apimodule.cpp 12 Jun 2004 07:45:54 -0000 1.37 *************** *** 503,508 **** const int bufSize = 512; char buf[bufSize]; // @pyseeapi FormatMessage ! if (::FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, errCode, 0, buf, bufSize, NULL )<=0) return ReturnAPIError("FormatMessage"); return Py_BuildValue("s", buf); --- 503,512 ---- const int bufSize = 512; char buf[bufSize]; + DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; + HMODULE hmodule = PyWin_GetErrorMessageModule(errCode); + if (hmodule) + flags |= FORMAT_MESSAGE_FROM_HMODULE; // @pyseeapi FormatMessage ! if (::FormatMessage(flags, hmodule, errCode, 0, buf, bufSize, NULL )<=0) return ReturnAPIError("FormatMessage"); return Py_BuildValue("s", buf); Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** PyWinTypes.h 30 Mar 2004 04:38:17 -0000 1.21 --- PyWinTypes.h 12 Jun 2004 07:45:54 -0000 1.22 *************** *** 74,77 **** --- 74,82 ---- */ extern PYWINTYPES_EXPORT PyObject *PyWinExc_ApiError; + // Register a Windows DLL that contains the messages in the specified range. + extern PYWINTYPES_EXPORT BOOL PyWin_RegisterErrorMessageModule(DWORD first, DWORD last, HINSTANCE hmod); + // Get the previously registered hmodule for an error code. + extern PYWINTYPES_EXPORT HINSTANCE PyWin_GetErrorMessageModule(DWORD err); + /* A global function that sets an API style error (ie, (code, fn, errTest)) */ |