* RPCNOTIFICATION_ROUTINE
*/
#ifdef _MSC_VER
-# pragma warning(disable:4115) /* named type definition in parentheses */
+# pragma warning(disable:4115) /* named type definition in parentheses */
#endif
/* This needs to be before the wx/defs/h inclusion
*/
#ifdef __WXWINCE__
-#include <windows.h>
+ /* windows.h results in tons of warnings at max warning level */
+# ifdef _MSC_VER
+# pragma warning(push, 1)
+# endif
+# include <windows.h>
+# ifdef _MSC_VER
+# pragma warning(pop)
+# pragma warning(disable:4514)
+# endif
#endif
#ifndef __GSOCKET_STANDALONE__
-#include "wx/defs.h"
-#include "wx/setup.h"
+# include "wx/platform.h"
+# include "wx/setup.h"
#endif
#if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__)
#include "gsockmsw.h"
#include "gsocket.h"
-/* If not using wxWindows, a global var called hInst must
+/* If not using wxWidgets, a global var called hInst must
* be available and it must contain the app's instance
* handle.
*/
#error "MAXSOCKETS is too big!"
#endif
+typedef int (PASCAL *WSAAsyncSelectFunc)(SOCKET,HWND,u_int,long);
/* Global variables */
static CRITICAL_SECTION critical;
static GSocket* socketList[MAXSOCKETS];
static int firstAvailable;
+static WSAAsyncSelectFunc gs_WSAAsyncSelect = NULL;
+static HMODULE gs_wsock32dll = 0;
/* Global initializers */
}
firstAvailable = 0;
+ /* Load WSAAsyncSelect from wsock32.dll (we don't link against it
+ statically to avoid dependency on wsock32.dll for apps that don't use
+ sockets): */
+ gs_wsock32dll = LoadLibraryA("wsock32.dll");
+ if (!gs_wsock32dll)
+ return FALSE;
+ gs_WSAAsyncSelect =(WSAAsyncSelectFunc)GetProcAddress(gs_wsock32dll,
+ "WSAAsyncSelect");
+ if (!gs_WSAAsyncSelect)
+ return FALSE;
+
return TRUE;
}
DestroyWindow(hWin);
UnregisterClass(CLASSNAME, INSTANCE);
+ /* Unlock wsock32.dll */
+ if (gs_wsock32dll)
+ {
+ FreeLibrary(gs_wsock32dll);
+ gs_wsock32dll = 0;
+ }
+
/* Delete critical section */
DeleteCriticalSection(&critical);
}
long lEvent = socket->m_server?
FD_ACCEPT : (FD_READ | FD_WRITE | FD_CONNECT | FD_CLOSE);
- WSAAsyncSelect(socket->m_fd, hWin, socket->m_msgnumber, lEvent);
+ gs_WSAAsyncSelect(socket->m_fd, hWin, socket->m_msgnumber, lEvent);
}
}
if (socket->m_fd != INVALID_SOCKET)
{
- WSAAsyncSelect(socket->m_fd, hWin, socket->m_msgnumber, 0);
+ gs_WSAAsyncSelect(socket->m_fd, hWin, socket->m_msgnumber, 0);
}
}