X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/978f48c64808f96853b9e3ac08d4630d670d724c..76d81b4d11617b806d6ab9bd60614c39999cdece:/src/msw/gsockmsw.c diff --git a/src/msw/gsockmsw.c b/src/msw/gsockmsw.c index f9efe7cb86..4ff547fe94 100644 --- a/src/msw/gsockmsw.c +++ b/src/msw/gsockmsw.c @@ -24,7 +24,7 @@ * 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 @@ -32,12 +32,25 @@ */ #ifdef __WXWINCE__ -#include + /* windows.h results in tons of warnings at max warning level */ +# ifdef _MSC_VER +# pragma warning(push, 1) + /* + "unreferenced inline function has been removed": this is not + suppressed by push above as it is given at the end of the + compilation unit + */ +# pragma warning(disable:4514) +# endif +# include +# ifdef _MSC_VER +# pragma warning(pop) +# 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__) @@ -86,7 +99,7 @@ HINSTANCE wxGetInstance(void); #define CLASSNAME TEXT("_GSocket_Internal_Window_Class") /* implemented in utils.cpp */ -extern HWND +extern WXDLLIMPEXP_BASE HWND wxCreateHiddenWindow(LPCTSTR *pclassname, LPCTSTR classname, WNDPROC wndproc); /* Maximum number of different GSocket objects at a given time. @@ -99,6 +112,7 @@ wxCreateHiddenWindow(LPCTSTR *pclassname, LPCTSTR classname, WNDPROC wndproc); #error "MAXSOCKETS is too big!" #endif +typedef int (PASCAL *WSAAsyncSelectFunc)(SOCKET,HWND,u_int,long); /* Global variables */ @@ -107,6 +121,8 @@ static HWND hWin; static CRITICAL_SECTION critical; static GSocket* socketList[MAXSOCKETS]; static int firstAvailable; +static WSAAsyncSelectFunc gs_WSAAsyncSelect = NULL; +static HMODULE gs_wsock32dll = 0; /* Global initializers */ @@ -129,6 +145,17 @@ int _GSocket_GUI_Init(void) } 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; } @@ -138,6 +165,13 @@ void _GSocket_GUI_Cleanup(void) DestroyWindow(hWin); UnregisterClass(CLASSNAME, INSTANCE); + /* Unlock wsock32.dll */ + if (gs_wsock32dll) + { + FreeLibrary(gs_wsock32dll); + gs_wsock32dll = 0; + } + /* Delete critical section */ DeleteCriticalSection(&critical); } @@ -267,7 +301,7 @@ void _GSocket_Enable_Events(GSocket *socket) 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); } } @@ -280,7 +314,7 @@ void _GSocket_Disable_Events(GSocket *socket) 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); } }