| Update of /cvsroot/pywin32/pywin32/win32/src/win32net
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18426
Modified Files:
	win32netmodule.cpp 
Log Message:
Register the network error range with pywintypes, and remove our local
error routine, as pywintypes now does it for us.
Index: win32netmodule.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/win32net/win32netmodule.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** win32netmodule.cpp	21 May 2004 04:49:41 -0000	1.15
--- win32netmodule.cpp	12 Jun 2004 07:51:53 -0000	1.16
***************
*** 41,91 ****
  /* error helpers */
  
- /* error helper - GetLastError() is provided, but this is for exceptions */
  PyObject *ReturnNetError(char *fnName, long err /*=0*/)
  {
- 	static HMODULE hModule=NULL;
- 	if (hModule==NULL)
- 		hModule = LoadLibraryEx(
- 			TEXT("netmsg.dll"),
- 			NULL,
- 			LOAD_LIBRARY_AS_DATAFILE);
- 
- 	if (err==0) err = GetLastError();
- 	if(err >= NERR_BASE && err <= MAX_NERR) {
- 		if(hModule != NULL) {
- 			DWORD dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER |
- 			                      FORMAT_MESSAGE_IGNORE_INSERTS |
- 								  FORMAT_MESSAGE_FROM_HMODULE |
- 								  FORMAT_MESSAGE_FROM_SYSTEM |
- 								  FORMAT_MESSAGE_ALLOCATE_BUFFER;
- 
- 			// call FormatMessage() to allow for message text to be acquired
- 			// from the system or the supplied module handle    //
- 			WCHAR *szMessage;
- 			DWORD dwResult;
- 			if(dwResult=FormatMessage(
- 				dwFormatFlags,
- 				hModule, // module to get message from (NULL == system)
- 				err,
- 				MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
- 				(LPTSTR) &szMessage,        
- 				0,        
- 				NULL)) {
- 				// remove the \r\n, like the real API
- 				if (dwResult>2)
- 					szMessage[dwResult-2]=_T('\0');
- 				PyObject *str = PyString_FromUnicode(szMessage);
- 				LocalFree(szMessage);
- 				PyObject *v = Py_BuildValue("(izO)", err, fnName, str );
- 				Py_DECREF(str);
- 				if (v != NULL) {
- 					PyErr_SetObject(PyWinExc_ApiError, v);
- 					Py_DECREF(v);
- 					return NULL;
- 				}
- 
- 			}
- 		}
- 	}
  	return PyWin_SetAPIError(fnName, err);
  };
--- 41,46 ----
***************
*** 1150,1155 ****
    PyDict_SetItemString(dict, "SERVICE_SERVER", PyUnicode_FromWideChar(SERVICE_SERVER,wcslen(SERVICE_SERVER)));
    PyDict_SetItemString(dict, "SERVICE_WORKSTATION", PyUnicode_FromWideChar(SERVICE_WORKSTATION,wcslen(SERVICE_WORKSTATION)));
!   
!   Py_INCREF(PyWinExc_ApiError);
    AddConstant(dict, "USE_NOFORCE", USE_NOFORCE);
    AddConstant(dict, "USE_FORCE", USE_FORCE);
--- 1105,1113 ----
    PyDict_SetItemString(dict, "SERVICE_SERVER", PyUnicode_FromWideChar(SERVICE_SERVER,wcslen(SERVICE_SERVER)));
    PyDict_SetItemString(dict, "SERVICE_WORKSTATION", PyUnicode_FromWideChar(SERVICE_WORKSTATION,wcslen(SERVICE_WORKSTATION)));
! 
!   HMODULE hmod = LoadLibraryEx(TEXT("netmsg.dll"), NULL, LOAD_LIBRARY_AS_DATAFILE);
!   PyWin_RegisterErrorMessageModule(NERR_BASE,
!                                    MAX_NERR,
!                                    hmod);
    AddConstant(dict, "USE_NOFORCE", USE_NOFORCE);
    AddConstant(dict, "USE_FORCE", USE_FORCE);
 |