OdbcConnectionUtil::~OdbcConnectionUtil(void) { if (m_SetupValues->PropertyExist( L"clean" )) { FdoStringP pValue = m_SetupValues->GetPropertyValue( L"clean" ); if (pValue == L"false") return; } FdoPtr<FdoStringCollection> files = FdoStringCollection::Create(); FdoCommonFile::GetAllFiles (L"", files); FdoStringP pTypeName = L"OdbcMySql"; pTypeName += m_IdTest; CleanFiles(files, pTypeName); pTypeName = L"OdbcSqlServer"; pTypeName += m_IdTest; CleanFiles(files, pTypeName); pTypeName = L"OdbcOracle"; pTypeName += m_IdTest; CleanFiles(files, pTypeName); pTypeName = L"OdbcAccess"; pTypeName += m_IdTest; CleanFiles(files, pTypeName); pTypeName = L"OdbcExcel"; pTypeName += m_IdTest; CleanFiles(files, pTypeName); #ifdef _WIN32 if (m_SetupMySqlDSNdone) TeardownMySqlDSN(); if (m_SetupSqlServerDSNdone) TeardownSqlServerDSN(); if (m_SetupOracleDSNdone) TeardownOracleDSN(); if (m_SetupAccessDSNdone) TeardownAccessDSN(); if (m_SetupDbaseDSNdone) TeardownDbaseDSN(); if (m_SetupExcelDSNdone) TeardownExcelDSN(); if (m_SetupTextDSNdone) TeardownTextDSN(); #endif }
int __stdcall wWinMain(HINSTANCE module, HINSTANCE, wchar_t* cc, int) { static int count = 0; static HPEN pen_dot = ::CreatePen(PS_DOT, 1, RGB(0, 0, 0)); MessageHandler msg_handlers[] = { { WM_PAINT, [] (HWND window, WPARAM, LPARAM) -> LRESULT { PAINTSTRUCT ps; HDC dc = ::BeginPaint(window, &ps); ::Rectangle(dc, 10, 10, 100, 100); ::EndPaint(window, &ps); ++count; return 0; }}, { WM_ERASEBKGND, [] (HWND window, WPARAM wparam, LPARAM) -> LRESULT { RECT rect; VerifyNot(::GetClientRect(window, &rect), FALSE); HGDIOBJ prev_obj = ::SelectObject(HDC(wparam), pen_dot); ::Rectangle(HDC(wparam), rect.left, rect.top, rect.right, rect.bottom); ::SelectObject(HDC(wparam), prev_obj); return 0; }}, { WM_DISPLAYCHANGE, [] (HWND window, WPARAM, LPARAM) -> LRESULT { ::InvalidateRect(window, NULL, TRUE); return 0; }}, { WM_CLOSE, [] (HWND window, WPARAM, LPARAM) -> LRESULT { ::PostQuitMessage(0); return 0; }}, { WM_ENDSESSION, [] (HWND window, WPARAM, LPARAM) -> LRESULT { ::PostQuitMessage(0); return 0; }}, { WM_TIMER, [] (HWND window, WPARAM wp, LPARAM) -> LRESULT { ::KillTimer(window, wp); CleanFiles(window); return 0; }}, {-1, NULL} }; SIZE size = {300, 200}; HWND main_window = VerifyNot(MakeWindow( L"file cleaner", WS_OVERLAPPEDWINDOW | WS_VISIBLE, NULL, size, msg_handlers), HWND(NULL)); CleanFiles(main_window); MSG msg; while (VerifyNot(::GetMessageW(&msg, NULL, 0, 0), -1)) { ::DispatchMessageW(&msg); } return 0; }
int OpenImage (int nFlags, LONG lParam) { FARPROC lpfnOpenDlg; int hInFile = 0; int nError = EC_ERROR; int nFileType; OFSTRUCT Of; ATOM Atom; WORD wBytes; int hTempFile; int nErr = FALSE; /* First get szOpenFileName filled in */ switch (nFlags) { case SCAN_OPEN: CleanFiles (); Atom = (ATOM) LOWORD (lParam); wBytes = GlobalGetAtomName (Atom, szOpenFileName, 128); GlobalDeleteAtom (Atom); GetNameFromPath ((LPSTR) szImageName, (LPSTR) szOpenFileName); bIsCurrTemp = FALSE; bImageModified = FALSE; break; case USER_OPEN: // CleanFiles (); BUG HERE???? lpfnOpenDlg = MakeProcInstance ((FARPROC)OpenDlgProc, hInstIP); hInFile = DialogBox (hInstIP, "FILEDLG", hWndIP, lpfnOpenDlg); FreeProcInstance (lpfnOpenDlg); if (hInFile) { CleanFiles (); // Put here instead of before call to dialog _lclose (hInFile); // Kludge.. /* Always get image name from path. Optionally also update the szOpenDir */ GetNameFromPath ((LPSTR) szImageName, (LPSTR) szOpenFileName); if (szOpenFileName [1] == ':') // Look for A: or B:, if neither, remember open drive/directory { if (! (szOpenFileName [0] == 'A' || szOpenFileName[0] == 'B' || szOpenFileName[0] == 'a' || szOpenFileName[0] == 'b')) { SeparateFile ((LPSTR) szOpenDir, (LPSTR) szImageName, (LPSTR)szOpenFileName); _fstrcpy ((LPSTR) szSaveDir, (LPSTR) szOpenDir); } } bIsCurrTemp = FALSE; } else nErr = USER_ABANDON; bImageModified = FALSE; break; case COMMAND_LINE_OPEN: CleanFiles (); _fstrcpy ((LPSTR)szOpenFileName, (LPSTR) lParam); GetNameFromPath ((LPSTR) szImageName, (LPSTR) szOpenFileName); bIsCurrTemp = FALSE; bImageModified = FALSE; break; case TOOLS_OPEN: _fstrcpy ((LPSTR)szOpenFileName, (LPSTR) lParam); bIsCurrTemp = TRUE; break; case OIC_OPEN: case AUTO_CONVERT_OPEN: _fstrcpy ((LPSTR)szOpenFileName, (LPSTR) lParam); bIsCurrTemp = TRUE; bImageModified = FALSE; break; case CLIPBOARD_OPEN: CleanFiles (); Atom = (ATOM) LOWORD (lParam); wBytes = GlobalGetAtomName (Atom, szOpenFileName, 128); GlobalDeleteAtom (Atom); _fstrcpy ((LPSTR) szImageName, (LPSTR) "Untitled"); bIsCurrTemp = TRUE; bImageModified = FALSE; break; case GENERIC_OPEN: case UNDO_OPEN: _fstrcpy ((LPSTR)szOpenFileName, (LPSTR) lParam); break; } if (nErr != 0) return (nErr); hInFile = OpenFile ((LPSTR)szOpenFileName, (LPOFSTRUCT)&Of, OF_READWRITE); if (hInFile <= 0) { if (hInFile == 0) hInFile = IDCANCEL; nError = hInFile; return (nError); } /* Identify and Import File */ if (image_active) { _fstrcpy ((LPSTR) szTempPath, (LPSTR) szOpenFileName); // Store it somewhere SendMessage (hWndDisplay, WM_CLOSE, 0, 0); // Close that baby down! if (nFlags == USER_OPEN) // So we don't re-display dialog nFlags = COMMAND_LINE_OPEN; else if (nFlags == CLIPBOARD_OPEN) nFlags = GENERIC_OPEN; _lclose (hInFile); PostMessage (hWndIP, WM_SHOWIMAGE, nFlags, (LONG) (LPSTR) szTempPath); // Re-prime the pump return (0); } _fstrcpy ((LPSTR) szCurrFileName, (LPSTR) szOpenFileName); // For having UNDO cap. 5/91 _llseek (hInFile, 0L, 0); nFileType = IdentFormat (hInFile, (LPSTR) szOpenFileName); if (nFileType < 0) { /* File type unknown */ _lclose (hInFile); hImportFile = 0; return (nFileType); } switch (nFileType) { case IDFMT_CCPI: { char Buffer [128]; GetTempFileName (0, (LPSTR) "OIC", 0, (LPSTR) Buffer); #ifndef DECIPHER /* If file type is compressed cpi, decompress first, then re-open */ hTempFile = DecompressCPI (hInFile ,(LPSTR) Buffer); if (hTempFile > 0) { _lclose (hInFile); return (OpenImage (OIC_OPEN, (LONG) (LPSTR) Buffer)); } else return (hTempFile); } #else return (EC_UFILETYPE); #endif break; case IDFMT_WMF: { char Buffer [128]; WORD Retval; wUserImportType = (WORD) nFileType; GetTempFileName (0, (LPSTR) "WMF", 0, (LPSTR) Buffer); Retval = wmfImportMetaFile (hWndIP, hInFile, (LPSTR) Buffer); if (Retval == 0) { _lclose (hInFile); return (OpenImage (OIC_OPEN, (LONG) (LPSTR) Buffer)); } else return (USER_ABANDON); } break; case IDFMT_CPI: break; default: if (bDoDisplay) // If we are going to actually display the thing, we may need to do some stuff first.. if (bAutoConvert) { /* Now if opened image is not CPI, save as CPI and re-open as CPI */ if (wImportType != IDFMT_CPI) if (bAutoConvert) { wUserImportType = (WORD) nFileType; hImportFile = hInFile; SetState (IMPORT_TYPE, nFileType); nError = ImportFile(); if (nError != 0) return (nError); else return (DoSave (SAVE_TO_CPI)); } } break; } hImportFile = hInFile; SetState (IMPORT_TYPE, nFileType); if (! wUserImportType) wUserImportType = wImportType; nError = ImportFile(); if (nError >= 0) if (! bDoDisplay) PostMessage (hWndIP, WM_COMMAND, IDM_SAVE, 0L); return (nError); }