#include <windows.h>
#include <winsock.h>

BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
    switch(fdwReason)
    {
		WSADATA wsadata;
        case    DLL_PROCESS_ATTACH:
			if (WSAStartup(MAKEWORD(2, 2), &wsadata) != 0) {
				OutputDebugString(_T("WSASartup() failed."));
				return FALSE;
			}
			// スレッド関連通知は不要
			DisableThreadLibraryCalls(hinstDLL);
            break;

        case    DLL_PROCESS_DETACH:
			if (WSACleanup() != 0) {
				return FALSE;
			}
            break;

    }
    return  TRUE;
}
