BOOL CheckVersion() { HANDLE hStdOutRead; HANDLE hStdOutWrite; BOOL retval = FALSE; STARTUPINFO si; PROCESS_INFORMATION pi; TCHAR cmdline[] = _T("openvpn --version"); char match_version[] = "OpenVPN 2."; TCHAR pwd[MAX_PATH]; char line[1024]; TCHAR *p; CLEAR(si); CLEAR(pi); /* Make handles inheritable and accessible by all */ SECURITY_DESCRIPTOR sd; SECURITY_ATTRIBUTES sa = { .nLength = sizeof(sa), .lpSecurityDescriptor = &sd, .bInheritHandle = TRUE }; if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION)) { ShowLocalizedMsg(IDS_ERR_INIT_SEC_DESC); return FALSE; } if (!SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE)) { ShowLocalizedMsg(IDS_ERR_SET_SEC_DESC_ACL); return FALSE; } /* Create the pipe for STDOUT with inheritable write end */ if (!CreatePipe(&hStdOutRead, &hStdOutWrite, &sa, 0)) { ShowLocalizedMsg(IDS_ERR_CREATE_PIPE_IN_READ); return FALSE; } if (!SetHandleInformation(hStdOutRead, HANDLE_FLAG_INHERIT, 0)) { ShowLocalizedMsg(IDS_ERR_DUP_HANDLE_IN_WRITE); goto out; } /* Construct the process' working directory */ _tcsncpy(pwd, o.exe_path, _countof(pwd)); p = _tcsrchr(pwd, _T('\\')); if (p != NULL) *p = _T('\0'); /* Fill in STARTUPINFO struct */ si.cb = sizeof(si); si.dwFlags = STARTF_USESTDHANDLES; si.hStdInput = GetStdHandle(STD_INPUT_HANDLE); si.hStdOutput = hStdOutWrite; si.hStdError = hStdOutWrite; /* Start OpenVPN to check version */ if (!CreateProcess(o.exe_path, cmdline, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, pwd, &si, &pi)) { ShowLocalizedMsg(IDS_ERR_CREATE_PROCESS, o.exe_path, cmdline, pwd); } else if (ReadLineFromStdOut(hStdOutRead, line, sizeof(line))) { #ifdef DEBUG PrintDebug(_T("VersionString: %S"), line); #endif CloseHandle(pi.hThread); CloseHandle(pi.hProcess); /* OpenVPN version 2.x */ if (strstr(line, match_version)) retval = TRUE; } out: CloseHandle(hStdOutRead); CloseHandle(hStdOutWrite); return retval; }
BOOL CT3000App::InitInstance() { try { // InitCommonControlsEx() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // Set this to include all the common control classes you want to use // in your application. InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); HRESULT hr;// if(!AfxInitRichEdit()) { AfxMessageBox(IDS_INIT_RICHEDIT_ERROR);// return FALSE;// } if (!AfxSocketInit())// { AfxMessageBox(IDP_SOCKETS_INIT_FAILED);// return FALSE;// } // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); #if 1 try { TCHAR exeFullPath[MAX_PATH+1]; // GetModuleFileName(NULL, exeFullPath, MAX_PATH); // (_tcsrchr(exeFullPath, _T('\\')))[1] = 0;// g_strDatabasefilepath=exeFullPath;// g_strExePth=g_strDatabasefilepath;// CreateDirectory(g_strExePth+_T("Database"),NULL);//creat database folder;// g_strOrigDatabaseFilePath=g_strExePth+_T("T3000.mdb");// g_strDatabasefilepath+=_T("Database\\T3000.mdb");// CString FilePath; HANDLE hFind;// WIN32_FIND_DATA wfd;// hFind = FindFirstFile(g_strDatabasefilepath, &wfd);// if (hFind==INVALID_HANDLE_VALUE)//说明当前目录下无t3000.mdb { //CopyFile(g_strOrigDatabaseFilePath,g_strDatabasefilepath,FALSE);// //没有找到就创建一个默认的数据库 FilePath=g_strExePth+_T("Database\\T3000.mdb"); HRSRC hrSrc = FindResource(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_T3000_DATABASE), _T("DB")); HGLOBAL hGlobal = LoadResource(AfxGetResourceHandle(), hrSrc); LPVOID lpExe = LockResource(hGlobal); CFile file; if(file.Open(FilePath, CFile::modeCreate | CFile::modeWrite)) file.Write(lpExe, (UINT)SizeofResource(AfxGetResourceHandle(), hrSrc)); file.Close(); ::UnlockResource(hGlobal); ::FreeResource(hGlobal); }// FindClose(hFind);// g_strDatabasefilepath=(CString)FOR_DATABASE_CONNECT+g_strDatabasefilepath;// g_strImgeFolder=g_strExePth+_T("Database\\image\\");// CreateDirectory(g_strImgeFolder,NULL);// JudgeDB(); //CString strocx=g_strExePth+_T("MSFLXGRD.OCX"); /*CStdioFile file; CString versionno; file. file.SetFilePath(_T("http://www.temcocontrols.com/ftp/software/T3000_Version.txt")); file.ReadString(versionno); file.Close();*/ //CFile file; // file.Open(_T("http://www.temcocontrols.com/ftp/software/T3000_Version.txt"),modeRead); InitModeName();// #if 0 CInternetSession session; CInternetFile *file=NULL; try { INTERNET_PROXY_INFO proxyinfo; proxyinfo.dwAccessType=INTERNET_OPEN_TYPE_PROXY; proxyinfo.lpszProxy=_T("192.168.0.4:8080 "); proxyinfo.lpszProxyBypass=NULL; if (!session.SetOption(INTERNET_OPTION_PROXY,(LPVOID)&proxyinfo,sizeof(INTERNET_PROXY_INFO))) { AfxMessageBox(_T("UserName")); } CString username=_T("alex"); if(!session.SetOption(INTERNET_OPTION_PROXY_USERNAME,username.GetBuffer(),username.GetLength()+ 1)){ AfxMessageBox(_T("UserName")); } CString password=_T("travel"); if(!session.SetOption(INTERNET_OPTION_PROXY_PASSWORD,password.GetBuffer(),password.GetLength()+ 1)){ AfxMessageBox(_T("Password")); } file=(CInternetFile*)session.OpenURL(_T("www.temcocontrols.com/ftp/software/T3000_Version.txt")); } catch (CInternetException* e) { file=NULL; e->Delete(); } CString version; if (file) { while(file->ReadString(version)!=NULL){ } AfxMessageBox(version); } #endif #endif // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("Temco T3000 Application"));// LoadStdProfileSettings(); // Load standard INI file options (including MRU)// InitContextMenuManager(); InitKeyboardManager(); InitTooltipManager(); CMFCToolTipInfo ttParams; ttParams.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL, RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams); #if 1 hr=CoInitialize(NULL);// if(FAILED(hr)) // { AfxMessageBox(_T("Error Initialize the COM Interface"));// return FALSE;// } #endif } catch (...) { AfxMessageBox(_T("Database operation to stop!")); } CString registerfilename; registerfilename=g_strExePth+_T("REG_msado15.bat"); // ::ShellExecute(NULL, _T("open"), registerfilename.GetBuffer(), _T(""), _T(""), SW_HIDE); registerfilename=g_strExePth+_T("REG_MSFLXGRD.bat"); //::ShellExecute(NULL, _T("open"), registerfilename.GetBuffer(), _T(""), _T(""), SW_HIDE); CString languagepath=g_strExePth+_T("\\Language"); m_locale.AddCatalogLookupPath(languagepath); m_locale.SetLanguage(CLanguageLocale::LANGUAGE_ENGLISH); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views #ifndef Fance_Enable_Test CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CT3000Doc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CT3000View)); #endif #ifdef Fance_Enable_Test CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CT3000Doc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CDialogCM5_BacNet)); #endif if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); //cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing; //lsc // Dispatch commands specified on the command line. Will return FALSE if // app was launched with /RegServer, /Register, /Unregserver or /Unregister. if (!ProcessShellCommand(cmdInfo)) return FALSE; GdiplusStartupInput gdiplusStartupInput;// GdiplusStartup(&g_gdiplusToken, &gdiplusStartupInput, NULL);// #if 1 //////////////////////////////////////////////////////// _ConnectionPtr m_pCon; _RecordsetPtr m_pRs; m_pCon.CreateInstance(_T("ADODB.Connection")); hr=m_pRs.CreateInstance(_T("ADODB.Recordset")); if(FAILED(hr)) { AfxMessageBox(_T("Load msado12.dll erro")); return FALSE; } m_pCon->Open(g_strDatabasefilepath.GetString(),"","",adModeUnknown); m_pRs->Open(_T("select * from Userlogin"),_variant_t((IDispatch *)m_pCon,true),adOpenStatic,adLockOptimistic,adCmdText); int nRecord=m_pRs->GetRecordCount(); if (nRecord<=0) { g_bPrivilegeMannage=FALSE; } else { int nUse; _variant_t temp_variant; temp_variant=m_pRs->GetCollect("USE_PASSWORD");// if(temp_variant.vt!=VT_NULL) nUse=temp_variant; else nUse=0; if(nUse==-1) { g_bPrivilegeMannage=TRUE; } else { g_bPrivilegeMannage=FALSE; } } m_pRs->Close(); m_pCon->Close(); if (g_bPrivilegeMannage) {//for just quick debug,only on this computer if(!user_login()) { AfxMessageBox(_T("Error password!")); return false; } } #endif ((CMainFrame*)m_pMainWnd)->InitViews();// m_pMainWnd->SetWindowText(_T("T3000 Building Automation System"));// m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); } catch (...) { // AfxMessageBox(_T("Double click 'REG_msado15.dll',Please!\nAt C:\\Program Files\\Temcocontrols\\T3000")); // CString strFilter = _T("hex File;bin File|*.hex;*.bin|all File|*.*||"); // CFileDialog dlg(true,_T("hex"),NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER,strFilter); // dlg.DoModal(); // CFileDialog dlg(true,NULL,_T("C:\Program Files\Common Files\System\ado")); //dlg.lpstrInitialDir = "..\\hisdata"; //dlg.op //// // OPENFILENAME // if (dlg.DoModal()==IDOK) // { // path = dlg.GetPathName(); // pLogFile = fopen("Log.txt", "wt+"); // fprintf(pLogFile, "%s", (LPCSTR)path); // fclose(pLogFile); // pLogFile = NULL; // } // CFileDialog fileDlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, // NULL,NULL);//_T("工作表(*.xls)|*.xls|文本文件(*.txt)|*.txt||") // fileDlg.m_ofn.lpstrInitialDir = _T("C:\\Program Files\\Temcocontrols\\T3000\\REG_msado15.dll.bat"); // fileDlg.DoModal(); //::ShellExecute(NULL, _T("open"), _T("C:\\Program Files\\Temcocontrols\\T3000\\REG_msado15.dll.bat"), _T(""), _T(""), SW_SHOW); //vcredist_x86.zip // ::ShellExecute(NULL, _T("open"), _T("C:\\Program Files\\Temcocontrols\\T3000\\vcredist_x86.zip"), _T(""), _T(""), SW_SHOW); //这个要先试试,当电脑没有安装这个文件时,如何捕获这个信息,然后再执行这个。 AfxMessageBox(_T("Open'T3000'Again,Please!")); return TRUE; } return TRUE; }
INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES); switch (message) { case WM_INITDIALOG: hwndDialog = hDlg; TranslateDialogDefault( hDlg ); oldWndProc = (WNDPROC)SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)PluginListWndProc); SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon("plg_list", 1)); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon("plg_list")); { HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); ImageList_AddIconFromIconLib(hIml, "info"); ListView_SetImageList(hwndList, hIml, LVSIL_SMALL); OSVERSIONINFO osver = { sizeof(osver) }; if (GetVersionEx(&osver) && osver.dwMajorVersion >= 6) { wchar_t szPath[MAX_PATH]; GetModuleFileName(NULL, szPath, SIZEOF(szPath)); TCHAR *ext = _tcsrchr(szPath, '.'); if (ext != NULL) *ext = '\0'; _tcscat(szPath, _T(".test")); HANDLE hFile = CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) // Running Windows Vista or later (major version >= 6). Button_SetElevationRequiredState(GetDlgItem(hDlg, IDOK), !IsProcessElevated()); else { CloseHandle(hFile); DeleteFile(szPath); } } RECT r; GetClientRect(hwndList, &r); /// LVCOLUMN lvc = {0}; lvc.mask = LVCF_WIDTH | LVCF_TEXT; //lvc.fmt = LVCFMT_LEFT; lvc.pszText = TranslateT("Component Name"); lvc.cx = 220; // width of column in pixels ListView_InsertColumn(hwndList, 0, &lvc); lvc.pszText = L""; lvc.cx = 32 - GetSystemMetrics(SM_CXVSCROLL); // width of column in pixels ListView_InsertColumn(hwndList, 1, &lvc); lvc.pszText = TranslateT("State"); lvc.cx = 100 - GetSystemMetrics(SM_CXVSCROLL); // width of column in pixels ListView_InsertColumn(hwndList, 2, &lvc); /// LVGROUP lvg; lvg.cbSize = sizeof(LVGROUP); lvg.mask = LVGF_HEADER | LVGF_GROUPID; lvg.pszHeader = TranslateT("Plugins"); lvg.iGroupId = 1; ListView_InsertGroup(hwndList, 0, &lvg); lvg.pszHeader = TranslateT("Icons"); lvg.iGroupId = 2; ListView_InsertGroup(hwndList, 0, &lvg); lvg.pszHeader = TranslateT("Other"); lvg.iGroupId = 3; ListView_InsertGroup(hwndList, 0, &lvg); ListView_EnableGroupView(hwndList, TRUE); /// SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP); ListView_DeleteAllItems(hwndList); /// OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)lParam; for (int i = 0; i < todo.getCount(); ++i) { int groupId = 3; LVITEM lvi = {0}; lvi.mask = LVIF_PARAM | LVIF_GROUPID | LVIF_TEXT | LVIF_IMAGE; if (_tcschr(todo[i].tszOldName, L'\\') != NULL) groupId = _tcsstr(todo[i].tszOldName, L"Plugins") != NULL ? 1 : 2; lvi.iItem = i; lvi.lParam = (LPARAM)&todo[i]; lvi.iGroupId = groupId; lvi.iImage = -1; lvi.pszText = todo[i].tszOldName; int iRow = ListView_InsertItem(hwndList, &lvi); if (iRow != -1) { lvi.iItem = iRow; if (groupId == 1) { lvi.mask = LVIF_IMAGE; lvi.iSubItem = 1; lvi.iImage = 0; ListView_SetItem(hwndList, &lvi); } } todo[i].bEnabled = false; } HWND hwOk = GetDlgItem(hDlg, IDOK); EnableWindow(hwOk, false); } // do this after filling list - enables 'ITEMCHANGED' below SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam); Utils_RestoreWindowPosition(hDlg, 0, MODNAME, "ListWindow"); return TRUE; case WM_NOTIFY: if (((LPNMHDR) lParam)->hwndFrom == hwndList) { switch (((LPNMHDR) lParam)->code) { case LVN_ITEMCHANGED: if (GetWindowLongPtr(hDlg, GWLP_USERDATA)) { NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; LVITEM lvI = {0}; lvI.iItem = nmlv->iItem; lvI.iSubItem = 0; lvI.mask = LVIF_PARAM; ListView_GetItem(hwndList, &lvI); OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA); if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) { todo[lvI.iItem].bEnabled = ListView_GetCheckState(hwndList, nmlv->iItem); bool enableOk = false; for (int i=0; i < todo.getCount(); ++i) { if (todo[i].bEnabled) { enableOk = true; break; } } HWND hwOk = GetDlgItem(hDlg, IDOK); EnableWindow(hwOk, enableOk ? TRUE : FALSE); } } break; } } break; case WM_COMMAND: if (HIWORD( wParam ) == BN_CLICKED) { switch(LOWORD(wParam)) { case IDOK: EnableWindow( GetDlgItem(hDlg, IDOK), FALSE); EnableWindow( GetDlgItem(hDlg, IDC_SELNONE), FALSE); mir_forkthread(ApplyDownloads, hDlg); return TRUE; case IDC_SELNONE: SelectAll(hDlg, false); break; case IDCANCEL: DestroyWindow(hDlg); return TRUE; } } break; case WM_SIZE: // make the dlg resizeable if (!IsIconic(hDlg)) { UTILRESIZEDIALOG urd = { sizeof(urd) }; urd.hInstance = hInst; urd.hwndDlg = hDlg; urd.lpTemplate = MAKEINTRESOURCEA(IDD_LIST); urd.pfnResizer = ListDlg_Resize; CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); } break; case WM_GETMINMAXINFO: { LPMINMAXINFO mmi = (LPMINMAXINFO)lParam; // The minimum width in points mmi->ptMinTrackSize.x = 370; // The minimum height in points mmi->ptMinTrackSize.y = 300; } break; case WM_DESTROY: Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ListWindow"); Skin_ReleaseIcon((HICON)SendMessage(hDlg, WM_SETICON, ICON_BIG, 0)); Skin_ReleaseIcon((HICON)SendMessage(hDlg, WM_SETICON, ICON_SMALL, 0)); hwndDialog = NULL; delete (OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA); SetWindowLongPtr(hDlg, GWLP_USERDATA, 0); break; } return FALSE; }
static INT_PTR CALLBACK DlgProfileNew(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { struct DlgProfData *dat = (struct DlgProfData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); dat = (struct DlgProfData *)lParam; { HWND hwndCombo = GetDlgItem(hwndDlg, IDC_PROFILEDRIVERS); // what, no plugins?! if (arDbPlugins.getCount() == 0) { EnableWindow(hwndCombo, FALSE); EnableWindow(GetDlgItem(hwndDlg, IDC_PROFILENAME), FALSE); ShowWindow(GetDlgItem(hwndDlg, IDC_NODBDRIVERS), TRUE); } else { for (int i = 0; i < arDbPlugins.getCount(); i++) { DATABASELINK *p = arDbPlugins[i]; LRESULT index = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM)TranslateTS(p->szFullName)); SendMessage(hwndCombo, CB_SETITEMDATA, index, (LPARAM)p); } } // default item SendMessage(hwndCombo, CB_SETCURSEL, 0, 0); // subclass the profile name box mir_subclassWindow(GetDlgItem(hwndDlg, IDC_PROFILENAME), ProfileNameValidate); } // decide if there is a default profile name given in the INI and if it should be used if (dat->pd->noProfiles || (shouldAutoCreate(dat->pd->szProfile) && _taccess(dat->pd->szProfile, 0))) { TCHAR *profile = _tcsrchr(dat->pd->szProfile, '\\'); if (profile) ++profile; else profile = dat->pd->szProfile; TCHAR *p = _tcsrchr(profile, '.'); TCHAR c = 0; if (p) { c = *p; *p = 0; } SetDlgItemText(hwndDlg, IDC_PROFILENAME, profile); if (c) *p = c; } // focus on the textbox PostMessage(hwndDlg, WM_FOCUSTEXTBOX, 0, 0); return TRUE; case WM_FOCUSTEXTBOX: SetFocus(GetDlgItem(hwndDlg, IDC_PROFILENAME)); break; case WM_INPUTCHANGED: // when input in the edit box changes SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); EnableWindow(dat->hwndOK, GetWindowTextLength(GetDlgItem(hwndDlg, IDC_PROFILENAME)) > 0); break; case WM_SHOWWINDOW: if (wParam) { EnableWindow(dat->hwndSM, FALSE); SetWindowText(dat->hwndOK, TranslateT("&Create")); SendMessage(hwndDlg, WM_INPUTCHANGED, 0, 0); } break; case WM_NOTIFY: NMHDR *hdr = (NMHDR*)lParam; if (hdr && hdr->code == PSN_APPLY && dat && IsWindowVisible(hwndDlg)) { TCHAR szName[MAX_PATH]; LRESULT curSel = SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETCURSEL, 0, 0); if (curSel == CB_ERR) break; // should never happen GetDlgItemText(hwndDlg, IDC_PROFILENAME, szName, SIZEOF(szName)); if (szName[0] == 0) break; // profile placed in "profile_name" subfolder mir_sntprintf(dat->pd->szProfile, MAX_PATH, _T("%s\\%s\\%s.dat"), dat->pd->szProfileDir, szName, szName); dat->pd->newProfile = 1; dat->pd->dblink = (DATABASELINK *)SendDlgItemMessage(hwndDlg, IDC_PROFILEDRIVERS, CB_GETITEMDATA, (WPARAM)curSel, 0); if (CreateProfile(dat->pd->szProfile, dat->pd->dblink, hwndDlg) == 0) SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE); } break; } return FALSE; }
bool extractCurrentFile(unzFile uf, TCHAR *path) { int err = UNZ_OK; unz_file_info64 file_info; char filename[MAX_PATH]; char buf[8192]; err = unzGetCurrentFileInfo64(uf, &file_info, filename, sizeof(filename), buf, sizeof(buf), NULL, 0); if (err != UNZ_OK) return false; // Get Unicode file name for InfoZip style archives, otherwise assume PKZip/WinZip style if (file_info.size_file_extra) { char *p = buf; unsigned long size = min(file_info.size_file_extra, sizeof(buf)); while (size > 0) { unsigned short id = *(unsigned short*)p; unsigned len = *(unsigned short*)(p + 2); if (size < (len + 4)) break; if (id == 0x7075 && len > 5 && (len - 5) < sizeof(filename) && *(p + 4) == 1) { memcpy(filename, p + 9, len - 5); filename[len - 5] = 0; break; } size -= len + 4; p += len + 4; } } TCHAR save_file[MAX_PATH]; TCHAR* p = mir_utf8decodeT(filename); if (p == NULL) p = mir_a2t(filename); mir_sntprintf(save_file, SIZEOF(save_file), _T("%s\\%s"), path, p); mir_free(p); for (p = save_file; *p; ++p) if (*p == '/') *p = '\\'; if (file_info.external_fa & FILE_ATTRIBUTE_DIRECTORY) CreatePath(save_file); else { err = unzOpenCurrentFile(uf); if (err != UNZ_OK) return false; p = _tcsrchr(save_file, '\\'); if (p) *p = 0; CreatePath(save_file); if (p) *p = '\\'; HANDLE hFile = CreateFile(save_file, GENERIC_WRITE, FILE_SHARE_WRITE, 0, CREATE_ALWAYS, file_info.external_fa, 0); if (hFile != INVALID_HANDLE_VALUE) { for (;;) { err = unzReadCurrentFile(uf, buf, sizeof(buf)); if (err <= 0) break; DWORD bytes; if (!WriteFile(hFile, buf, err, &bytes, FALSE)) { err = UNZ_ERRNO; break; } } FILETIME ftLocal, ftCreate, ftLastAcc, ftLastWrite; GetFileTime(hFile, &ftCreate, &ftLastAcc, &ftLastWrite); DosDateTimeToFileTime(HIWORD(file_info.dosDate), LOWORD(file_info.dosDate), &ftLocal); LocalFileTimeToFileTime(&ftLocal, &ftLastWrite); SetFileTime(hFile, &ftCreate, &ftLastAcc, &ftLastWrite); CloseHandle(hFile); unzCloseCurrentFile(uf); /* don't lose the error */ } } return true; }
int LoadNewPluginsModule(void) { TCHAR exe[MAX_PATH]; TCHAR* slice; pluginEntry* p; pluginEntry* clist = NULL; int useWhiteList, i; bool msgModule = false; // make full path to the plugin GetModuleFileName(NULL, exe, SIZEOF(exe)); slice = _tcsrchr(exe, '\\'); if (slice) *slice = 0; // remember some useful options askAboutIgnoredPlugins=(UINT) GetPrivateProfileInt( _T("PluginLoader"), _T("AskAboutIgnoredPlugins"), 0, mirandabootini); // if Crash Dumper is present, load it to provide Crash Reports if (pluginList_crshdmp != NULL && isPluginOnWhiteList(pluginList_crshdmp->pluginname)) { if ( pluginList_crshdmp->bpi.Load(&pluginCoreLink) == 0 ) pluginList_crshdmp->pclass |= PCLASS_LOADED | PCLASS_LAST; else Plugin_Uninit( pluginList_crshdmp ); } // if freeimage is present, load it to provide the basic core functions if ( pluginList_freeimg != NULL ) { BASIC_PLUGIN_INFO bpi; mir_sntprintf(slice, &exe[SIZEOF(exe)] - slice, _T("\\Plugins\\%s"), pluginList_freeimg->pluginname); if ( checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_NONE, NULL) ) { pluginList_freeimg->bpi = bpi; pluginList_freeimg->pclass |= PCLASS_OK | PCLASS_BASICAPI; if ( bpi.Load(&pluginCoreLink) == 0 ) pluginList_freeimg->pclass |= PCLASS_LOADED; else Plugin_Uninit( pluginList_freeimg ); } } // first load the clist cos alot of plugins need that to be present at Load() for ( useWhiteList = 1; useWhiteList >= 0 && clist == NULL; useWhiteList-- ) clist=getCListModule(exe, slice, useWhiteList); /* the loop above will try and get one clist DLL to work, if all fail then just bail now */ if ( clist == NULL ) { // result = 0, no clist_* can be found if ( pluginListUI ) MessageBox(NULL, TranslateT("Unable to start any of the installed contact list plugins, I even ignored your preferences for which contact list couldn't load any."), _T("Miranda IM"), MB_OK | MB_ICONINFORMATION); else MessageBox(NULL, TranslateT("Can't find a contact list plugin! you need clist_classic or any other clist plugin.") , _T("Miranda IM"), MB_OK | MB_ICONINFORMATION); return 1; } /* enable and disable as needed */ p = pluginListUI; while ( p != NULL ) { SetPluginOnWhiteList(p->pluginname, clist != p ? 0 : 1 ); p = p->nextclass; } /* now loop thru and load all the other plugins, do this in one pass */ for ( i=0; i < pluginList.getCount(); i++ ) { p = pluginList[i]; CharLower(p->pluginname); if (!(p->pclass & (PCLASS_LOADED | PCLASS_DB | PCLASS_CLIST))) { if (isPluginOnWhiteList(p->pluginname)) { BASIC_PLUGIN_INFO bpi; mir_sntprintf(slice, &exe[SIZEOF(exe)] - slice, _T("\\Plugins\\%s"), p->pluginname); if ( checkAPI(exe, &bpi, mirandaVersion, CHECKAPI_NONE, NULL) ) { int rm = bpi.pluginInfo->replacesDefaultModule; p->bpi = bpi; p->pclass |= PCLASS_OK | PCLASS_BASICAPI; if ( pluginDefModList[rm] == NULL ) { pluginListAddr.insert( p ); if ( bpi.Load(&pluginCoreLink) == 0 ) { p->pclass |= PCLASS_LOADED; msgModule |= (bpi.pluginInfo->replacesDefaultModule == DEFMOD_SRMESSAGE); } else { Plugin_Uninit( p ); i--; } if ( rm ) pluginDefModList[rm]=p; } //if else { SetPluginOnWhiteList( p->pluginname, 0 ); Plugin_Uninit( p ); i--; } } else p->pclass |= PCLASS_FAILED; } else { Plugin_Uninit( p ); i--; } } else if ( p->bpi.hInst != NULL ) { pluginListAddr.insert( p ); p->pclass |= PCLASS_LOADED; } } if (!msgModule) MessageBox(NULL, TranslateT("No messaging plugins loaded. Please install/enable one of the messaging plugins, for instance, \"srmm.dll\""), _T("Miranda IM"), MB_OK | MB_ICONINFORMATION); HookEvent(ME_OPT_INITIALISE, PluginOptionsInit); return 0; }
void CShellExt::GetColumnStatus(const TCHAR * path, BOOL bIsDir) { PreserveChdir preserveChdir; if (_tcscmp(path, columnfilepath.c_str())==0) return; LoadLangDll(); columnfilepath = path; const FileStatusCacheEntry * status = NULL; TGITCacheResponse itemStatus; ShellCache::CacheType t = ShellCache::exe; AutoLocker lock(g_csGlobalCOMGuard); t = g_ShellCache.GetCacheType(); switch (t) { case ShellCache::exe: { SecureZeroMemory(&itemStatus, sizeof(itemStatus)); if(m_remoteCacheLink.GetStatusFromRemoteCache(CTGitPath(path), &itemStatus, true)) { filestatus = GitStatus::GetMoreImportant(itemStatus.m_status.text_status, itemStatus.m_status.prop_status); } else { filestatus = git_wc_status_none; columnauthor.clear(); columnrev = GIT_INVALID_REVNUM; itemurl.clear(); itemshorturl.clear(); owner.clear(); return; } } break; case ShellCache::dll: case ShellCache::dllFull: { status = m_CachedStatus.GetFullStatus(CTGitPath(path), bIsDir, TRUE); filestatus = status->status; } break; default: case ShellCache::none: { if (g_ShellCache.HasGITAdminDir(path, bIsDir)) filestatus = git_wc_status_normal; else filestatus = git_wc_status_none; columnauthor.clear(); columnrev = GIT_INVALID_REVNUM; itemurl.clear(); itemshorturl.clear(); owner.clear(); return; } break; } if (t == ShellCache::exe) { columnauthor = UTF8ToWide(itemStatus.m_author); columnrev = itemStatus.m_entry.cmt_rev; itemurl = UTF8ToWide(itemStatus.m_url); owner = UTF8ToWide(itemStatus.m_owner); } else { if (status) { columnauthor = UTF8ToWide(status->author); columnrev = status->rev; itemurl = UTF8ToWide(status->url); owner = UTF8ToWide(status->owner); } } #if 0 TCHAR urlpath[INTERNET_MAX_URL_LENGTH+1]; URL_COMPONENTS urlComponents; memset(&urlComponents, 0, sizeof(URL_COMPONENTS)); urlComponents.dwStructSize = sizeof(URL_COMPONENTS); urlComponents.dwUrlPathLength = INTERNET_MAX_URL_LENGTH; urlComponents.lpszUrlPath = urlpath; if (InternetCrackUrl(itemurl.c_str(), 0, ICU_DECODE, &urlComponents)) { // since the short url is shown as an additional column where the // file/foldername is shown too, we strip that name from the url // to make the url even shorter. TCHAR * ptr = _tcsrchr(urlComponents.lpszUrlPath, '/'); if (ptr == NULL) ptr = _tcsrchr(urlComponents.lpszUrlPath, '\\'); if (ptr) { *ptr = '\0'; // to shorten the url even more, we check for 'trunk', 'branches' and 'tags' // and simply assume that these are the folders attached to the repository // root. If we find those, we strip the whole path before those folders too. // Note: this will strip too much if such a folder is *below* the repository // root - but it's called 'short url' and we're free to shorten it the way we // like :) /*ptr = _tcsstr(urlComponents.lpszUrlPath, _T("/trunk")); if (ptr == NULL) ptr = _tcsstr(urlComponents.lpszUrlPath, _T("\\trunk")); if ((ptr == NULL)||((*(ptr+6) != 0)&&(*(ptr+6) != '/')&&(*(ptr+6) != '\\'))) { ptr = _tcsstr(urlComponents.lpszUrlPath, _T("/branches")); if (ptr == NULL) ptr = _tcsstr(urlComponents.lpszUrlPath, _T("\\branches")); if ((ptr == NULL)||((*(ptr+9) != 0)&&(*(ptr+9) != '/')&&(*(ptr+9) != '\\'))) { ptr = _tcsstr(urlComponents.lpszUrlPath, _T("/tags")); if (ptr == NULL) ptr = _tcsstr(urlComponents.lpszUrlPath, _T("\\tags")); if ((ptr)&&(*(ptr+5) != 0)&&(*(ptr+5) != '/')&&(*(ptr+5) != '\\')) ptr = NULL; } } if (ptr) itemshorturl = ptr; else*/ itemshorturl = urlComponents.lpszUrlPath; } else itemshorturl = _T(" "); } else itemshorturl = _T(" "); if (status) { char url[INTERNET_MAX_URL_LENGTH]; strcpy_s(url, INTERNET_MAX_URL_LENGTH, status->url); CPathUtils::Unescape(url); itemurl = UTF8ToWide(url); } else if (t == ShellCache::exe) { char url[INTERNET_MAX_URL_LENGTH]; strcpy_s(url, INTERNET_MAX_URL_LENGTH, itemStatus.m_url); CPathUtils::Unescape(url); itemurl = UTF8ToWide(url); } #endif }
static int InternalSetMyAvatar(char *protocol, TCHAR *szFinalName, SetMyAvatarHookData &data, BOOL allAcceptXML, BOOL allAcceptSWF) { int format = ProtoGetAvatarFormat(szFinalName); if (format == PA_FORMAT_UNKNOWN || _taccess(szFinalName, 4) == -1) return -3; // file exists... HBITMAP hBmp = NULL; if (format == PA_FORMAT_SWF) { if (!allAcceptSWF) return -4; } else if (format == PA_FORMAT_XML) { if (!allAcceptXML) return -4; } else { // Try to open if is not a flash or XML hBmp = (HBITMAP)CallService(MS_IMG_LOAD, (WPARAM)szFinalName, IMGL_TCHAR); if (hBmp == NULL) return -4; } SetIgnoreNotify(protocol, TRUE); int ret = 0; if (protocol != NULL) { ret = SetProtoMyAvatar(protocol, hBmp, szFinalName, format, data.square, data.grow); if (ret == 0) { DeleteGlobalUserAvatar(); db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); } } else { int count; PROTOACCOUNT **accs; Proto_EnumAccounts(&count, &accs); for (int i = 0; i < count; i++) { if (!ProtoServiceExists(accs[i]->szModuleName, PS_SETMYAVATAR)) continue; if (!Proto_IsAvatarsEnabled(accs[i]->szModuleName)) continue; int retTmp = SetProtoMyAvatar(accs[i]->szModuleName, hBmp, szFinalName, format, data.square, data.grow); if (retTmp != 0) ret = retTmp; } DeleteGlobalUserAvatar(); if (ret) db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); else { // Copy avatar file to store as global one TCHAR globalFile[1024]; BOOL saved = TRUE; if (FoldersGetCustomPathT(hGlobalAvatarFolder, globalFile, _countof(globalFile), _T(""))) { mir_sntprintf(globalFile, _T("%s%s"), g_szDataPath, _T("GlobalAvatar")); CreateDirectory(globalFile, NULL); } TCHAR *ext = _tcsrchr(szFinalName, _T('.')); // Can't be NULL here if (format == PA_FORMAT_XML || format == PA_FORMAT_SWF) { mir_sntprintf(globalFile, _T("%s\\my_global_avatar%s"), globalFile, ext); CopyFile(szFinalName, globalFile, FALSE); } else { // Resize (to avoid too big avatars) ResizeBitmap rb = { 0 }; rb.size = sizeof(ResizeBitmap); rb.hBmp = hBmp; rb.max_height = 300; rb.max_width = 300; rb.fit = (data.grow ? 0 : RESIZEBITMAP_FLAG_DONT_GROW) | (data.square ? RESIZEBITMAP_MAKE_SQUARE : RESIZEBITMAP_KEEP_PROPORTIONS); HBITMAP hBmpTmp = (HBITMAP)CallService(MS_IMG_RESIZE, WPARAM(&rb), 0); // Check if need to resize if (hBmpTmp == hBmp || hBmpTmp == NULL) { // Use original image mir_sntprintf(globalFile, _T("%s\\my_global_avatar%s"), globalFile, ext); CopyFile(szFinalName, globalFile, FALSE); } else { // Save as PNG mir_sntprintf(globalFile, _T("%s\\my_global_avatar.png"), globalFile); if (BmpFilterSaveBitmap(hBmpTmp, globalFile, 0)) saved = FALSE; DeleteObject(hBmpTmp); } } if (saved) { TCHAR relFile[1024]; if (PathToRelativeT(globalFile, relFile, g_szDataPath)) db_set_ts(NULL, AVS_MODULE, "GlobalUserAvatarFile", relFile); else db_set_ts(NULL, AVS_MODULE, "GlobalUserAvatarFile", globalFile); db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 0); } else db_set_b(NULL, AVS_MODULE, "GlobalUserAvatarNotConsistent", 1); } } DeleteObject(hBmp); SetIgnoreNotify(protocol, FALSE); ReportMyAvatarChanged(WPARAM((protocol == NULL) ? "" : protocol), 0); return ret; }
//----------------------------------------------------------------------------- // Name: StartDriver // Object: Install and start KernelMemoryAccess driver // Parameters : // in : // out : // return : TRUE on success, FALSE on error or if driver is already running //----------------------------------------------------------------------------- BOOL CKernelMemoryAccessInterface::StartDriver() { BOOL bAlreadyLoaded=FALSE; BOOL bAlreadyInstalled=FALSE; /* BOOL bForceContinue=FALSE; DWORD dwCurrentState=0; */ CDriver Driver; TCHAR szDir[MAX_PATH]; TCHAR* pos; // Get current application directory GetModuleFileName(GetModuleHandle(NULL),szDir,MAX_PATH); pos=_tcsrchr(szDir,'\\'); if (pos) *(pos+1)=0; // put full path of KernelMemoryAccess.sys in szDir _tcscat(szDir,KERNEL_MEMORY_ACCESS_SYS); // install the driver querying if it is already installed if (!Driver.Install(szDir,SERVICE_DEMAND_START,&bAlreadyInstalled)) return FALSE; // open the driver if (!Driver.Open(KERNEL_MEMORY_ACCESS_NAME)) return FALSE; /* // driver state checking : useless as multiple app can access it simultaneously // if driver is already installed, 2 things may append // - another soft is using it // - driver hasn't been uninstalled for unknown reason (software/computer crash, bad programming ...) if (bAlreadyInstalled) { // query the state of driver if (!Driver.GetState(&dwCurrentState)) return FALSE; // check if another application is using it if ((dwCurrentState!=SERVICE_STOPPED)&&(dwCurrentState!=SERVICE_STOP_PENDING)) { #if (!defined(TOOLS_NO_MESSAGEBOX)) if (MessageBox(NULL,MSG_DRIVER_ALREADY_RUNNING,_T("Warning"),MB_YESNO|MB_ICONWARNING|MB_TOPMOST)==IDYES) bForceContinue=TRUE; else #endif return FALSE; } } */ // try to start the driver (still check if another app is using it) if (!Driver.Start(&bAlreadyLoaded)) return FALSE; /* // driver state checking : useless as multiple app can access it simultaneously // if used by another application if (bAlreadyLoaded&&(!bForceContinue)) { #if (!defined(TOOLS_NO_MESSAGEBOX)) if (MessageBox(NULL,MSG_DRIVER_ALREADY_RUNNING,_T("Warning"),MB_YESNO|MB_ICONWARNING|MB_TOPMOST)!=IDYES) #endif return FALSE; } */ this->bStarted=TRUE; return TRUE; }
void Canvas::DrawFormattedText(PixelRect *rc, const TCHAR *text, unsigned format) { assert(text != NULL); #ifndef UNICODE assert(ValidateUTF8(text)); #endif if (font == NULL) return; UPixelScalar skip = font->GetLineSpacing(); unsigned max_lines = (format & DT_CALCRECT) ? -1 : (rc->bottom - rc->top + skip - 1) / skip; size_t len = _tcslen(text); TCHAR *duplicated = new TCHAR[len + 1], *p = duplicated; unsigned lines = 1; for (const TCHAR *i = text; *i != _T('\0'); ++i) { TCHAR ch = *i; if (ch == _T('\n')) { /* explicit line break */ if (++lines >= max_lines) break; ch = _T('\0'); } else if (ch == _T('\r')) /* skip */ continue; else if ((unsigned)ch < 0x20) /* replace non-printable characters */ ch = _T(' '); *p++ = ch; } *p = _T('\0'); len = p - duplicated; // simple wordbreak algorithm. looks for single spaces only, no tabs, // no grouping of multiple spaces if (format & DT_WORDBREAK) { for (size_t i = 0; i < len; i += _tcslen(duplicated + i) + 1) { PixelSize sz = CalcTextSize(duplicated + i); TCHAR *prev_p = NULL; // remove words from behind till line fits or no more space is found while (sz.cx > rc->right - rc->left && (p = _tcsrchr(duplicated + i, _T(' '))) != NULL) { if (prev_p) *prev_p = _T(' '); *p = _T('\0'); prev_p = p; sz = CalcTextSize(duplicated + i); } if (prev_p) { lines++; if (lines >= max_lines) break; } } } if (format & DT_CALCRECT) { rc->bottom = rc->top + lines * skip; delete[] duplicated; return; } PixelScalar y = (format & DT_VCENTER) && lines < max_lines ? (PixelScalar)(rc->top + rc->bottom - lines * skip) / 2 : rc->top; for (size_t i = 0; i < len; i += _tcslen(duplicated + i) + 1) { if (duplicated[i] != _T('\0')) { PixelScalar x; if (format & (DT_RIGHT | DT_CENTER)) { PixelSize sz = CalcTextSize(duplicated + i); x = (format & DT_CENTER) ? (rc->left + rc->right - sz.cx)/2 : rc->right - sz.cx; // DT_RIGHT } else { // default is DT_LEFT x = rc->left; } TextAutoClipped(x, y, duplicated + i); } y += skip; if (y >= rc->bottom) break; } delete[] duplicated; }
extern "C" bool ParseCommandLine( CGT_CDiagMsg* pdm, ICG_IECFront* pIFront, CMDL_OPTIONSTYP* pOpts, int argc, TCHAR** argv ) { int i; int is; const TCHAR* psz; const TCHAR* psz2; CG_Edipos cmdl; const TCHAR* pszTrgExts; LIB_ACTION libAct; //init cmdl to show error location 'command line' CG_InitCMDLEdipos(&cmdl); //get the list of target exts: pszTrgExts = pIFront->KADgetTargetTypeExts(); assert(pszTrgExts); for(i=0;i<argc;i++) { psz = argv[i]; if(*psz==_T('/') || *psz==_T('-')) { psz++; libAct = LIB_ACT_UNDEF; if(!_tcsicmp(psz, _T("c"))) { if(++i>=argc) pdm->msg1(CG_E_CMDL_NEEDPARAM, &cmdl, psz); else if(!pOpts->szCheckFile.isEmpty()) pdm->msg2(CG_W_CMDL_OPT_TWICE, &cmdl, _T("-"), psz); else pOpts->szCheckFile.load(argv[i]); } else if((is = FC_StringStartsWithI(psz, _T("c:"))) >0) { if(i+1>=argc) { pdm->msg1(CG_E_CMDL_NEEDPARAM, &cmdl, _T("c")); } else if(!pOpts->szCheckFile.isEmpty()) { pdm->msg2(CG_W_CMDL_OPT_TWICE, &cmdl, _T("-"), _T("c")); } else { if(psz[is]) { //check syntax of command line: old: -c:4cwin or new: -c:win1:21050 const TCHAR* pszTrgType = &psz[is]; const TCHAR* pszTrgVers = _tcsrchr(pszTrgType, ':'); FC_CStr szTrgType; if(pszTrgVers) { szTrgType.loadLen(pszTrgType, pszTrgVers - pszTrgType); pszTrgVers++; //skip the ':' } else { szTrgType.load(pszTrgType); } if(pIFront->KADgetTargetTypeByExt(szTrgType, NULL, NULL, NULL)) { pOpts->szCheckTrgType.load(szTrgType); if(pszTrgVers) pOpts->szCheckTrgVers.load(pszTrgVers); } else { pdm->msg2(CG_E_NO_TARGETTYPE_EXT, &cmdl, psz, pszTrgExts); } } i++; pOpts->szCheckFile.load(argv[i]); } } else if( (is = FC_StringStartsWithI(psz, _T("ml"))) >0) { libAct = LIB_MAKE; if(psz[is]==_T(':')) pOpts->szLibTargetType.load(&psz[is+1]); else if(psz[is] != 0) pdm->msg1(CG_E_CMDL_OPT_NEEDS_TARGET, &cmdl, psz); if(pOpts->szLibTargetType.isEmpty()) { ;//checked later: either only one target type inKAD or libtyp=<trg typ> in [compiler] section } else if(!_tcsicmp(pOpts->szLibTargetType, _T("0"))) { //special case: only stub libAct = LIB_MAKE_STUB; } else if(!pIFront->KADgetTargetTypeByExt(pOpts->szLibTargetType, NULL, NULL, NULL)) { pdm->msg2(CG_E_NO_TARGETTYPE_EXT, &cmdl, psz, pszTrgExts); } //get the lib name below... } else if(!_tcsicmp(psz, _T("al"))) { libAct = LIB_APPEND; } else if(!_tcsicmp(psz, _T("ll"))) { libAct = LIB_LIST; } else if(!_tcsicmp(psz, _T("lll"))) { libAct = LIB_LISTLONG; } else if(!_tcsicmp(psz, _T("el"))) { libAct = LIB_EXTRACT; } else if( (is = FC_StringStartsWithI(psz, _T("rl"))) >0) { libAct = LIB_REMOVE; if(psz[is]==_T(':')) { pOpts->szLibTargetType.load(&psz[is+1]); if(!pIFront->KADgetTargetTypeByExt(pOpts->szLibTargetType, NULL, NULL, NULL)) pdm->msg2(CG_E_NO_TARGETTYPE_EXT, &cmdl, psz, pszTrgExts); } else { pdm->msg1(CG_E_CMDL_OPT_NEEDS_TARGET, &cmdl, psz); } } else if(!_tcsicmp(psz, _T("i"))) { if(pOpts->bIncrementelly) pdm->msg2(CG_W_CMDL_OPT_TWICE, &cmdl, _T("-"), psz); else pOpts->bIncrementelly = true; } else if(!_tcsicmp(psz, _T("r"))) { if(pOpts->bRecursive) pdm->msg2(CG_W_CMDL_OPT_TWICE, &cmdl, _T("-"), psz); else pOpts->bRecursive = true; } else if(!_tcsicmp(psz, _T("nologo"))) { ;//nologo already handeled, -? must not pass here any more ... } else { pdm->msg1(CG_E_CMDL_UNKNOWN_OPT, &cmdl, --psz); } if(libAct != LIB_ACT_UNDEF) { //check opt twice or conflict with other lib action: if(pOpts->libAct == libAct) { pdm->msg2(CG_W_CMDL_OPT_TWICE, &cmdl, _T("-"), LIBOptName(libAct)); } else if(pOpts->libAct != LIB_ACT_UNDEF) { pdm->msg2(CG_E_CMDL_OPT_CONFLICT, &cmdl, psz, LIBOptName(pOpts->libAct)); } pOpts->libAct = libAct; if(++i>=argc) { pdm->msg1(CG_E_CMDL_NEEDPARAM, &cmdl, LIBOptName(libAct)); } else { pOpts->szMakeLib.load(argv[i]); if(_tcsicmp(FC_StringGetFileExt(argv[i]), CG_PREDEF_LIB_EXT)) pdm->msg3(CG_E_BAD_CMDL_FILETYPE, &cmdl, psz, argv[i], CG_PREDEF_LIB_EXT); } //-al <source>.4cl <dest>.4cl if(libAct == LIB_APPEND) { if(++i>=argc) { pdm->msg1(CG_E_CMDL_NEEDPARAM, &cmdl, _T("al")); } else { pOpts->szSourceLib.load(pOpts->szMakeLib); pOpts->szMakeLib.load(argv[i]); if(_tcsicmp(FC_StringGetFileExt(argv[i]), CG_PREDEF_LIB_EXT)) pdm->msg3(CG_E_BAD_CMDL_FILETYPE, &cmdl, psz, argv[i], CG_PREDEF_LIB_EXT); } } } } else { //pure file argument, must be either 4CP or //build target by name: psz2 = FC_StringGetFileExt(psz); if(!_tcsicmp(psz2, CG_4CP_EXTENSION)) { if(pOpts->sz4CP[0]) { pdm->msg2(CG_W_CMDL_OPT_TWICE, &cmdl, _T("."), psz2); } else { pOpts->sz4CP.load(psz); TCHAR buffer[2*MAX_PATH]; FC_FileFullPath(NULL, psz, buffer, FC_ARRAY_LEN(buffer)); FC_StringCutFilePart(buffer); pOpts->sz4CPFullPath.load(buffer); } } else if(pOpts->targets.findI(psz)) { pdm->msg2(CG_W_CMDL_OPT_TWICE, &cmdl, _T(""), psz); } else { pOpts->targets.add(psz); } } } //check option combinations got end after first error //in order to produce only one error (the user is frustrated anyway...): if(pdm->hasErr()) goto Ende; if(pOpts->sz4CP.isEmpty()) { if(pOpts->libAct==LIB_ACT_UNDEF || pOpts->libAct==LIB_MAKE || pOpts->libAct==LIB_MAKE_STUB) { pdm->msg0(CG_E_CMDL_NO4CP, &cmdl); goto Ende; } } else if(pOpts->libAct!=LIB_ACT_UNDEF && pOpts->libAct!=LIB_MAKE && pOpts->libAct!=LIB_MAKE_STUB) { pdm->msg2(CG_E_CMDL_OPT_CONFLICT, &cmdl, pOpts->sz4CP, pdm->jot1()<<LIBOptName(pOpts->libAct, true)<<_T(" (library management)")); goto Ende; } if(!pOpts->szCheckFile.isEmpty() && pOpts->libAct != LIB_ACT_UNDEF) { //-c check file cannot be together with -al,-ll-rl or -ml: pdm->msg2(CG_E_CMDL_OPT_CONFLICT, &cmdl, _T("-c"), LIBOptName(pOpts->libAct, true)); goto Ende; } if(!pOpts->szCheckFile.isEmpty() && pOpts->targets.getUsed()>0) { //-c check file cannot be together with build target by name pdm->msg2(CG_E_CMDL_OPT_CONFLICT, &cmdl, _T("-c"), pOpts->targets.get(0)); goto Ende; } if(pdm->hasNoErr() && pOpts->targets.getUsed()>0) { //-c check build target by name in respect //to target type extension: for(i=0;i<pOpts->targets.getUsed();i++) { psz = pOpts->targets.get(i); psz2 = FC_StringGetFileExt(psz); if(!pIFront->KADgetTargetTypeByExt(psz2, NULL, NULL, NULL)) { pdm->msg2(CG_E_NO_TARGETTYPE_EXT, &cmdl, psz, pszTrgExts); } } } Ende: //if any cmdl error dump hint how to get help: if(pdm->hasErr()) { pdm->msg0(CG_E_BAD_CMDL_LINE, NULL); return false; } return true; }
//----------------------------------------------------------------------------- // Name: writeMiniDump() // Desc: //----------------------------------------------------------------------------- LONG CMiniDumper::writeMiniDump( _EXCEPTION_POINTERS *pExceptionInfo ) { LONG retval = EXCEPTION_CONTINUE_SEARCH; m_pExceptionInfo = pExceptionInfo; HANDLE hImpersonationToken = NULL; if( !getImpersonationToken( &hImpersonationToken ) ) return FALSE; // You have to find the right dbghelp.dll. // Look next to the EXE first since the one in System32 might be old (Win2k) HMODULE hDll = NULL; TCHAR szDbgHelpPath[MAX_PATH]; if( GetModuleFileName( NULL, m_szAppPath, _MAX_PATH ) ) { TCHAR *pSlash = _tcsrchr( m_szAppPath, '\\' ); if( pSlash ) { _tcscpy( m_szAppBaseName, pSlash + 1); *(pSlash+1) = 0; } _tcscpy( szDbgHelpPath, m_szAppPath ); _tcscat( szDbgHelpPath, _T("DBGHELP.DLL") ); hDll = ::LoadLibrary( szDbgHelpPath ); } if( hDll == NULL ) { // If we haven't found it yet - try one more time. hDll = ::LoadLibrary( _T("DBGHELP.DLL") ); } LPCTSTR szResult = NULL; if( hDll ) { // Get the address of the MiniDumpWriteDump function, which writes // user-mode mini-dump information to a specified file. MINIDUMPWRITEDUMP MiniDumpWriteDump = (MINIDUMPWRITEDUMP)::GetProcAddress( hDll, "MiniDumpWriteDump" ); if( MiniDumpWriteDump != NULL ) { TCHAR szScratch[USER_DATA_BUFFER_SIZE]; setMiniDumpFileName(); // Ask the user if he or she wants to save a mini-dump file... _tcssprintf( szScratch, _T("There was an unexpected error:\n\nWould you ") _T("like to create a mini-dump file?\n\n%s " ), m_szMiniDumpPath); // Create the mini-dump file... HANDLE hFile = ::CreateFile( m_szMiniDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL ); if( hFile != INVALID_HANDLE_VALUE ) { _MINIDUMP_EXCEPTION_INFORMATION ExInfo; ExInfo.ThreadId = ::GetCurrentThreadId(); ExInfo.ExceptionPointers = pExceptionInfo; ExInfo.ClientPointers = NULL; // We need the SeDebugPrivilege to be able to run MiniDumpWriteDump TOKEN_PRIVILEGES tp; BOOL bPrivilegeEnabled = enablePrivilege( SE_DEBUG_NAME, hImpersonationToken, &tp ); BOOL bOk; // DBGHELP.dll is not thread-safe, so we need to restrict access... EnterCriticalSection( s_pCriticalSection ); { // Write out the mini-dump data to the file... bOk = MiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL ); } LeaveCriticalSection( s_pCriticalSection ); // Restore the privileges when done if( bPrivilegeEnabled ) restorePrivilege( hImpersonationToken, &tp ); if( bOk ) { szResult = NULL; retval = EXCEPTION_EXECUTE_HANDLER; } else { _tcssprintf( szScratch, _T("Failed to save the mini-dump file to '%s' (error %d)"), m_szMiniDumpPath, GetLastError() ); szResult = szScratch; } ::CloseHandle( hFile ); } else { _tcssprintf( szScratch, _T("Failed to create the mini-dump file '%s' (error %d)"), m_szMiniDumpPath, GetLastError() ); szResult = szScratch; } } else { szResult = _T( "Call to GetProcAddress failed to find MiniDumpWriteDump. ") _T("The DBGHELP.DLL is possibly outdated." ); } } else { szResult = _T( "Call to LoadLibrary failed to find DBGHELP.DLL." ); } if( szResult && m_bPromptUserForMiniDump ) ::MessageBox( NULL, szResult, NULL, MB_OK ); TerminateProcess( GetCurrentProcess(), 0 ); return retval; }
BOOL CUnzipper::UnzipFile(LPCTSTR szFolder, BOOL bIgnoreFilePath) { if (!m_uzFile) return FALSE; if (!szFolder) szFolder = m_szOutputFolder; if (!CreateFolder(szFolder)) return FALSE; UZ_FileInfo info; GetFileInfo(info); // if the item is a folder then simply return 'TRUE' if (info.szFileName[lstrlen(info.szFileName) - 1] == '\\') return TRUE; // build the output filename TCHAR szFilePath[MAX_PATH]; wcscpy_s(szFilePath, MAX_PATH, szFolder); // append backslash if (szFilePath[lstrlen(szFilePath) - 1] != '\\') lstrcat(szFilePath, _T("\\")); if (bIgnoreFilePath) { TCHAR* p = _tcsrchr(info.szFileName, '\\'); if (p) _tcscpy_s(info.szFileName, MAX_PATH+1,p + 1); } TCHAR szFileName[MAX_PATH+1]; _tcscat_s(szFilePath, MAX_PATH, szFileName); // open the input and output files if (!CreateFilePath(szFilePath)) return FALSE; HANDLE hOutputFile = ::CreateFile(szFilePath, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (INVALID_HANDLE_VALUE == hOutputFile) return FALSE; // read the file and output int nRet = UNZ_OK; TCHAR pBuffer[BUFFERSIZE]; mUnzipData.message = ZLIBCBFN_FILE; do { nRet = unzReadCurrentFile(m_uzFile, pBuffer, BUFFERSIZE); if (nRet > 0) { // output DWORD dwBytesWritten = 0; if (!::WriteFile(hOutputFile, pBuffer, nRet, &dwBytesWritten, NULL) || dwBytesWritten != (DWORD)nRet) { nRet = UNZ_ERRNO; break; } mUnzipData.szBytesProcessed = dwBytesWritten; if (mCallbackFn(&mUnzipData) != ZLIBCBFN_CONTINUE) { nRet = UNZ_ERRNO; // User says abort break; } } } while (nRet > 0); CloseHandle(hOutputFile); unzCloseCurrentFile(m_uzFile); if (nRet == UNZ_OK) SetFileModTime(szFilePath, info.dwDosDate); return (nRet == UNZ_OK); }
IM_TCHAR * im_oswl_strrchr(IM_TCHAR *s, IM_INT32 c){ return _tcsrchr(s, c); }
BOOL CPreviewThread::Run() { ASSERT (m_pPartfile) ; CFile destFile; CFile srcFile; if (!srcFile.Open(m_pPartfile->GetFilePath(), CFile::modeRead | CFile::shareDenyNone)) return FALSE; try{ uint64 nSize = m_pPartfile->GetFileSize(); CString strExtension = CString(_tcsrchr(m_pPartfile->GetFileName(), _T('.'))); CString strPreviewName = m_pPartfile->GetTempPath() + m_pPartfile->GetFileName().Mid(0, 5) + _T("_preview") + strExtension; bool bFullSized = true; if (!strExtension.CompareNoCase(_T(".mpg")) || !strExtension.CompareNoCase(_T(".mpeg"))) bFullSized = false; if (!destFile.Open(strPreviewName, CFile::modeWrite | CFile::shareDenyWrite | CFile::modeCreate)) return FALSE; srcFile.SeekToBegin(); if (bFullSized) destFile.SetLength(nSize); destFile.SeekToBegin(); BYTE abyBuffer[4096]; uint32 nRead; while (destFile.GetPosition()+4096 < PARTSIZE*2){ nRead = srcFile.Read(abyBuffer,4096); destFile.Write(abyBuffer,nRead); } srcFile.Seek(-(LONGLONG)(PARTSIZE*2), CFile::end); uint32 nToGo = PARTSIZE*2; if (bFullSized) destFile.Seek(-(LONGLONG)(PARTSIZE*2), CFile::end); do{ nRead = (nToGo - 4096 < 1)? nToGo:4096; nToGo -= nRead; nRead = srcFile.Read(abyBuffer,4096); destFile.Write(abyBuffer,nRead); } while (nToGo); destFile.Close(); srcFile.Close(); m_pPartfile->m_bPreviewing = false; SHELLEXECUTEINFO SE = {0}; SE.fMask = SEE_MASK_NOCLOSEPROCESS; CString strCommand; CString strArgs; CString strCommandDir; if (!m_strCommand.IsEmpty()) { SE.lpVerb = _T("open"); // "open" the specified video player // get directory of video player application strCommandDir = m_strCommand; int iPos = strCommandDir.ReverseFind(_T('\\')); if (iPos == -1) strCommandDir.Empty(); else strCommandDir = strCommandDir.Left(iPos + 1); PathRemoveBackslash(strCommandDir.GetBuffer()); strCommandDir.ReleaseBuffer(); strArgs = m_strCommandArgs; if (!strArgs.IsEmpty()) strArgs += _T(' '); if (strPreviewName.Find(_T(' ')) != -1) strArgs += _T('\"') + strPreviewName + _T('\"'); else strArgs += strPreviewName; strCommand = m_strCommand; ExpandEnvironmentStrings(strCommand); ExpandEnvironmentStrings(strArgs); ExpandEnvironmentStrings(strCommandDir); SE.lpFile = strCommand; SE.lpParameters = strArgs; SE.lpDirectory = strCommandDir; } else { SE.lpVerb = NULL; // use the default verb or the open verb for the document SE.lpFile = strPreviewName; } SE.nShow = SW_SHOW; SE.cbSize = sizeof(SE); ShellExecuteEx(&SE); if (SE.hProcess){ WaitForSingleObject(SE.hProcess, INFINITE); CloseHandle(SE.hProcess); } CFile::Remove(strPreviewName); } catch(CFileException* error){ m_pPartfile->m_bPreviewing = false; error->Delete(); } return TRUE; }
bool WINAPI SFileCompactArchive(HANDLE hMpq, const char * szListFile, bool /* bReserved */) { TFileStream * pTempStream = NULL; TMPQArchive * ha = (TMPQArchive *)hMpq; ULONGLONG ByteOffset; ULONGLONG ByteCount; LPDWORD pFileKeys = NULL; TCHAR szTempFile[MAX_PATH] = _T(""); TCHAR * szTemp = NULL; int nError = ERROR_SUCCESS; // Test the valid parameters if(!IsValidMpqHandle(ha)) nError = ERROR_INVALID_HANDLE; if(ha->dwFlags & MPQ_FLAG_READ_ONLY) nError = ERROR_ACCESS_DENIED; // If the MPQ is changed at this moment, we have to flush the archive if(nError == ERROR_SUCCESS && (ha->dwFlags & MPQ_FLAG_CHANGED)) { SFileFlushArchive(hMpq); } // Create the table with file keys if(nError == ERROR_SUCCESS) { if((pFileKeys = STORM_ALLOC(DWORD, ha->dwFileTableSize)) != NULL) memset(pFileKeys, 0, sizeof(DWORD) * ha->dwFileTableSize); else nError = ERROR_NOT_ENOUGH_MEMORY; } // First of all, we have to check of we are able to decrypt all files. // If not, sorry, but the archive cannot be compacted. if(nError == ERROR_SUCCESS) { // Initialize the progress variables for compact callback FileStream_GetSize(ha->pStream, CompactTotalBytes); CompactBytesProcessed = 0; nError = CheckIfAllFilesKnown(ha, szListFile, pFileKeys); } // Get the temporary file name and create it if(nError == ERROR_SUCCESS) { _tcscpy(szTempFile, ha->pStream->szFileName); if((szTemp = _tcsrchr(szTempFile, '.')) != NULL) _tcscpy(szTemp + 1, _T("mp_")); else _tcscat(szTempFile, _T("_")); pTempStream = FileStream_CreateFile(szTempFile); if(pTempStream == NULL) nError = GetLastError(); } // Write the data before MPQ user data (if any) if(nError == ERROR_SUCCESS && ha->UserDataPos != 0) { // Inform the application about the progress if(CompactCB != NULL) CompactCB(pvUserData, CCB_COPYING_NON_MPQ_DATA, CompactBytesProcessed, CompactTotalBytes); ByteOffset = 0; ByteCount = ha->UserDataPos; nError = CopyNonMpqData(ha->pStream, pTempStream, ByteOffset, ByteCount); } // Write the MPQ user data (if any) if(nError == ERROR_SUCCESS && ha->MpqPos > ha->UserDataPos) { // At this point, we assume that the user data size is equal // to pUserData->dwHeaderOffs. // If this assumption doesn't work, then we have an unknown version of MPQ ByteOffset = ha->UserDataPos; ByteCount = ha->MpqPos - ha->UserDataPos; assert(ha->pUserData != NULL); assert(ha->pUserData->dwHeaderOffs == ByteCount); nError = CopyNonMpqData(ha->pStream, pTempStream, ByteOffset, ByteCount); } // Write the MPQ header if(nError == ERROR_SUCCESS) { // Remember the header size before swapping DWORD dwBytesToWrite = ha->pHeader->dwHeaderSize; BSWAP_TMPQHEADER(ha->pHeader); if(!FileStream_Write(pTempStream, NULL, ha->pHeader, dwBytesToWrite)) nError = GetLastError(); BSWAP_TMPQHEADER(ha->pHeader); // Update the progress CompactBytesProcessed += ha->pHeader->dwHeaderSize; } // Now copy all files if(nError == ERROR_SUCCESS) { nError = CopyMpqFiles(ha, pFileKeys, pTempStream); ha->dwFlags |= MPQ_FLAG_CHANGED; } // If succeeded, switch the streams if(nError == ERROR_SUCCESS) { if(FileStream_MoveFile(ha->pStream, pTempStream)) pTempStream = NULL; else nError = ERROR_CAN_NOT_COMPLETE; } // If all succeeded, save the MPQ tables if(nError == ERROR_SUCCESS) { // // Note: We don't recalculate position of the MPQ tables at this point. // SaveMPQTables does it automatically. // nError = SaveMPQTables(ha); if(nError == ERROR_SUCCESS && CompactCB != NULL) { CompactBytesProcessed += (ha->pHeader->dwHashTableSize * sizeof(TMPQHash)); CompactBytesProcessed += (ha->pHeader->dwBlockTableSize * sizeof(TMPQBlock)); CompactCB(pvUserData, CCB_CLOSING_ARCHIVE, CompactBytesProcessed, CompactTotalBytes); } } // Invalidate the compact callback pvUserData = NULL; CompactCB = NULL; // Cleanup and return if(pTempStream != NULL) FileStream_Close(pTempStream); if(pFileKeys != NULL) STORM_FREE(pFileKeys); if(nError != ERROR_SUCCESS) SetLastError(nError); return (nError == ERROR_SUCCESS); }
BOOL CPropertiesGeneral::OnInitDialog() { CPropertyPage::OnInitDialog(); CARMDlg* dlg=(CARMDlg*)this->GetParentOwner()->GetParent(); TCHAR szTemp[MAX_PATH]; arfile* arFile=(arfile*)dlg->m_lstFiles.GetItemDataPtr(dlg->m_lstFiles.GetCurSel()); HANDLE hFile; FILETIME fileTime; size_t fileSize; SYSTEMTIME stUTC, stLocal; TCITEM ti={0}; HZIP hZip; ZIPENTRY ze; LPTSTR pszTemp, pszBuffer, pszTok; CString szBytes; szBytes.LoadString(IDS_BYTES); _tcscpy(szTemp,arFile->fileName); *_tcsrchr(szTemp,'\\')=0; SetDlgItemText(IDC_PROP_DESC,arFile->description); SetDlgItemText(IDC_PROP_FILENAME,szTemp+_tcslen(szTemp)+1); SetDlgItemText(IDC_PROP_LOCATION,szTemp); _itot(arFile->size,szTemp,10); _tcscat(szTemp,szBytes); SetDlgItemText(IDC_PROP_UNCOMPRESSED,szTemp); hFile=CreateFile(arFile->fileName,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL); fileSize=GetFileSize(hFile,NULL); GetFileTime(hFile,NULL,NULL,&fileTime); FileTimeToSystemTime(&fileTime, &stUTC); SystemTimeToTzSpecificLocalTime(NULL, &stUTC, &stLocal); CloseHandle(hFile); _itot((int)fileSize,szTemp,10); _tcscat(szTemp,szBytes); SetDlgItemText(IDC_PROP_FILESIZE,szTemp); _stprintf(szTemp,"%4d/%2d/%2d %2d:%2d:%2d",stLocal.wYear,stLocal.wMonth,stLocal.wDay,stLocal.wHour,stLocal.wMinute,stLocal.wSecond); SetDlgItemText(IDC_PROP_MODIFIED,szTemp); _stprintf(szTemp,"%d - ",arFile->features); ti.mask=TCIF_TEXT; ti.pszText=szTemp+_tcslen(szTemp); ti.cchTextMax=MAX_PATH-(int)_tcslen(szTemp); dlg->m_tab.GetItem(dlg->m_tab.GetCurSel(),&ti); SetDlgItemText(IDC_PROP_FILETYPE,szTemp); hZip=OpenZip(arFile->fileName,0,ZIP_FILENAME); if (hZip) { for (int c=0; GetZipItem(hZip,c,&ze)!=ZR_ARGS; c++) { _tcslwr(ze.name); if (!_tcsncmp(ze.name,"tune/",5) && _tcsstr(ze.name,".info")) { pszTemp=(LPTSTR)malloc(ze.unc_size); UnzipItem(hZip,c,pszTemp,ze.unc_size,ZIP_MEMORY); pszBuffer=_tcsstr(pszTemp,"Colors="); if (pszBuffer) { pszBuffer+=7; if (_tcschr(pszBuffer,'\r')) *_tcschr(pszBuffer,'\r')=0; if (_tcschr(pszBuffer,'\n')) *_tcschr(pszBuffer,'\n')=0; pszTok=_tcstok(pszBuffer,"|"); while (pszTok) { ((CListBox*)this->GetDlgItem(IDC_PROP_VARIATIONS))->AddString(pszTok); pszTok=_tcstok(NULL,"|"); } } free(pszTemp); } } CloseZip(hZip); } return FALSE; }
int CShellCommandSetValue::Execute(CConsole &rConsole, CArgumentParser& rArguments) { LONG nError; rArguments.ResetArgumentIteration(); TCHAR *pszCommandItself = rArguments.GetNextArgument(); TCHAR *pszParameter; TCHAR *pszValueFull = NULL; TCHAR *pszValueData = NULL; BOOL blnBadParameter = FALSE; BOOL blnHelp = FALSE; DWORD dwValueSize = 0; DWORD dwType = REG_NONE; BYTE *pDataBuffer = NULL; if ((_tcsnicmp(pszCommandItself,SET_VALUE_CMD _T(".."),SET_VALUE_CMD_LENGTH+2*sizeof(TCHAR)) == 0)|| (_tcsnicmp(pszCommandItself,SET_VALUE_CMD _T("\\"),SET_VALUE_CMD_LENGTH+1*sizeof(TCHAR)) == 0)) { pszValueFull = pszCommandItself + SET_VALUE_CMD_LENGTH; } else if (_tcsnicmp(pszCommandItself,SET_VALUE_CMD _T("/"),SET_VALUE_CMD_LENGTH+1*sizeof(TCHAR)) == 0) { pszParameter = pszCommandItself + SET_VALUE_CMD_LENGTH; goto CheckValueArgument; } while((pszParameter = rArguments.GetNextArgument()) != NULL) { CheckValueArgument: blnBadParameter = FALSE; if (((*pszParameter == _T('/'))||(*pszParameter == _T('-'))) &&(*(pszParameter+1) == _T('?'))) { blnHelp = TRUE; } else if (dwType == REG_NONE) { if (_tcsicmp(pszParameter,_T("b")) == 0) { dwType = REG_BINARY; } else if (_tcsicmp(pszParameter,_T("dw")) == 0) { dwType = REG_DWORD; } else if (_tcsicmp(pszParameter,_T("dwle")) == 0) { dwType = REG_DWORD_LITTLE_ENDIAN; } else if (_tcsicmp(pszParameter,_T("dwbe")) == 0) { dwType = REG_DWORD_BIG_ENDIAN; } else if (_tcsicmp(pszParameter,_T("sz")) == 0) { dwType = REG_SZ; } else if (_tcsicmp(pszParameter,_T("esz")) == 0) { dwType = REG_EXPAND_SZ; } else { blnBadParameter = TRUE; } } else if (pszValueData == NULL) { pszValueData = pszParameter; } else if (!pszValueFull) { pszValueFull = pszParameter; } else { blnBadParameter = TRUE; } if (blnBadParameter) { rConsole.Write(_T("Bad parameter: ")); rConsole.Write(pszParameter); rConsole.Write(_T("\n")); } } if (!pszValueData) blnHelp = TRUE; CRegistryKey Key; TCHAR *pszValueName; const TCHAR *pszEmpty = _T(""); const TCHAR *pszPath; if (blnHelp) { rConsole.Write(GetHelpString()); if (pDataBuffer) delete pDataBuffer; return 0; } if (pszValueFull) { if (_tcscmp(pszValueFull,_T("\\")) == 0) goto CommandNAonRoot; TCHAR *pchSep = _tcsrchr(pszValueFull,_T('\\')); pszValueName = pchSep?(pchSep+1):(pszValueFull); pszPath = pchSep?pszValueFull:_T("."); //if (_tcsrchr(pszValueName,_T('.'))) //{ // pszValueName = _T(""); // pszPath = pszValueFull; //} //else if (pchSep) *pchSep = 0; } else { pszValueName = (TCHAR*)pszEmpty; pszPath = _T("."); } if (!m_rTree.GetKey(pszPath,KEY_SET_VALUE,Key)) { rConsole.Write(m_rTree.GetLastErrorDescription()); goto SkipCommand; } if (Key.IsRoot()) goto CommandNAonRoot; switch (dwType) { case REG_BINARY: { HANDLE hFile; DWORD dwBytesReaded; hFile = CreateFile(pszValueData,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL); if (hFile == INVALID_HANDLE_VALUE) { rConsole.Write(_T("Cannot open file ")); rConsole.Write(pszValueData); rConsole.Write(_T("\n")); goto SkipCommand; } dwValueSize = GetFileSize(hFile,NULL); if (dwValueSize == (DWORD)-1) // ok, that's right, we compare signed with unsigned here. // GetFileSize is documented and declared to return DWORD. // Error is indicated by checking if return is -1. Design->documentation bug ??? { rConsole.Write(_T("Cannot get size of file ")); rConsole.Write(pszValueData); rConsole.Write(_T("\n")); VERIFY(CloseHandle(hFile)); goto SkipCommand; } pDataBuffer = new BYTE [dwValueSize]; if (!pDataBuffer) { rConsole.Write(_T("Cannot load file into memory. Out of memory.\n")); VERIFY(CloseHandle(hFile)); goto SkipCommand; } if (!ReadFile(hFile,pDataBuffer,dwValueSize,&dwBytesReaded,NULL)) { rConsole.Write(_T("Cannot load file into memory. Error reading file.\n")); VERIFY(CloseHandle(hFile)); goto SkipCommand; } VERIFY(CloseHandle(hFile)); ASSERT(dwBytesReaded == dwValueSize); } break; case REG_DWORD_LITTLE_ENDIAN: case REG_DWORD_BIG_ENDIAN: dwValueSize = 4; pDataBuffer = (BYTE *) new BYTE [dwValueSize]; if (!StringToDWORD(*(DWORD *)pDataBuffer,pszValueData)) { rConsole.Write(_T("Cannot convert ")); rConsole.Write(pszValueData); rConsole.Write(_T(" to DWORD \n")); goto SkipCommand; } if (dwType == REG_DWORD_BIG_ENDIAN) { unsigned char nByte; nByte = *pDataBuffer; *pDataBuffer = *(pDataBuffer+3); *(pDataBuffer+3) = nByte; nByte = *(pDataBuffer+1); *(pDataBuffer+1) = *(pDataBuffer+2); *(pDataBuffer+2) = nByte; } break; case REG_SZ: case REG_EXPAND_SZ: dwValueSize = _tcslen(pszValueData)+1; if (*pszValueData == _T('\"')) { dwValueSize -= 2; *(pszValueData+dwValueSize) = 0; pszValueData++; } dwValueSize *= sizeof(TCHAR); pDataBuffer = (BYTE *) new BYTE [dwValueSize]; { const TCHAR *pchSrc = pszValueData; TCHAR *pchDest = (TCHAR *)pDataBuffer; while(*pchSrc) { if (pchSrc[0] == _T('^')) { if (pchSrc[1] == _T('a')) *pchDest = _T('\a'); else if (pchSrc[1] == _T('b')) *pchDest = _T('\b'); else if (pchSrc[1] == _T('f')) *pchDest = _T('\f'); else if (pchSrc[1] == _T('n')) *pchDest = _T('\n'); else if (pchSrc[1] == _T('r')) *pchDest = _T('\r'); else if (pchSrc[1] == _T('t')) *pchDest = _T('\t'); else *pchDest = pchSrc[1]; pchSrc +=2; pchDest++; dwValueSize--; } else { *pchDest = *pchSrc; pchSrc++; pchDest++; } } *pchDest = _T('\0'); } break; default: ASSERT(FALSE); } { size_t s = _tcslen(pszValueName); if (s && (pszValueName[0] == _T('\"'))&&(pszValueName[s-1] == _T('\"'))) { pszValueName[s-1] = 0; pszValueName++; } } nError = Key.SetValue(pszValueName,dwType,pDataBuffer,dwValueSize); if (nError != ERROR_SUCCESS) { char Buffer[254]; _stprintf(Buffer,_T("Cannot set value. Error is %u\n"),(unsigned int)nError); rConsole.Write(Buffer); } else { InvalidateCompletion(); } SkipCommand: if (pDataBuffer) delete[] pDataBuffer; return 0; CommandNAonRoot: rConsole.Write(SET_VALUE_CMD COMMAND_NA_ON_ROOT); return 0; }
static int checkAPI(TCHAR* plugin, BASIC_PLUGIN_INFO* bpi, DWORD mirandaVersion, int checkTypeAPI, int* exports) { HINSTANCE h = NULL; // this is evil but these plugins are buggy/old and people are blaming Miranda // fontservice plugin is built into the core now { TCHAR * p = _tcsrchr(plugin, '\\'); if ( p != NULL && ++p ) { int i; for ( i = 0; i < SIZEOF(modulesToSkip); i++ ) if ( lstrcmpi( p, modulesToSkip[i] ) == 0 ) return 0; } } h = LoadLibrary(plugin); if ( h == NULL ) return 0; // loaded, check for exports bpi->Load = (Miranda_Plugin_Load) GetProcAddress(h, "Load"); bpi->Unload = (Miranda_Plugin_Unload) GetProcAddress(h, "Unload"); bpi->Info = (Miranda_Plugin_Info) GetProcAddress(h, "MirandaPluginInfo"); bpi->InfoEx = (Miranda_Plugin_InfoEx) GetProcAddress(h, "MirandaPluginInfoEx"); bpi->Interfaces = (Miranda_Plugin_Interfaces) GetProcAddress(h, "MirandaPluginInterfaces"); // if they were present if ( bpi->Load && bpi->Unload && ( bpi->Info || ( bpi->InfoEx && bpi->Interfaces ))) { PLUGININFOEX* pi = 0; if (bpi->InfoEx) pi = bpi->InfoEx(mirandaVersion); else pi = (PLUGININFOEX*)bpi->Info(mirandaVersion); { // similar to the above hack but these plugins are checked for a valid interface first (in case there are updates to the plugin later) TCHAR* p = _tcsrchr(plugin, '\\'); if ( pi != NULL && p != NULL && ++p ) { if ( !bpi->InfoEx || pi->cbSize != sizeof(PLUGININFOEX)) { int i; for ( i = 0; i < SIZEOF(expiredModulesToSkip); i++ ) { if ( lstrcmpi( p, expiredModulesToSkip[i] ) == 0 ) { FreeLibrary(h); return 0; } } } } } if ( checkPI( bpi, pi )) { bpi->pluginInfo = pi; // basic API is present if ( checkTypeAPI == CHECKAPI_NONE ) { bpi->hInst=h; return 1; } // check for DB? if ( checkTypeAPI == CHECKAPI_DB ) { bpi->DbInfo = (Database_Plugin_Info) GetProcAddress(h, "DatabasePluginInfo"); if ( bpi->DbInfo ) { // fetch internal database function pointers bpi->dblink = bpi->DbInfo(NULL); // validate returned link structure if ( bpi->dblink && bpi->dblink->cbSize==sizeof(DATABASELINK) ) { bpi->hInst=h; return 1; } // had DB exports if ( exports != NULL ) *exports=1; } //if } //if // check clist ? if ( checkTypeAPI == CHECKAPI_CLIST ) { bpi->clistlink = (CList_Initialise) GetProcAddress(h, "CListInitialise"); #if defined( _UNICODE ) if ( pi->flags & UNICODE_AWARE ) #endif if ( bpi->clistlink ) { // nothing more can be done here, this export is a load function bpi->hInst=h; if ( exports != NULL ) *exports=1; return 1; } } } // if if ( exports != NULL ) *exports=1; } //if // not found, unload FreeLibrary(h); return 0; }
BOOL CALLBACK SelectDbDlgProc(HWND hdlg,UINT message,WPARAM wParam,LPARAM lParam) { BOOL bReturn; if ( DoMyControlProcessing( hdlg, message, wParam, lParam, &bReturn )) return bReturn; switch ( message ) { case WM_INITDIALOG: { TCHAR szMirandaPath[MAX_PATH]; szMirandaPath[ 0 ] = 0; { HIMAGELIST hIml; hIml=ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), (IsWinVerXPPlus() ? ILC_COLOR32 : ILC_COLOR16) | ILC_MASK, 3, 3); ImageList_AddIcon(hIml,LoadIcon(hInst,MAKEINTRESOURCE(IDI_PROFILEGREEN))); ImageList_AddIcon(hIml,LoadIcon(hInst,MAKEINTRESOURCE(IDI_PROFILEYELLOW))); ImageList_AddIcon(hIml,LoadIcon(hInst,MAKEINTRESOURCE(IDI_PROFILERED))); ImageList_AddIcon(hIml,LoadIcon(hInst,MAKEINTRESOURCE(IDI_BAD))); ListView_SetImageList(GetDlgItem(hdlg,IDC_DBLIST),hIml,LVSIL_SMALL); } ListView_SetExtendedListViewStyleEx(GetDlgItem(hdlg,IDC_DBLIST),LVS_EX_FULLROWSELECT,LVS_EX_FULLROWSELECT); { LV_COLUMN lvc; lvc.mask = LVCF_WIDTH | LVCF_FMT | LVCF_TEXT; lvc.cx = 205; lvc.fmt = LVCFMT_LEFT; lvc.pszText = TranslateT("Database"); ListView_InsertColumn( GetDlgItem(hdlg,IDC_DBLIST), 0, &lvc ); lvc.cx = 68; lvc.fmt = LVCFMT_RIGHT; lvc.pszText = TranslateT("Total size"); ListView_InsertColumn(GetDlgItem(hdlg,IDC_DBLIST), 1, &lvc ); lvc.pszText = TranslateT("Wasted"); ListView_InsertColumn(GetDlgItem(hdlg,IDC_DBLIST), 2, &lvc ); } { TCHAR *str2; GetModuleFileName(NULL,szMirandaPath,SIZEOF(szMirandaPath)); str2 = _tcsrchr(szMirandaPath,'\\'); if( str2 != NULL ) *str2=0; } { int i = 0; HKEY hKey; TCHAR szProfileDir[MAX_PATH]; DWORD cbData = SIZEOF(szMirandaPath); TCHAR szMirandaProfiles[MAX_PATH]; _tcscpy(szMirandaProfiles, szMirandaPath); _tcscat(szMirandaProfiles, _T("\\Profiles")); GetProfileDirectory(szMirandaPath,szProfileDir,SIZEOF(szProfileDir)); // search in profile dir (using ini file) if( lstrcmpi(szProfileDir,szMirandaProfiles) ) FindAdd(hdlg, szProfileDir, _T("[ini]\\")); FindAdd(hdlg, szMirandaProfiles, _T("[prf]\\")); // search in current dir (as DBTOOL) FindAdd(hdlg, szMirandaPath, _T("[ . ]\\")); // search in profile dir (using registry path + ini file) if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\Miranda"),0,KEY_QUERY_VALUE,&hKey) == ERROR_SUCCESS) { if(RegQueryValueEx(hKey,_T("Install_Dir"),NULL,NULL,(PBYTE)szMirandaPath,&cbData) == ERROR_SUCCESS) { if( lstrcmp(szProfileDir,szMirandaPath) ) { GetProfileDirectory(szMirandaPath,szProfileDir,SIZEOF(szProfileDir)); FindAdd(hdlg, szProfileDir, _T("[reg]\\")); } } RegCloseKey(hKey); } // select if ( opts.filename[0] ) i = AddDatabaseToList( GetDlgItem( hdlg, IDC_DBLIST ), opts.filename, _T("") ); if ( i == -1 ) i = 0; ListView_SetItemState( GetDlgItem(hdlg,IDC_DBLIST), i, LVIS_SELECTED, LVIS_SELECTED ); } if ( opts.hFile != NULL && opts.hFile != INVALID_HANDLE_VALUE ) { CloseHandle( opts.hFile ); opts.hFile = NULL; } TranslateDialog( hdlg ); return TRUE; } case WZN_PAGECHANGING: GetDlgItemText( hdlg, IDC_FILE, opts.filename, SIZEOF(opts.filename)); break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_FILE: if(HIWORD(wParam)==EN_CHANGE) EnableWindow(GetDlgItem(GetParent(hdlg),IDOK),GetWindowTextLength(GetDlgItem(hdlg,IDC_FILE))); break; case IDC_OTHER: { OPENFILENAME ofn={0}; TCHAR str[MAX_PATH]; // _T("Miranda Databases (*.dat)\0*.DAT\0All Files (*)\0*\0"); TCHAR *filter, *tmp, *tmp1, *tmp2; tmp1 = TranslateT("Miranda Databases (*.dat)"); tmp2 = TranslateT("All Files"); filter = tmp = (TCHAR*)_malloca((_tcslen(tmp1)+_tcslen(tmp2)+11)*sizeof(TCHAR)); tmp = addstring(tmp, tmp1); tmp = addstring(tmp, _T("*.DAT")); tmp = addstring(tmp, tmp2); tmp = addstring(tmp, _T("*")); *tmp = 0; GetDlgItemText( hdlg, IDC_FILE, str, SIZEOF( str )); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hdlg; ofn.hInstance = NULL; ofn.lpstrFilter = filter; ofn.lpstrDefExt = _T("dat"); ofn.lpstrFile = str; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.nMaxFile = SIZEOF(str); ofn.nMaxFileTitle = MAX_PATH; if ( GetOpenFileName( &ofn )) { int i; i = AddDatabaseToList( GetDlgItem(hdlg,IDC_DBLIST), str, _T("") ); if ( i == -1 ) i=0; ListView_SetItemState( GetDlgItem(hdlg,IDC_DBLIST), i, LVIS_SELECTED, LVIS_SELECTED ); } break; } case IDC_BACK: SendMessage(GetParent(hdlg),WZM_GOTOPAGE,IDD_WELCOME,(LPARAM)WelcomeDlgProc); break; case IDOK: opts.hFile = CreateFile( opts.filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL ); if ( opts.hFile == INVALID_HANDLE_VALUE ) { opts.hFile = NULL; opts.error = GetLastError(); SendMessage( GetParent(hdlg), WZM_GOTOPAGE, IDD_OPENERROR, ( LPARAM )OpenErrorDlgProc ); } else SendMessage( GetParent(hdlg), WZM_GOTOPAGE, IDD_FILEACCESS, (LPARAM)FileAccessDlgProc ); break; } break; case WM_NOTIFY: switch(((LPNMHDR)lParam)->idFrom) { case IDC_DBLIST: switch(((LPNMLISTVIEW)lParam)->hdr.code) { case LVN_ITEMCHANGED: { LV_ITEM lvi; lvi.iItem=ListView_GetNextItem(GetDlgItem(hdlg,IDC_DBLIST),-1,LVNI_SELECTED); if(lvi.iItem==-1) break; lvi.mask=LVIF_PARAM; ListView_GetItem(GetDlgItem(hdlg,IDC_DBLIST),&lvi); SetDlgItemText(hdlg,IDC_FILE,(TCHAR*)lvi.lParam); SendMessage(hdlg,WM_COMMAND,MAKEWPARAM(IDC_FILE,EN_CHANGE),(LPARAM)GetDlgItem(hdlg,IDC_FILE)); break; } } break; } break; case WM_DESTROY: { LV_ITEM lvi; lvi.mask=LVIF_PARAM; for(lvi.iItem=ListView_GetItemCount(GetDlgItem(hdlg,IDC_DBLIST))-1;lvi.iItem>=0;lvi.iItem--) { ListView_GetItem(GetDlgItem(hdlg,IDC_DBLIST),&lvi); free((char*)lvi.lParam); } } break; } return FALSE; }
// This function returns the full path of the next selected file. // // Parameters: // [IN] pos // A reference to a POSITION value returned by a previous GetNextPathName // or GetStartPosition function call. // NULL if the end of the list has been reached. // // Return value: // A CString object containing the full path of the file. // // Note: this function has been copied exactly from the MFC // implementation of the CFileDialog class. // CString CFileDialogST::GetNextPathName(POSITION& pos) const { BOOL bExplorer = m_ofn.Flags & OFN_EXPLORER; TCHAR chDelimiter; if (bExplorer) chDelimiter = '\0'; else chDelimiter = ' '; LPTSTR lpsz = (LPTSTR)pos; if (lpsz == m_ofn.lpstrFile) // first time { if ((m_ofn.Flags & OFN_ALLOWMULTISELECT) == 0) { pos = NULL; return m_ofn.lpstrFile; } // find char pos after first Delimiter while(*lpsz != chDelimiter && *lpsz != '\0') lpsz = _tcsinc(lpsz); lpsz = _tcsinc(lpsz); // if single selection then return only selection if (*lpsz == 0) { pos = NULL; return m_ofn.lpstrFile; } } CString strPath = m_ofn.lpstrFile; if (!bExplorer) { LPTSTR lpszPath = m_ofn.lpstrFile; while(*lpszPath != chDelimiter) lpszPath = _tcsinc(lpszPath); strPath = strPath.Left(lpszPath - m_ofn.lpstrFile); } LPTSTR lpszFileName = lpsz; CString strFileName = lpsz; // find char pos at next Delimiter while(*lpsz != chDelimiter && *lpsz != '\0') lpsz = _tcsinc(lpsz); if (!bExplorer && *lpsz == '\0') pos = NULL; else { if (!bExplorer) strFileName = strFileName.Left(lpsz - lpszFileName); lpsz = _tcsinc(lpsz); if (*lpsz == '\0') // if double terminated then done pos = NULL; else pos = (POSITION)lpsz; } // only add '\\' if it is needed if (!strPath.IsEmpty()) { // check for last back-slash or forward slash (handles DBCS) LPCTSTR lpsz = _tcsrchr(strPath, '\\'); if (lpsz == NULL) lpsz = _tcsrchr(strPath, '/'); // if it is also the last character, then we don't need an extra if (lpsz != NULL && (lpsz - (LPCTSTR)strPath) == strPath.GetLength()-1) { ASSERT(*lpsz == '\\' || *lpsz == '/'); return strPath + strFileName; } } return strPath + '\\' + strFileName; } // End of GetNextPathName
static int AddDatabaseToList(HWND hwndList, TCHAR* filename, TCHAR* dir) { LV_ITEM lvi; int iNewItem; TCHAR szSize[20], *pName, *pDot, szName[MAX_PATH]; HANDLE hDbFile; DBHeader dbhdr; DWORD bytesRead; DWORD totalSize,wasted=0; int broken=0; lvi.mask=LVIF_PARAM; lvi.iSubItem=0; for(lvi.iItem=ListView_GetItemCount(hwndList)-1;lvi.iItem>=0;lvi.iItem--) { ListView_GetItem(hwndList,&lvi); if( !_tcsicmp(( TCHAR* )lvi.lParam,filename)) return lvi.iItem; } hDbFile=CreateFile(filename,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,0,NULL); if ( hDbFile == INVALID_HANDLE_VALUE ) return -1; ReadFile(hDbFile,&dbhdr,sizeof(dbhdr),&bytesRead,NULL); totalSize=GetFileSize(hDbFile,NULL); broken = (bytesRead<sizeof(dbhdr) || memcmp(dbhdr.signature,&dbSignature,sizeof(dbhdr.signature))); if(!broken) { wasted = dbhdr.slackSpace; if (totalSize>dbhdr.ofsFileEnd) wasted+=totalSize-dbhdr.ofsFileEnd; } CloseHandle(hDbFile); pName = _tcsrchr(filename,'\\'); if ( pName == NULL ) pName = ( LPTSTR )filename; else pName++; _tcscpy(szName,dir); _tcscat(szName,pName); pDot = _tcsrchr( szName, '.' ); if ( pDot != NULL && !_tcsicmp( pDot, _T(".dat")) ) *pDot=0; lvi.iItem = 0; lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE; lvi.iSubItem = 0; lvi.lParam = ( LPARAM )_tcsdup(filename); lvi.pszText = szName; if (broken) lvi.iImage = 3; else if ( wasted < 1024*128 ) lvi.iImage = 0; else if ( wasted < 1024*256 + (DWORD)(totalSize > 2*1024*1024 ) ? 256 * 1024 : 0 ) lvi.iImage=1; else lvi.iImage=2; iNewItem = ListView_InsertItem(hwndList, &lvi ); _stprintf(szSize,_T("%.2lf MB"),totalSize/1048576.0); ListView_SetItemText(hwndList,iNewItem,1,szSize); if ( !broken ) { _stprintf(szSize,_T("%.2lf MB"),wasted/1048576.0); ListView_SetItemText(hwndList,iNewItem,2,szSize); } return iNewItem; }
BOOL EnumProfilesForList(TCHAR *fullpath, TCHAR *profile, LPARAM lParam) { ProfileEnumData *ped = (ProfileEnumData*)lParam; HWND hwndList = GetDlgItem(ped->hwnd, IDC_PROFILELIST); TCHAR sizeBuf[64]; bool bFileExists = false, bFileLocked = true; TCHAR *p = _tcsrchr(profile, '.'); _tcscpy(sizeBuf, _T("0 KB")); if (p != NULL) *p = 0; LVITEM item = { 0 }; item.mask = LVIF_TEXT | LVIF_IMAGE; item.pszText = profile; item.iItem = 0; struct _stat statbuf; if (_tstat(fullpath, &statbuf) == 0) { if (statbuf.st_size > 1000000) { mir_sntprintf(sizeBuf, SIZEOF(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1048576.0); _tcscpy(sizeBuf + 5, _T(" MB")); } else { mir_sntprintf(sizeBuf, SIZEOF(sizeBuf), _T("%.3lf"), (double)statbuf.st_size / 1024.0); _tcscpy(sizeBuf + 5, _T(" KB")); } bFileExists = TRUE; bFileLocked = !fileExist(fullpath); } item.iImage = bFileLocked; int iItem = SendMessage(hwndList, LVM_INSERTITEM, 0, (LPARAM)&item); if (lstrcmpi(ped->szProfile, fullpath) == 0) ListView_SetItemState(hwndList, iItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); item.iItem = iItem; item.iSubItem = 2; item.pszText = sizeBuf; SendMessage(hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item); if (bFileExists) { TCHAR szPath[MAX_PATH]; _tcscpy(szPath, fullpath); LVITEM item2; item2.mask = LVIF_TEXT; item2.iItem = iItem; DATABASELINK* dblink = FindDatabasePlugin(szPath); if (dblink != NULL) { if (bFileLocked) { // file locked item2.pszText = TranslateT("<In use>"); item2.iSubItem = 1; SendMessage(hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item2); } else { item.pszText = TranslateTS(dblink->szFullName); item.iSubItem = 1; SendMessage(hwndList, LVM_SETITEMTEXT, iItem, (LPARAM)&item); } } } return TRUE; }
BOOL CMainWnd::OpenMediaFile(BOOL fAdd, HWND hwndParent) { if (m_fShowOpenDlg) return FALSE; BOOL fRet; m_fShowOpenDlg = TRUE; CTempStr strTitle(fAdd ? IDS_TITLE_ADD_FILE : IDS_TITLE_OPEN_FILE); CTempStr strFilter; TCHAR szFile[FILE_BUFF_LEN] = {0}; #ifdef _WIN32_WCE OPENFILENAME ofn; memset(&(ofn), 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndParent ? hwndParent : m_hWnd; ofn.lpstrFile = szFile; ofn.nMaxFile = FILE_BUFF_LEN; ofn.lpstrTitle = strTitle; BOOL (*gsGetOpenFileName)(OPENFILENAME*) = NULL; HINSTANCE hInst = LoadLibrary(_T("gsgetfile.dll")); if (hInst) { (FARPROC&)gsGetOpenFileName = GetProcAddress(hInst, _T("gsGetOpenFileName")); } if (gsGetOpenFileName) { if (!m_pszOpenFilter) MakeOpenFilter(&m_pszOpenFilter, TRUE); ofn.lpstrFilter = m_pszOpenFilter; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY; ofn.lpstrInitialDir = m_pOptions->m_szLastDir; fRet = gsGetOpenFileName(&ofn); } else { if (!m_pszOpenFilter) MakeOpenFilter(&m_pszOpenFilter, FALSE); ofn.lpstrFilter = m_pszOpenFilter; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; ofn.lpstrInitialDir = m_pOptions->m_szLastDir; fRet = GetOpenFileName(&ofn); } if (hInst) FreeLibrary(hInst); #else if (!m_pszOpenFilter) MakeOpenFilter(&m_pszOpenFilter, TRUE); OPENFILENAME ofn; memset(&(ofn), 0, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndParent ? hwndParent : m_hWnd; ofn.lpstrFile = szFile; ofn.nMaxFile = FILE_BUFF_LEN; ofn.lpstrTitle = strTitle; ofn.lpstrFilter = m_pszOpenFilter; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY; ofn.lpstrInitialDir = m_pOptions->m_szLastDir; fRet = GetOpenFileName(&ofn); #endif m_fShowOpenDlg = FALSE; if (!fRet) return FALSE; // 既存のリストを削除 if (!fAdd) DeleteAllFile(); // 追加 DWORD dw = GetFileAttributes(szFile); if (dw != 0xFFFFFFFF) { if (!(dw & FILE_ATTRIBUTE_DIRECTORY)) { // single if (IsPlayList(szFile)) LoadPlayList(szFile); else AddFile(szFile); LPTSTR psz = _tcsrchr(szFile, _T('\\')); if (psz) *psz = _T('\0'); _tcscpy(m_pOptions->m_szLastDir, szFile); } else { // multi TCHAR szPath[MAX_PATH]; LPTSTR p = szFile; _tcscpy(m_pOptions->m_szLastDir, szFile); while (TRUE) { p += _tcslen(p); if (*p != NULL || *(p + 1) == NULL) break; wsprintf(szPath, _T("%s\\%s"), m_pOptions->m_szLastDir, ++p); if (IsPlayList(szPath)) LoadPlayList(szPath); else AddFile(szPath); } } } return TRUE; }
BOOL JsonPlugin::SetDirectory(PCTSTR dir, int iOpMode) { tstring path; if(!_tcscmp(dir, _T(".."))) // go to updir (..) { path = CurrentDir; TCHAR* pSlash = _tcsrchr(CurrentDir, '/'); if(pSlash) { path = path.substr(0, pSlash - CurrentDir); } return GoToPath(path.c_str()); } // First, try the name immediately if(curObject->IsObject()) { auto mem = curObject->FindMember((PWSTR)WideFromOem(dir)); if(mem != curObject->MemberEnd()) { if(!mem->value.IsObject() && !mem->value.IsArray()) return FALSE; curObject = &mem->value; _tcsncat(CurrentDir, _T("/"), _countof(CurrentDir)); size_t l = _tcslen(CurrentDir); EncodeToBuf(CurrentDir + l, dir, _countof(CurrentDir) - l); CurrentDir[_countof(CurrentDir) - 1] = 0; return TRUE; } } else if(curObject->IsArray()) //try the value immediately { PTSTR end; long index = _tcstol(dir, &end, 10); if(*end == 0) { auto val = &(*curObject)[index]; if(!val->IsObject() && !val->IsArray()) return FALSE; curObject = val; _tcsncat(CurrentDir, _T("/"), _countof(CurrentDir)); _tcsncat(CurrentDir, dir, _countof(CurrentDir)); CurrentDir[_countof(CurrentDir) - 1] = 0; return TRUE; } } // Then, try without converting backslashes to slashes (there may be a name with backslashes) if(dir[0] != '/') //relative path, add CurrentDir first { path = CurrentDir; path += _T("/"); } if(_tcscmp(dir, _T("/"))) path += dir; if(GoToPath(path.c_str())) return TRUE; // Convert \ to / and retry path.clear(); tstring tdir(dir); for(size_t i = 0; i < tdir.size(); i++) if(tdir[i] == '\\') tdir[i] = '/'; if(tdir[0] != '/') //relative path, add CurrentDir first { path = CurrentDir; path += _T("/"); } if(_tcscmp(tdir.c_str(), _T("/"))) path += tdir; return GoToPath(path.c_str()); } //SetDirectory
BOOL UtilLoadDriver( __in LPTSTR szDriverName, __in LPTSTR szDriverFileName, __in LPTSTR szWin32DeviceName, __out HANDLE *pDriver ) /*++ Routine Description: This routine uses the Service Control Manager APIs to create an entry for a standalone driver. It then opens a handle to the driver. The driver is assumed to be in the current directory. NOTE: This routine creates an entry for a standalone driver. If this is modified for use with a driver that requires a Tag, Group, and/or Dependencies, it may be necessary to query the registry for existing driver information (in order to determine a unique Tag, etc.). Arguments: szDriverName - name of the driver (no extension) szDriverFileName - name of driver (with extension) szWin32DeviceName - Name of driver (no extension) prefixed with \\.\ pDriver - pointer to a variable that receives the handle to the driver Return Value: TRUE if driver is loaded successfully. --*/ { BOOL ReturnValue = FALSE; TCHAR* pPathSeparator; TCHAR szDriverPath[MAX_PATH] = _T(""); DWORD dwSize; SC_HANDLE hSCM = NULL; HANDLE hDriver = NULL; // // Construct driver path. // dwSize = GetModuleFileName(NULL, szDriverPath, ARRAY_LENGTH(szDriverPath)); if (dwSize == 0) { ErrorPrint("GetModuleFileName failed, last error 0x%u", GetLastError()); goto Exit; } pPathSeparator = _tcsrchr(szDriverPath, _T('\\')); if (pPathSeparator != NULL) { pPathSeparator[1] = _T('\0'); _tcscat_s(szDriverPath, MAX_PATH, szDriverFileName); } else { ErrorPrint("_tcsrchr failed to file \\ in driver path: %s.", szDriverPath); goto Exit; } // // Get a handle to SCM // hSCM = OpenSCManager ( NULL, NULL, SC_MANAGER_ALL_ACCESS ); if (hSCM == NULL) { ErrorPrint("OpenSCManager failed, last error 0x%x", GetLastError()); goto Exit; } // // First, uninstall and unload the driver. // ReturnValue = UtilUnloadDriver( INVALID_HANDLE_VALUE, hSCM, szDriverName); if (ReturnValue != TRUE) { ErrorPrint("UnloadDriver failed"); goto Exit; } // // Install the driver. // ReturnValue = UtilCreateService(hSCM, szDriverName, szDriverPath); if (ReturnValue == FALSE) { ErrorPrint("UtilCreateService failed"); goto Exit; } // // Load the driver. // ReturnValue = UtilStartService(hSCM, szDriverName); if (ReturnValue == FALSE) { ErrorPrint("UtilStartService failed"); goto Exit; } // // Open a handle to the device. // ReturnValue = UtilOpenDevice(szWin32DeviceName, &hDriver); if (ReturnValue == FALSE) { ErrorPrint("UtilOpenDevice failed"); goto Exit; } *pDriver = hDriver; ReturnValue = TRUE; Exit: if (hSCM != NULL) { CloseServiceHandle(hSCM); } return ReturnValue; }
osd_file::error osd_file::open(std::string const &orig_path, UINT32 openflags, ptr &file, std::uint64_t &filesize) { std::string path; try { osd_subst_env(path, orig_path); } catch (...) { return error::OUT_OF_MEMORY; } if (win_check_socket_path(path)) return win_open_socket(path, openflags, file, filesize); else if (win_check_ptty_path(path)) return win_open_ptty(path, openflags, file, filesize); // convert path to TCHAR TCHAR *t_path = tstring_from_utf8(path.c_str()); osd_disposer<TCHAR> t_path_disposer(t_path); if (!t_path) return error::OUT_OF_MEMORY; // convert the path into something Windows compatible for (TCHAR *src = t_path; *src != 0; src++) *src = /* ('/' == *src) ? '\\' : */ *src; // select the file open modes DWORD disposition, access, sharemode; if (openflags & OPEN_FLAG_WRITE) { disposition = (!is_path_to_physical_drive(path.c_str()) && (openflags & OPEN_FLAG_CREATE)) ? CREATE_ALWAYS : OPEN_EXISTING; access = (openflags & OPEN_FLAG_READ) ? (GENERIC_READ | GENERIC_WRITE) : GENERIC_WRITE; sharemode = FILE_SHARE_READ; } else if (openflags & OPEN_FLAG_READ) { disposition = OPEN_EXISTING; access = GENERIC_READ; sharemode = FILE_SHARE_READ; } else { return error::INVALID_ACCESS; } // attempt to open the file HANDLE h = CreateFile(t_path, access, sharemode, nullptr, disposition, 0, nullptr); if (INVALID_HANDLE_VALUE == h) { DWORD err = GetLastError(); // create the path if necessary if ((ERROR_PATH_NOT_FOUND == err) && (openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS)) { TCHAR *pathsep = _tcsrchr(t_path, '\\'); if (pathsep != nullptr) { // create the path up to the file *pathsep = 0; err = create_path_recursive(t_path); *pathsep = '\\'; // attempt to reopen the file if (err == NO_ERROR) { h = CreateFile(t_path, access, sharemode, nullptr, disposition, 0, nullptr); err = GetLastError(); } } } // if we still failed, clean up and free if (INVALID_HANDLE_VALUE == h) return win_error_to_file_error(err); } // get the file size DWORD upper, lower; lower = GetFileSize(h, &upper); if (INVALID_FILE_SIZE == lower) { DWORD const err = GetLastError(); if (NO_ERROR != err) { CloseHandle(h); return win_error_to_file_error(err); } } try { file = std::make_unique<win_osd_file>(h); filesize = (std::uint64_t(upper) << 32) | lower; return error::NONE; } catch (...) { CloseHandle(h); return error::OUT_OF_MEMORY; } }
void CDownDlg::OnBtnDownLoad(void) { AddInfo(_T("开始下载...")); DWORD dwLen = lstrlen(m_pSign) + lstrlen(m_pFile) * 2 + 20; PTSTR lpURL = new TCHAR[dwLen]; wsprintf(lpURL, _T("download/symbols/%s/%s/%s"), m_pFile, m_pSign, m_pFile); lpURL[dwLen - 2] = _T('_'); // 获取目标文件路径 TCHAR str[MAX_PATH]; GetDlgItemText(IDC_EDIT_FILE, str, MAX_PATH); *(_tcsrchr(str, _T('\\')) + 1) = _T('\0'); LFileDialog dlg(FALSE, _T("*.pdb\0*.pdb\0\0"), _T("*.pdb")); dlg.m_ofn->lpstrInitialDir = str; lstrcpy(dlg.m_szFileName, str); lstrcat(dlg.m_szFileName, m_pFile); if (!dlg.DoModal(m_hWnd)) { AddInfo(_T("下载已取消。")); delete [] lpURL; return; } lstrcat(str, _T("download.tmp")); DOWNERROR ret = m_pDnLdr->DownLoadFile(_T("msdl.microsoft.com"), INTERNET_DEFAULT_HTTP_PORT, lpURL, str); switch (ret) { case DownOK: AddInfo(_T("下载完成。\r\n\r\n")); break; case DownDisconnected: AddInfo(_T("\r\nERROR: 无法连接服务器。\r\n\r\n")); break; case DownFileNotExists: AddInfo(_T("\r\nERROR: 远程文件不存在。\r\n\r\n")); break; case DownCannotOpenFile: AddInfo(_T("\r\nERROR: 无法创建本地文件。\r\n\r\n")); break; } if (DownOK != ret) { delete [] lpURL; return; } // 生成命令行 LPTSTR lpCmd = new TCHAR[32 + lstrlen(str) + lstrlen(dlg.m_szFileName)]; wsprintf(lpCmd, _T("expand.exe \"%s\" \"%s\""), str, dlg.m_szFileName); // 创建通信管道 SECURITY_ATTRIBUTES sa; ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES)); sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = TRUE; HANDLE hReadPipe, hWritePipe; CreatePipe(&hReadPipe, &hWritePipe, &sa, BUF_SIZE); // 创建目标进程 STARTUPINFO sui; ZeroMemory(&sui, sizeof(STARTUPINFO)); sui.cb = sizeof(STARTUPINFO); sui.dwFlags = STARTF_USESTDHANDLES; sui.hStdError = hWritePipe; sui.hStdOutput = hWritePipe; PROCESS_INFORMATION pi; if (CreateProcess(NULL, lpCmd, NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &sui, &pi)) { // 捕获所有进程输出 DWORD dw; PSTR buf = new char[BUF_SIZE]; ZeroMemory(buf, BUF_SIZE); ReadFile(hReadPipe, buf, BUF_SIZE, &dw, NULL); m_edtInfo.SetSelA(-1, -1); m_edtInfo.ReplaceSel(buf); delete [] buf; CloseHandle(pi.hThread); CloseHandle(pi.hProcess); // 删除 download.error 临时文件 DeleteFile(str); EnableDlgItem(IDC_BTN_DOWNLOAD, FALSE); } else { AddInfo(_T("ERROR: 解压文件失败。\r\n\r\n")); } CloseHandle(hWritePipe); CloseHandle(hReadPipe); delete [] lpCmd; delete [] lpURL; }
static void GetList(void *) { char szKey[64] = {0}; TCHAR tszTempPath[MAX_PATH]; DWORD dwLen = GetTempPath(SIZEOF(tszTempPath), tszTempPath); if (tszTempPath[dwLen-1] == '\\') tszTempPath[dwLen-1] = 0; ptrT updateUrl( GetDefaultUrl()), baseUrl; SERVLIST hashes(50, CompareHashes); if (!ParseHashes(updateUrl, baseUrl, hashes)) { hListThread = NULL; return; } FILELIST *UpdateFiles = new FILELIST(20); TCHAR *dirname = Utils_ReplaceVarsT(_T("%miranda_path%")); for (int i=0; i < hashes.getCount(); i++) { ServListEntry &hash = hashes[i]; TCHAR tszPath[MAX_PATH]; mir_sntprintf(tszPath, SIZEOF(tszPath), _T("%s\\%s"), dirname, hash.m_name); if (GetFileAttributes(tszPath) != DWORD(-1)) continue; FILEINFO *FileInfo = new FILEINFO; FileInfo->bDeleteOnly = FALSE; _tcscpy(FileInfo->tszOldName, hash.m_name); // copy the relative old name _tcscpy(FileInfo->tszNewName, hash.m_name); TCHAR tszFileName[MAX_PATH]; _tcscpy(tszFileName, _tcsrchr(tszPath, L'\\') + 1); TCHAR *tp = _tcschr(tszFileName, L'.'); *tp = 0; TCHAR tszRelFileName[MAX_PATH]; _tcscpy(tszRelFileName, hash.m_name); tp = _tcsrchr(tszRelFileName, L'.'); if (tp) *tp = 0; tp = _tcschr(tszRelFileName, L'\\'); if (tp) tp++; else tp = tszRelFileName; _tcslwr(tp); mir_sntprintf(FileInfo->File.tszDiskPath, SIZEOF(FileInfo->File.tszDiskPath), _T("%s\\Temp\\%s.zip"), tszRoot, tszFileName); mir_sntprintf(FileInfo->File.tszDownloadURL, SIZEOF(FileInfo->File.tszDownloadURL), _T("%s/%s.zip"), baseUrl, tszRelFileName); for (tp = _tcschr(FileInfo->File.tszDownloadURL, '\\'); tp != 0; tp = _tcschr(tp, '\\')) *tp++ = '/'; FileInfo->File.CRCsum = hash.m_crc; UpdateFiles->insert(FileInfo); } mir_free(dirname); // Show dialog if (UpdateFiles->getCount() == 0) { if (!opts.bSilent) ShowPopup(0, LPGENT("Plugin Updater"), LPGENT("List is empty."), 2, 0); delete UpdateFiles; } else CallFunctionAsync(LaunchListDialog, UpdateFiles); hListThread = NULL; }
BOOL CTaskbarNotifier::LoadConfiguration(LPCTSTR pszFilePath) { struct _stat st; st.st_mtime = -1; // '-1' = missing file (void)_tstat(pszFilePath, &st); if ( m_strConfigFilePath.CompareNoCase(pszFilePath) == 0 && st.st_mtime == m_tConfigFileLastModified) return TRUE; TCHAR szConfigDir[MAX_PATH]; int iTextNormalRed, iTextNormalGreen, iTextNormalBlue; int iTextSelectedRed, iTextSelectedGreen, iTextSelectedBlue; int iLeft, iTop, iRight, iBottom; int iBmpTransparentRed, iBmpTransparentGreen, iBmpTransparentBlue; int iFontSize; CString strFontType, strBmpFilePath, strBmpFileName; Hide(); m_strConfigFilePath = pszFilePath; CIni ini(pszFilePath, _T("Config")); _tcsncpy(szConfigDir, pszFilePath, _countof(szConfigDir)); szConfigDir[_countof(szConfigDir)-1] = _T('\0'); LPTSTR pszFileName = _tcsrchr(szConfigDir, _T('\\')); if (pszFileName == NULL) return FALSE; *(pszFileName + 1) = _T('\0'); iTextNormalRed = ini.GetInt(_T("TextNormalRed"), 255); iTextNormalGreen = ini.GetInt(_T("TextNormalGreen"), 255); iTextNormalBlue = ini.GetInt(_T("TextNormalBlue"), 255); iTextSelectedRed = ini.GetInt(_T("TextSelectedRed"), 255); iTextSelectedGreen = ini.GetInt(_T("TextSelectedGreen"), 255); iTextSelectedBlue = ini.GetInt(_T("TextSelectedBlue"), 255); // for backward compatibility read the old values (which had a typo) and then the new values iBmpTransparentRed = ini.GetInt(_T("BmpTrasparentRed"), 255); iBmpTransparentRed = ini.GetInt(_T("BmpTransparentRed"), iBmpTransparentRed); iBmpTransparentGreen = ini.GetInt(_T("BmpTrasparentGreen"), 0); iBmpTransparentGreen = ini.GetInt(_T("BmpTransparentGreen"), iBmpTransparentGreen); iBmpTransparentBlue = ini.GetInt(_T("BmpTrasparentBlue"), 255); iBmpTransparentBlue = ini.GetInt(_T("BmpTransparentBlue"), iBmpTransparentBlue); strFontType = ini.GetString(_T("FontType"), _T("MS Shell Dlg")); iFontSize = ini.GetInt(_T("FontSize"), 8) * 10; m_dwTimeToStay = ini.GetInt(_T("TimeToStay"), 4000); m_dwTimeToShow = ini.GetInt(_T("TimeToShow"), 500); m_dwTimeToHide = ini.GetInt(_T("TimeToHide"), 200); strBmpFileName = ini.GetString(_T("BmpFileName"), _T("")); if (!strBmpFileName.IsEmpty()) { if (PathIsRelative(strBmpFileName)) strBmpFilePath.Format(_T("%s%s"), szConfigDir, strBmpFileName); else strBmpFilePath = strBmpFileName; } // get text rectangle coordinates iLeft = ini.GetInt(_T("rcTextLeft"), 5); iTop = ini.GetInt(_T("rcTextTop"), 45); iRight = ini.GetInt(_T("rcTextRight"), 220); iBottom = ini.GetInt(_T("rcTextBottom"), 85); if (iLeft <= 0) iLeft = 1; if (iTop <= 0) iTop = 1; if (iRight <= 0) iRight = 1; if (iBottom <= 0) iBottom = 1; SetTextRect(CRect(iLeft, iTop, iRight, iBottom)); // get close button rectangle coordinates iLeft = ini.GetInt(_T("rcCloseBtnLeft"), 286); iTop = ini.GetInt(_T("rcCloseBtnTop"), 40); iRight = ini.GetInt(_T("rcCloseBtnRight"), 300); iBottom = ini.GetInt(_T("rcCloseBtnBottom"), 54); if (iLeft <= 0) iLeft = 1; if (iTop <= 0) iTop = 1; if (iRight <= 0) iRight = 1; if (iBottom <= 0) iBottom = 1; SetCloseBtnRect(CRect(iLeft, iTop, iRight, iBottom)); // get history button rectangle coordinates iLeft = ini.GetInt(_T("rcHistoryBtnLeft"), 283); iTop = ini.GetInt(_T("rcHistoryBtnTop"), 14); iRight = ini.GetInt(_T("rcHistoryBtnRight"), 299); iBottom = ini.GetInt(_T("rcHistoryBtnBottom"), 39); if (iLeft <= 0) iLeft = 1; if (iTop <= 0) iTop = 1; if (iRight <= 0) iRight = 1; if (iBottom <= 0) iBottom = 1; SetHistoryBtnRect(CRect(iLeft, iTop, iRight, iBottom)); if (strBmpFilePath.IsEmpty() || !SetBitmap(strBmpFilePath, iBmpTransparentRed, iBmpTransparentGreen, iBmpTransparentBlue)) { CEnBitmap imgTaskbar; if (imgTaskbar.LoadImage(IDR_TASKBAR, _T("GIF"))) { if (!SetBitmap(&imgTaskbar, iBmpTransparentRed, iBmpTransparentGreen, iBmpTransparentBlue)) return FALSE; } } SetTextFont(strFontType, iFontSize, TN_TEXT_NORMAL, TN_TEXT_UNDERLINE); SetTextColor(RGB(iTextNormalRed, iTextNormalGreen, iTextNormalBlue), RGB(iTextSelectedRed, iTextSelectedGreen, iTextSelectedBlue)); m_tConfigFileLastModified = st.st_mtime; return TRUE; }