inline char UploadLog(unsigned long int no) { /* this function will transfer the log files one by one to the FTP server */ static BOOL semaphore = FALSE; if(semaphore == TRUE) return 0; else semaphore = TRUE; if(InternetCheckConnection(InternetCheckMask,FLAG_ICC_FORCE_CONNECTION,0)) { /* connect me to the internet */ HINTERNET hNet = InternetOpen(AppName2, PRE_CONFIG_INTERNET_ACCESS, NULL, INTERNET_INVALID_PORT_NUMBER, 0 ); if(hNet != NULL) { /* connect me to the remote FTP Server */ HINTERNET hFtp = InternetConnect(hNet,FtpServer, INTERNET_DEFAULT_FTP_PORT,FtpUserName,FtpPassword, INTERNET_SERVICE_FTP, 0, 0); if(hFtp != NULL) { /* successful connection to FTP server established */ char local_file[MAX_PATH], remote_file[MAX_PATH]; sprintf(local_file,"%s%lX%s",BaseDirectory,no,LocLogFileExt); sprintf(remote_file,"%lu-%lX%s",GetCompId(hFtp),no,SrvLogFileExt); //MessageBox(NULL,local_file,remote_file,0); if(FtpPutFile(hFtp, local_file, remote_file, 0, 0)) { /* file transfer OK */ InternetCloseHandle(hFtp); InternetCloseHandle(hNet); semaphore = FALSE; return 1; } else { /* file transfer failed */ InternetCloseHandle(hFtp); InternetCloseHandle(hNet); semaphore = FALSE; return 0; } } else { /* connection to FTP server failed */ InternetCloseHandle(hNet); semaphore = FALSE; return 0; } } else { /* connection to internet failed */ semaphore = FALSE; return 0; } } /* internet connection is not available either because the person is not online or because a firewall has blocked me */ semaphore = FALSE; return 0; }
// // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; LPSTR str = ""; switch (message) { case WM_CREATE: if (!InternetCheckConnection(_T("http://google.com"), FLAG_ICC_FORCE_CONNECTION, 0)) { MessageBox(hWnd, _T("Отсутствует или очень плохое соединение с Интернетом. Пожалуйста, проверьте соединение с сетью Интернет."), _T("Ошибка подключения к сети Интернет!"), MB_OK); SendMessage(hWnd, WM_DESTROY, 0, 0); break; } MysqlSingleConnect::getInstance().ConnectDB(hWnd); engine->CreateTPResources(); hWndTmp = hWnd; SendMessage(hWnd, WM_USER + 21, 0, 0); break; case WM_USER + 4: hWndRooms = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ROOMS), hWnd, DlgRooms); break; case WM_USER + 5: hWndRoom = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ROOM_CAP), hWnd, DlgCapRoom); break; case WM_USER + 16: hWndRoom = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ROOM_PLAYER), hWnd, DlgPlayerRoom); break; case WM_USER + 21: hWndLogin = CreateDialog(hInst, MAKEINTRESOURCE(IDD_LOGIN), hWnd, DlgLogin); break; case WM_USER + 30: hWndRegistration = CreateDialog(hInst, MAKEINTRESOURCE(IDD_REGISTRATION), hWnd, DlgRegistration); break; case WM_USER + 22: SetTimer(hWnd, 1, 1000, NULL); break; case WM_TIMER: if (engine->CheckSituation(hWnd, hWndRoom, hWndRooms)) engine->CheckRoomUpdate(hWndRoom, hWndRooms); else break; break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case ID_ABOUTMENU: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case ID_EXITMENU: SendMessage(hWnd, WM_DESTROY, 0, 0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // TODO: Add any drawing code here... EndPaint(hWnd, &ps); break; case WM_DESTROY: KillTimer(hWnd, 1); engine->DestroyTPResource(hWnd, hWndRoom); MysqlSingleConnect::getInstance().CloseDB(); delete engine; engine = nullptr; PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }