HINSTANCE CHyperLink::GotoURL(LPCTSTR url, int showcmd) { TCHAR key[MAX_PATH + MAX_PATH]; // First try ShellExecute() HINSTANCE result = ShellExecute(NULL, _T("open"), url, NULL,NULL, showcmd); // If it failed, get the .htm regkey and lookup the program if ((UINT)result <= HINSTANCE_ERROR) { if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) { lstrcat(key, _T("\\shell\\open\\command")); if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) { TCHAR *pos; pos = _tcsstr(key, _T("\"%1\"")); if (pos == NULL) { // No quotes found pos = strstr(key, _T("%1")); // Check for %1, without quotes if (pos == NULL) // No parameter at all... pos = key+lstrlen(key)-1; else *pos = '\0'; // Remove the parameter } else *pos = '\0'; // Remove the parameter lstrcat(pos, _T(" ")); lstrcat(pos, url); result = (HINSTANCE) WinExec(key,showcmd); } } } return result; }
void GoHomepage() { LPCTSTR url = MSG_HOMEPAGE; int showcmd = SW_SHOW; char key[MAX_PATH + MAX_PATH]; // First try ShellExecute() HINSTANCE result = ShellExecute(NULL, "open", url, NULL,NULL, showcmd); // If it failed, get the .htm regkey and lookup the program if ((UINT)result <= HINSTANCE_ERROR) { if (GetRegKey(HKEY_CLASSES_ROOT, ".htm", key) == ERROR_SUCCESS) { lstrcat(key, "\\shell\\open\\command"); if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) { char *pos; pos = strstr(key, "\"%1\""); if (pos == NULL) { // No quotes found pos = strstr(key, "%1"); // Check for %1, without quotes if (pos == NULL) // No parameter at all... pos = key+lstrlen(key)-1; else *pos = '\0'; // Remove the parameter }else *pos = '\0'; // Remove the parameter lstrcat(pos, " "); lstrcat(pos, url); result = (HINSTANCE) WinExec(key,showcmd); } } } }
int GetRegKey(const char *Key,const char *ValueName,char *ValueData,const char *Default,DWORD DataSize) { int Ret; if(0==(Ret=GetRegKey(HKEY_CURRENT_USER, Key,ValueName,ValueData,Default,DataSize))) Ret=GetRegKey(HKEY_LOCAL_MACHINE,Key,ValueName,ValueData,Default,DataSize); return Ret; }
/////////////////////////////////////////////////////////////////////////////// // GoToURL BOOL CXHTMLStatic::GotoURL(LPCTSTR url, int showcmd) { BOOL bRet = FALSE; ASSERT(url); ASSERT(url[0] != _T('\0')); TCHAR key[MAX_PATH * 2]; // check if this is "app:" protocol int nAppSize = 0; if (_tcsnicmp(url, _T("APP:"), 4) == 0) nAppSize = 4; else if (_tcsnicmp(url, _T("\"APP:"), 5) == 0) nAppSize = 5; if (nAppSize) { bRet = ProcessAppCommand(&url[nAppSize]); } else { // not "app" - assume http: or mailto: // First try ShellExecute() HINSTANCE result = ::ShellExecute(NULL, _T("open"), url, NULL,NULL, showcmd); // If it failed, get the .htm regkey and lookup the program if ((UINT)result <= HINSTANCE_ERROR) { if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) { _tcscat(key, _T("\\shell\\open\\command")); if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) { TCHAR *pos; pos = _tcsstr(key, _T("\"%1\"")); if (pos == NULL) { // No quotes found pos = _tcsstr(key, _T("%1")); // Check for %1, without quotes if (pos == NULL) // No parameter at all... pos = key+lstrlen(key)-1; else *pos = _T('\0'); // Remove the parameter } else *pos = _T('\0'); // Remove the parameter _tcscat(pos, _T(" ")); _tcscat(pos, url); result = (HINSTANCE) WinExec((LPSTR)key,showcmd); } } } bRet = result > (HINSTANCE) HINSTANCE_ERROR; } return bRet; }
int WINAPI _export Start(const struct PluginStartupInfo *FarInfo,const struct AHPluginStartupInfo *AHInfo) { Info=*FarInfo; FSF=*FarInfo->FSF; ::AHInfo=*AHInfo; FSF.sprintf(PluginRootKey,"%s\\%s",AHInfo->RootKey,"MS-Help2"); GetRegKey("PathToViewer",PathToViewer,"H2Viewer.exe",sizeof(PathToViewer)); GetRegKey("OpenContents",OpenContents,"/appid \"%f\" /helpcol \"%f\"",sizeof(OpenContents)); GetRegKey("KeywordSearch",KeywordSearch,"/appid \"%f\" /helpcol \"%f\" /index \"%k\"",sizeof(KeywordSearch)); return 0; }
void WINAPI _export SetStartupInfo(const struct PluginStartupInfo *psi) { Info = *psi; FSF = *psi->FSF; Info.FSF = &FSF; FSF.sprintf(PluginRootKey,"%s\\CharacterMap",Info.RootKey); GetRegKey(®[REG_EDITORAUTOPOS],&EditorAutoPos,1); GetRegKey(®[REG_CMDAUTOPOS],&CmdAutoPos,1); GetRegKey(®[REG_COPYTOCLIPBOARD],&CopyToClipboard,0); GetRegKey(®[REG_ENCODEBEFOREINSERTION],&EncodeBeforeInsertion,1); GetRegKey(®[REG_PRELOAD],&Preload,0); }
int WINAPI _export Start(const struct PluginStartupInfo *FarInfo,const struct AHPluginStartupInfo *AHInfo) { Info=*FarInfo; FSF=*FarInfo->FSF; ::AHInfo=*AHInfo; FSF.sprintf(PluginRootKey,"%s\\%s",AHInfo->RootKey,"Custom"); GetRegKey("Modality",&Modality,0); Modality %= 2; GetRegKey("Visuality",&Visuality,0); Visuality %= 2; return 0; }
/////////////////////////////////////////////////////////////////////////////// // GotoURL HINSTANCE CXHyperLink::GotoURL(LPCTSTR url, int showcmd, BOOL bAlwaysOpenNew /*= FALSE*/) { // if no url then this is not an internet link if (!url || url[0] == _T('\0')) return (HINSTANCE) HINSTANCE_ERROR + 1; TCHAR key[MAX_PATH*2]; // First try ShellExecute() TCHAR *verb = _T("open"); if (bAlwaysOpenNew) verb = _T("new"); HINSTANCE result = ShellExecute(NULL, verb, url, NULL,NULL, showcmd); // If it failed, get the .htm regkey and lookup the program if (result <= (HINSTANCE)HINSTANCE_ERROR) { if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) { _tcscat(key, _T("\\shell\\open\\command")); if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) { TCHAR *pos; pos = _tcsstr(key, _T("\"%1\"")); if (pos == NULL) { // No quotes found pos = _tcsstr(key, _T("%1")); // Check for %1, without quotes if (pos == NULL) // No parameter at all... pos = key + _tcslen(key)-1; else *pos = _T('\0'); // Remove the parameter } else { *pos = _T('\0'); // Remove the parameter } _tcscat(pos, _T(" ")); _tcscat(pos, url); USES_CONVERSION; result = (HINSTANCE) (UINT_PTR) WinExec(T2A(key),showcmd); } } } return result; }
//************************************ // Method: CAutoStartupInfo // FullName: CAutoStartupInfo::CAutoStartupInfo // Access: public // Returns: // Qualifier: : m_hLocalMachineAutostartupKey( 0 )*/, m_hCurrentUserAutostartupKey( 0 ) //************************************ CAutoStartupInfo::CAutoStartupInfo() : m_hLocalMachineAutostartupKey( 0 ), m_hCurrentUserAutostartupKey( 0 ) { // Reserve space for at least 30 entries m_AutoStartups.reserve( 30 ); LPCTSTR lpctszAutorunKeyPath = _T( "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\\" ); m_hLocalMachineAutostartupKey = GetRegKey( HKEY_LOCAL_MACHINE, lpctszAutorunKeyPath ); ASSERT( m_hLocalMachineAutostartupKey ); m_hCurrentUserAutostartupKey = GetRegKey( HKEY_CURRENT_USER, lpctszAutorunKeyPath ); ASSERT( m_hCurrentUserAutostartupKey ); }
// the sub-class can call this method to fill out a combo box with the values stored in // the recently used list. void CAutoConfigDlg::EnumRecentlyUsed(CComboBox& cbRecentlyUsed) { cbRecentlyUsed.Clear(); CRegKey keyRecentConverterIDs; CString strRegKey = GetRegKey(); if( keyRecentConverterIDs.Open(HKEY_CURRENT_USER, strRegKey) == ERROR_SUCCESS ) { DWORD dwIndex = 0; BOOL bStop = false; do { DWORD dwValueType = 0, cbName = _MAX_PATH; TCHAR lpName[_MAX_PATH]; lpName[0] = 0; LONG lVal = RegEnumValue(keyRecentConverterIDs,dwIndex++,lpName,&cbName,0,&dwValueType,0,0); if( (lVal == ERROR_SUCCESS) || (lVal == ERROR_MORE_DATA) ) { // skip the default value if( _tcslen(lpName) > 0 ) { TRACE(_T("Found: (%s)"), lpName); if( cbRecentlyUsed.FindStringExact(0,lpName) < 0 ) cbRecentlyUsed.AddString(lpName); } } else bStop = true; } while( !bStop ); // select the first one so there's something in it. cbRecentlyUsed.SetCurSel(0); } }
/* Инициализация системозависимой сортировки строк. Вызывать только после CopyGlobalSettings (потому что только тогда GetRegKey считает правильные данные) и перед InitKeysArray (потому что там уже используется сортировка)! */ void InitLCIDSort() { unsigned char LCSortBuffer[256]; for (size_t i=0; i<ARRAYSIZE(LCSortBuffer); i++) { LCSortBuffer[i]=static_cast<BYTE>(i); } Opt.LCIDSort=GetRegKey(L"System",L"LCID",LOCALE_USER_DEFAULT); far_qsort(LCSortBuffer,256,sizeof(LCSortBuffer[0]),LCSort); for (size_t i=0; i<ARRAYSIZE(LCSortBuffer); i++) { LCOrder[LCSortBuffer[i]]=static_cast<BYTE>(i); } LCOrder[0]=0; LCOrder[(unsigned)'\\']=1; LCOrder[(unsigned)'.']=2; for (size_t i=0; i<ARRAYSIZE(LCSortBuffer)-1; i++) { if (!LCSort(&LCSortBuffer[i],&LCSortBuffer[i+1])) { LCOrder[LCSortBuffer[i+1]]=LCOrder[LCSortBuffer[i]]; } } for (size_t i=0; i<ARRAYSIZE(LCOrder); i++) { LCOrder[i]=LCOrder[UpperToLower[i]]; } }
Shortcuts::Shortcuts() { HKEY hNewKey = OpenRegKey(FolderShortcutsKeyTest); if (hNewKey == NULL) { for(size_t i = 0; i < KeyCount; i++) { FormatString ValueName; ValueName << RecTypeName[PSCR_RT_SHORTCUT] << i; string strValue; if(!GetRegKey(OldFolderShortcutsKey, ValueName, strValue, L"")) continue; ValueName.Clear(); ShortcutItem* Item = Items[i].Push(); Item->strFolder = strValue; ValueName << RecTypeName[PSCR_RT_PLUGINMODULE] << i; GetRegKey(OldFolderShortcutsKey, ValueName, Item->strPluginModule, L""); ValueName.Clear(); ValueName << RecTypeName[PSCR_RT_PLUGINFILE] << i; GetRegKey(OldFolderShortcutsKey, ValueName, Item->strPluginFile, L""); ValueName.Clear(); ValueName << RecTypeName[PSCR_RT_PLUGINDATA] << i; GetRegKey(OldFolderShortcutsKey, ValueName, Item->strPluginData, L""); ValueName.Clear(); } return; } for(size_t i = 0; i < KeyCount; i++) { FormatString strFolderShortcuts; strFolderShortcuts << FolderShortcutsKey << i; if (!CheckRegKey(strFolderShortcuts)) continue; for(size_t j=0; ; j++) { FormatString ValueName; ValueName << RecTypeName[PSCR_RT_SHORTCUT] << j; string strValue; if(!GetRegKey(strFolderShortcuts, ValueName, strValue, L"")) break; ValueName.Clear(); ShortcutItem* Item = Items[i].Push(); Item->strFolder = strValue; ValueName << RecTypeName[PSCR_RT_PLUGINMODULE] << j; GetRegKey(strFolderShortcuts, ValueName, Item->strPluginModule, L""); ValueName.Clear(); ValueName << RecTypeName[PSCR_RT_PLUGINFILE] << j; GetRegKey(strFolderShortcuts, ValueName, Item->strPluginFile, L""); ValueName.Clear(); ValueName << RecTypeName[PSCR_RT_PLUGINDATA] << j; GetRegKey(strFolderShortcuts, ValueName, Item->strPluginData, L""); ValueName.Clear(); } } }
static int FillFileTypesMenu(VMenu *TypesMenu,int MenuPos) { int DizWidth=GetDescriptionWidth(); MenuItemEx TypesMenuItem; TypesMenu->DeleteItems(); int NumLine=0; for (;; NumLine++) { string strRegKey; strRegKey.Format(FTS.TypeFmt,NumLine); TypesMenuItem.Clear(); string strMask; if (!GetRegKey(strRegKey,FTS.Mask,strMask,L"")) { break; } string strMenuText; if (DizWidth) { string strDescription; GetRegKey(strRegKey,FTS.Desc,strDescription,L""); string strTitle=strDescription; size_t Pos=0; bool Ampersand=strTitle.Pos(Pos,L'&'); if (DizWidth+Ampersand > ScrX/2 && Ampersand && static_cast<int>(Pos) > DizWidth) Ampersand=false; strMenuText.Format(L"%-*.*s %c ",DizWidth+Ampersand,DizWidth+Ampersand,strTitle.CPtr(),BoxSymbols[BS_V1]); } //TruncStr(strMask,ScrX-DizWidth-14); strMenuText += strMask; TypesMenuItem.strName = strMenuText; TypesMenuItem.SetSelect(NumLine==MenuPos); TypesMenu->AddItem(&TypesMenuItem); } TypesMenuItem.strName.Clear(); TypesMenuItem.SetSelect(NumLine==MenuPos); TypesMenu->AddItem(&TypesMenuItem); return NumLine; }
// called by the base class to remember a good converter identifier. void CAutoConfigDlg::AddToRecentlyUsed(const CString& strRecentlyUsed) { CRegKey keyRecentConverterIDs; CString strRegKey = GetRegKey(); if( keyRecentConverterIDs.Create(HKEY_CURRENT_USER, strRegKey) == ERROR_SUCCESS ) { keyRecentConverterIDs.SetStringValue(strRecentlyUsed, _T("")); } }
void CAutoConfigDlg::RemFromRecentlyUsed(const CString& strRecentlyUsed) { CRegKey keyRecentConverterIDs; CString strRegKey = GetRegKey(); if( keyRecentConverterIDs.Open(HKEY_CURRENT_USER, strRegKey) == ERROR_SUCCESS ) { keyRecentConverterIDs.DeleteValue(strRecentlyUsed); } }
int GetDescriptionWidth(const wchar_t *Name=nullptr,const wchar_t *ShortName=nullptr) { int Width=0; RenumKeyRecord(FTS.Associations,FTS.TypeFmt,FTS.Type0); for (int NumLine=0;; NumLine++) { string strRegKey; strRegKey.Format(FTS.TypeFmt, NumLine); string strMask; if (!GetRegKey(strRegKey,FTS.Mask, strMask, L"")) break; CFileMask FMask; if (!FMask.Set(strMask, FMF_SILENT)) continue; string strDescription; GetRegKey(strRegKey,FTS.Desc,strDescription,L""); int CurWidth; if (!Name) CurWidth = HiStrlen(strDescription); else { if (!FMask.Compare(Name)) continue; string strExpandedDesc = strDescription; SubstFileName(strExpandedDesc,Name,ShortName,nullptr,nullptr,nullptr,nullptr,TRUE); CurWidth = HiStrlen(strExpandedDesc); } if (CurWidth>Width) Width=CurWidth; } if (Width>ScrX/2) Width=ScrX/2; return(Width); }
// "GotoURL" function by Stuart Patterson // As seen in the August, 1997 Windows Developer's Journal. HINSTANCE CHyperLink::GotoURL( zCPCHAR cpcURL, int nShowCmd ) { TCHAR pchKey[ MAX_PATH + MAX_PATH ]; // First try ShellExecute( ). HINSTANCE hInst = ShellExecute( 0, _T( "open" ), cpcURL, 0, 0, nShowCmd ); // If it failed, get the .htm regkey and lookup the program. if ( (UINT) hInst <= HINSTANCE_ERROR ) { if ( GetRegKey( HKEY_CLASSES_ROOT, _T( ".htm" ), pchKey ) == ERROR_SUCCESS ) { strcat_s( pchKey, _T( "\\shell\\open\\command" ) ); if ( GetRegKey( HKEY_CLASSES_ROOT, pchKey, pchKey ) == ERROR_SUCCESS ) { TCHAR *pos; pos = _tcsstr( pchKey, _T( "\"%1\"" ) ); if ( pos == 0 ) { // No quotes found pos = zstrstr( pchKey, _T( "%1" ) ); // check for %1 without quotes if ( pos == 0 ) // no parameter at all ... pos = pchKey + zstrlen( pchKey ) - 1; else *pos = 0; // remove the parameter } else *pos = 0; // remove the parameter strcat_s( pos, MAX_PATH + MAX_PATH - (pos - pchKey), _T( " " ) ); strcat_s( pos, MAX_PATH + MAX_PATH - (pos - pchKey), cpcURL ); hInst = (HINSTANCE) WinExec( pchKey, nShowCmd ); } } } return( hInst ); }
SHAREDSYMBOL void WINAPI EXP_NAME(SetStartupInfo)(const struct PluginStartupInfo *Info) { ::Info=*Info; ::FSF=*Info->FSF; ::Info.FSF=&::FSF; FSF.snprintf(PluginRootKey, ARRAYSIZE(PluginRootKey), _T("%s/EditCase"),Info->RootKey); WordDivLen=(int)::Info.AdvControl(::Info.ModuleNumber, ACTL_GETSYSWORDDIV, WordDiv); TCHAR AddWordDiv[sizeof(WordDiv)]; GetRegKey(HKEY_CURRENT_USER,_T(""),_T("AddWordDiv"),AddWordDiv,_T("#"),sizeof(AddWordDiv)); WordDivLen += lstrlen(AddWordDiv); lstrcat(WordDiv, AddWordDiv); WordDivLen += sizeof(_T(" \n\r\t")); lstrcat(WordDiv, _T(" \n\r\t")); }
BOOL CXHyperLink::GotoURL(LPCTSTR url, int showcmd) { TCHAR key[MAX_PATH + MAX_PATH]; // First try ShellExecute() m_nErrorCode = (LONG)ShellExecute(NULL, _T("open"), url, NULL, NULL, showcmd); // If it failed, get the .htm regkey and lookup the program if ((UINT)m_nErrorCode <= HINSTANCE_ERROR) { if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) { lstrcat(key, _T("\\shell\\open\\command")); if (GetRegKey(HKEY_CLASSES_ROOT, key, key) == ERROR_SUCCESS) { TCHAR *pos; pos = _tcsstr(key, _T("\"%1\"")); if (pos == NULL) { // No quotes found pos = _tcsstr(key, _T("%1")); // Check for %1, without quotes if (pos == NULL) // No parameter at all... pos = key+_tcslen(key)-1; else *pos = _T('\0'); // Remove the parameter } else *pos = _T('\0'); // Remove the parameter lstrcat(pos, _T(" ")); lstrcat(pos, url); LPSTR lpszBuffer = TCharToChar(key); m_nErrorCode = WinExec(lpszBuffer, showcmd); XMemFree((void**)&lpszBuffer); } } } return m_nErrorCode > HINSTANCE_ERROR; }
HINSTANCE CHLink::GotoURL(LPCTSTR url, int showcmd) { TCHAR key[MAX_PATH + MAX_PATH]; HINSTANCE result = ShellExecute(NULL, _T("open"), url, NULL,NULL, showcmd); if ((UINT)result <= HINSTANCE_ERROR) { if (GetRegKey(HKEY_CLASSES_ROOT, _T(".htm"), key) == ERROR_SUCCESS) { lstrcat(key, _T("\shell\open\command")); if (GetRegKey(HKEY_CLASSES_ROOT,key,key) == ERROR_SUCCESS) { TCHAR *pos; pos = _tcsstr(key, _T("%1")); if (pos == NULL) { pos = strstr(key, _T("%1")); if (pos == NULL) pos = key+lstrlen(key)-1; else *pos = '0'; } else *pos = '0'; // Remove the parameter lstrcat(pos, _T(" ")); lstrcat(pos, url); result = (HINSTANCE) WinExec(key,showcmd); } } }
bool GotoURL( RString sUrl ) { // First try ShellExecute() int iRet = (int) ShellExecute( NULL, "open", sUrl, NULL, NULL, SW_SHOWDEFAULT ); // If it failed, get the .htm regkey and lookup the program if( iRet > 32 ) return true; char key[2*MAX_PATH]; if( GetRegKey(HKEY_CLASSES_ROOT, ".htm", key) != ERROR_SUCCESS ) return false; strcpy( key, "\\shell\\open\\command" ); if( GetRegKey(HKEY_CLASSES_ROOT, key, key) != ERROR_SUCCESS ) return false; char *szPos = strstr( key, "\"%1\"" ); if( szPos == NULL ) { // No quotes found. Check for %1 without quotes szPos = strstr( key, "%1" ); if( szPos == NULL ) szPos = key+lstrlen(key)-1; // No parameter. else *szPos = '\0'; // Remove the parameter } else *szPos = '\0'; // Remove the parameter strcat( szPos, " " ); strcat( szPos, sUrl ); return WinExec( key, SW_SHOWDEFAULT ) > 32; }
// Форматируем имя таблицы символов wchar_t *FormatCodePageName(UINT CodePage, wchar_t *CodePageName, size_t Length, bool &IsCodePageNameCustom) { if (!CodePageName || !Length) return CodePageName; // Пытаемся получить заданное пользоваталем имя таблицы символов FormatString strCodePage; strCodePage<<CodePage; FARString strCodePageName; if (GetRegKey(NamesOfCodePagesKey, strCodePage, strCodePageName, L"")) { Length = Min(Length-1, strCodePageName.GetLength()); IsCodePageNameCustom = true; } else IsCodePageNameCustom = false; if (*CodePageName) { // Под виндой на входе "XXXX (Name)", а, например, под wine просто "Name" wchar_t *Name = wcschr(CodePageName, L'('); if (Name && *(++Name)) { size_t NameLength = wcslen(Name)-1; if (Name[NameLength] == L')') { Name[NameLength] = L'\0'; } } if (IsCodePageNameCustom) { if (strCodePageName==Name) { DeleteRegValue(NamesOfCodePagesKey, strCodePage); IsCodePageNameCustom = false; return Name ? Name : CodePageName; } } else return Name ? Name : CodePageName; } if (IsCodePageNameCustom) { wmemcpy(CodePageName, strCodePageName, Length); CodePageName[Length] = L'\0'; } return CodePageName; }
// Добавляем стандартную таблицу символов void AddStandardCodePage(const wchar_t *codePageName, UINT codePage, int position = -1, bool enabled = true) { bool checked = false; if (selectedCodePages && codePage!=CP_AUTODETECT) { FormatString strCodePageName; strCodePageName<<codePage; int selectType = 0; GetRegKey(FavoriteCodePagesKey, strCodePageName, selectType, 0); if (selectType & CPST_FIND) checked = true; } AddCodePage(codePageName, codePage, position, enabled, checked, false); }
bool DeleteTypeRecord(int DeletePos) { bool Result=false; string strRecText, strRegKey; strRegKey.Format(FTS.TypeFmt,DeletePos); GetRegKey(strRegKey,FTS.Mask,strRecText,L""); string strItemName=strRecText; InsertQuote(strItemName); if (!Message(MSG_WARNING,2,MSG(MAssocTitle),MSG(MAskDelAssoc),strItemName,MSG(MDelete),MSG(MCancel))) { DeleteKeyRecord(FTS.TypeFmt,DeletePos); Result=true; } return Result; }
/* $ 03.08.2000 SVS ! Не срабатывал шаблон поиска файлов для под-юзеров */ void CopyGlobalSettings() { if (CheckRegKey(L"")) // при существующем - вываливаемся return; // такого извера нету - перенесем данные! SetRegRootKey(HKEY_LOCAL_MACHINE); CopyKeyTree(L"Software/Far2",Opt.strRegRoot,L"Software/Far2/Users\0"); SetRegRootKey(HKEY_CURRENT_USER); CopyKeyTree(L"Software/Far2",Opt.strRegRoot,L"Software/Far2/Users/Software/Far2/PluginsCache\0"); // "Вспомним" путь по шаблону!!! SetRegRootKey(HKEY_LOCAL_MACHINE); GetRegKey(L"System",L"TemplatePluginsPath",Opt.LoadPlug.strPersonalPluginsPath,L""); // удалим!!! DeleteRegKey(L"System"); // запишем новое значение! SetRegRootKey(HKEY_CURRENT_USER); SetRegKey(L"System",L"PersonalPluginsPath",Opt.LoadPlug.strPersonalPluginsPath); }
int GetRegKey(HKEY hRoot,const char *Key,const char *ValueName,DWORD Default) { int ValueData; GetRegKey(hRoot,Key,ValueName,ValueData,Default); return ValueData; }
// получить данные типа DWORD int GetRegKey(HKEY hRoot,TCHAR *Key,TCHAR *ValueName,DWORD Default) { int ValueData; GetRegKey(hRoot,Key,ValueName,ValueData,Default); return(ValueData); }
void FileList::ReadPanelModes() { for (int I=0; I<10; I++) { string strColumnTitles, strColumnWidths; string strStatusColumnTitles, strStatusColumnWidths, strRegKey; strRegKey.Format(L"Panel\\ViewModes\\Mode%d",I); GetRegKey(strRegKey,L"Columns",strColumnTitles,L""); GetRegKey(strRegKey,L"ColumnWidths",strColumnWidths,L""); GetRegKey(strRegKey,L"StatusColumns",strStatusColumnTitles,L""); GetRegKey(strRegKey,L"StatusColumnWidths",strStatusColumnWidths,L""); if (strColumnTitles.IsEmpty() || strColumnWidths.IsEmpty()) continue; PanelViewSettings NewSettings=ViewSettingsArray[VIEW_0+I]; if (!strColumnTitles.IsEmpty()) TextToViewSettings(strColumnTitles,strColumnWidths,FALSE,NewSettings.ColumnType, NewSettings.ColumnWidth,NewSettings.ColumnWidthType,NewSettings.ColumnCount); if (!strStatusColumnTitles.IsEmpty()) TextToViewSettings(strStatusColumnTitles,strStatusColumnWidths,TRUE,NewSettings.StatusColumnType, NewSettings.StatusColumnWidth,NewSettings.StatusColumnWidthType,NewSettings.StatusColumnCount); GetRegKey(strRegKey,L"FullScreen",NewSettings.FullScreen,0); GetRegKey(strRegKey,L"AlignExtensions",NewSettings.AlignExtensions,1); GetRegKey(strRegKey,L"FolderAlignExtensions",NewSettings.FolderAlignExtensions,0); GetRegKey(strRegKey,L"FolderUpperCase",NewSettings.FolderUpperCase,0); GetRegKey(strRegKey,L"FileLowerCase",NewSettings.FileLowerCase,0); GetRegKey(strRegKey,L"FileUpperToLowerCase",NewSettings.FileUpperToLowerCase,0); GetRegKey(strRegKey,L"PreloadC0Data",NewSettings.PreloadC0Data,0); ViewSettingsArray[VIEW_0+I]=NewSettings; } }
long WINAPI MyDialog(HANDLE hDlg,int Msg,int Param1,long Param2) { static int POpenFrom; static unsigned char *Str; static int *Ret; static COORD coord; static int LastSelectedMenu; static struct FarMenuItem *MenuItems; static int TotalMenuItems; static int TargetTable; static struct CharTableSet cts; static struct TableStruct newtable; static struct FarDialogItem DlgASCII, DlgText, DlgEdit, DlgInfo; static CHAR_INFO VBufASCII[256]; static const unsigned char *InfoFormat; static BOOL EditMode; static int EditInsertMode; static char CharTxt[4]; static int CharTxtPos; static char example[MAX_PATH]; unsigned char Temp[51]; static int EditLen; static unsigned char EditText[512]; int tmplen; unsigned char tmptext[512]; char *Cmd; static struct EditorInfo ei; struct FarList *fl; struct EditorConvertText ect; struct EditorGetString egs; struct EditorSetString ess; struct EditorSetPosition esp; WORD Color; int i; switch (Msg) { case DN_INITDIALOG: EditMode = FALSE; EditLen = 0; POpenFrom = ((struct DialogData *)Param2)->OpenFrom; Str = ((struct DialogData *)Param2)->Str; Ret = ((struct DialogData *)Param2)->Ret; MenuItems = NULL; GetRegKey(®[REG_LASTCOORDX],(int *)&coord.X,0); GetRegKey(®[REG_LASTCOORDY],(int *)&coord.Y,0); for (i=0; GetCharTable(i,&cts) != -1; i++) { MenuItems=(struct FarMenuItem *)realloc(MenuItems,(i+1)*sizeof(struct FarMenuItem)); if (!MenuItems) { Warning(MMemoryError); Info.SendDlgMessage(hDlg,DM_CLOSE,0,0); return FALSE; } lstrcpy(MenuItems[i].Text,cts.TableName); MenuItems[i].Checked = MenuItems[i].Selected = MenuItems[i].Separator = 0; } TotalMenuItems = i; MenuItems[LastSelectedMenu=0].Selected = 1; Info.SendDlgMessage(hDlg,DM_SETCURSORSIZE,3,MAKELONG(1,99)); InfoFormat = (const unsigned char *) GetMsg(MInfoFormat); Info.SendDlgMessage(hDlg,DM_GETDLGITEM,3,(long)&DlgASCII); Info.SendDlgMessage(hDlg,DM_GETDLGITEM,1,(long)&DlgText); Info.SendDlgMessage(hDlg,DM_GETDLGITEM,5,(long)&DlgEdit); Info.SendDlgMessage(hDlg,DM_GETDLGITEM,6,(long)&DlgInfo); Color = Info.AdvControl(Info.ModuleNumber,ACTL_GETCOLOR,(void *)COL_DIALOGTEXT); Color |= Info.AdvControl(Info.ModuleNumber,ACTL_GETCOLOR,(void *)COL_DIALOGBOX); SetVBufAttrib(VBufASCII,Color,256); SetVBufAttrib(DlgInfo.VBuf,Color,32); { struct FarDialogItem DlgDemo; char Demo[19*17+1]; char Space[18]; Info.SendDlgMessage(hDlg,DM_GETDLGITEM,11,(long)&DlgDemo); SetVBufAttrib(DlgDemo.VBuf,Color,19*17); FSF.sprintf(Space,"%17s"," "); lstrcpy(Demo," 0123456789ABCDEF"); for (i=0; i<256; i+=16) { char Hex[3]; FSF.sprintf(Hex,x2,i); lstrcat(Demo,Hex); lstrcat(Demo,Space); } Demo[19+3] = 32; for (i=1; i<256; i++) { Demo[19+i/16*19+i%16+3] = i; } SetVBufChars(DlgDemo.VBuf,(unsigned char *)Demo,19*17); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,11,(long)&DlgDemo); } Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,1,0); //Select DOS TargetTable = 0; //DOS if (POpenFrom == OPENF_EDITOR) { Info.EditorControl(ECTL_GETINFO,(void *)&ei); switch (ei.TableNum) { case -1: if (ei.AnsiMode == 1) { TargetTable = 1; //WIN Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,1,1); //select WIN } break; default: if (ei.TableNum < 0) break; TargetTable = ei.TableNum+2; FSF.sprintf(DlgText.Data,s32,MenuItems[ei.TableNum+2].Text); MenuItems[LastSelectedMenu].Selected = 0; MenuItems[LastSelectedMenu=(ei.TableNum+2)].Selected = 1; Info.CharTable(ei.TableNum,(char *)&cts,sizeof(struct CharTableSet)); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,1,(long)&DlgText); } if (EditorAutoPos) { egs.StringNumber = -1; Info.EditorControl(ECTL_GETSTRING,(void *)&egs); if (egs.StringLength > 0 && ei.CurPos < egs.StringLength) { i = egs.StringText[ei.CurPos]; coord.X = i%32; coord.Y = i/32; } } } if (CmdAutoPos && POpenFrom == OPENF_COMMANDLINE) { Info.Control(INVALID_HANDLE_VALUE,FCTL_GETCMDLINEPOS,(void *)&i); if (i < 1024) { Cmd = (char *)malloc(1024*sizeof(char)); if (!Cmd) { Warning(MMemoryError); Info.SendDlgMessage(hDlg,DM_CLOSE,0,0); return FALSE; } Info.Control(INVALID_HANDLE_VALUE,FCTL_GETCMDLINE,(void *)Cmd); i = cts.EncodeTable[Cmd[i]]; coord.X = i%32; coord.Y = i/32; free(Cmd); } } if (POpenFrom == OPENF_MANUAL) { i = cts.EncodeTable[*Str]; coord.X = i%32; coord.Y = i/32; } Info.SendDlgMessage(hDlg,DMCM_REDRAW,1,1); return TRUE; case DN_KEY: { long rParam2 = Param2; if (Param1==8) if (!(Param2==KEY_ESC || Param2==KEY_F10)) return FALSE; if ((Param2&KEY_CTRL)&&((Param2&0xFFL)>='a')&&((Param2&0xFFL)<='z')) rParam2&=~0x20L; switch (rParam2) { case KEY_LEFT: (coord.X>0)?--coord.X:((coord.Y>0)?(coord.X=31,--coord.Y):coord.X); break; case KEY_RIGHT: (coord.X<31)?++coord.X:((coord.Y<7)?(coord.X=0,++coord.Y):coord.X); break; case KEY_UP: if (coord.Y > 0) --coord.Y; break; case KEY_DOWN: if (coord.Y < 7) ++coord.Y; break; case KEY_HOME: coord.X = 0; break; case KEY_END: coord.X = 31; break; case KEY_PGUP: coord.Y = 0; break; case KEY_PGDN: coord.Y = 7; break; case KEY_CTRLHOME: coord.Y = coord.X = 0; break; case KEY_CTRLEND: coord.Y = 7; coord.X = 31; break; case KEY_ENTER: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_ENTER,0,0); return TRUE; case KEY_SHIFTF8: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,0,0); return TRUE; case KEY_F8: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,2,0); //exchange DOS/WIN return TRUE; case KEY_SHIFTENTER: case KEY_INS: case KEY_ADD: case KEY_SUBTRACT: if (!EditMode && Info.SendDlgMessage(hDlg,DMCM_SETEDIT,0,0)) { switch (Param2) { case KEY_ADD: (coord.X<31)?++coord.X:((coord.Y<7)?(coord.X=0,++coord.Y):coord.X); break; case KEY_SUBTRACT: (coord.X>0)?--coord.X:((coord.Y>0)?(coord.X=31,--coord.Y):coord.X); break; } break; } return TRUE; case KEY_DEL: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_DEL,0,0); return TRUE; case KEY_BS: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_BS,0,0); return TRUE; case KEY_CTRLINS: case KEY_CTRLC: if (!EditMode) { tmplen = EditLen; if (tmplen==0) { EditText[0] = coord.X+32*coord.Y; tmplen = 1; } EditText[tmplen] = 0; if (EncodeBeforeInsertion) { memcpy(tmptext,EditText,tmplen+1); Encode((char *)tmptext,tmplen,&cts,TargetTable); FSF.CopyToClipboard((const char *)tmptext); } else FSF.CopyToClipboard((const char *)EditText); } return TRUE; case KEY_ALTSHIFTF9: Info.SendDlgMessage(hDlg,DM_SHOWDIALOG,FALSE,0); Config(); Info.SendDlgMessage(hDlg,DM_SHOWDIALOG,TRUE,0); return TRUE; case KEY_F9: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,3,1); break; case KEY_SHIFTF9: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,3,-1); break; case KEY_CTRLI: Info.SendDlgMessage(hDlg,DMCM_SHOWTABLEINFO,0,0); return TRUE; case KEY_CTRLN: if (!EditMode) Info.SendDlgMessage(hDlg,DMCM_EDITTABLE,1,0); return TRUE; case KEY_CTRLE: if (!EditMode) { Info.SendDlgMessage(hDlg,DMCM_EDITTABLE,0,0); } else { int xxx; const char *XXX; EditInsertMode = (EditInsertMode+1)%3; xxx=VBufASCII[coord.X+32*coord.Y].Char.AsciiChar; switch (EditInsertMode) { case 0: XXX = x2; break; case 1: XXX = d3; break; case 2: XXX = c1; break; } FSF.sprintf(CharTxt,XXX,xxx); CharTxtPos = 0; Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,7,(long)CharTxt); Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,9,(long)GetMsg(MEditModeHex+EditInsertMode)); } return TRUE; case KEY_CTRLX: if (EditMode) Info.SendDlgMessage(hDlg,DMCM_EDITTABLE,0,1); return TRUE; case KEY_CTRLS: if (EditMode) Info.SendDlgMessage(hDlg,DMCM_EDITTABLE,1,1); return TRUE; case KEY_CTRLL: if (EditMode) { static struct InitDialogItem InitItems[]= { {DI_DOUBLEBOX,3,1,57,4,0,MTitle}, {DI_TEXT,5,2,0,0,0,MEnterFileName}, {DI_EDIT,5,3,55,0,0,-1}, {DI_BUTTON,3,5,0,0,0,MOk}, }; struct FarDialogItem DialogItems[4]; InitDialogItems(InitItems,DialogItems,4); DialogItems[3].DefaultButton = 1; if (Info.Dialog(Info.ModuleNumber,-1,-1,60,6,NULL,DialogItems,4)!=3) break; FSF.Unquote(DialogItems[2].Data); lstrcpy(example,DialogItems[2].Data); LoadFile(example,hDlg,&newtable.cts); } return TRUE; case KEY_CTRLU: if (EditMode) { *example = '\0'; Info.SendDlgMessage(hDlg,DM_LISTDELETE,8,0); } return TRUE; default: if (EditMode) { BOOL ret=FALSE; if (Param2==KEY_ESC||Param2==KEY_F10) { if (Info.SendDlgMessage(hDlg,DMCM_EDITTABLE,0,1)) { Info.SendDlgMessage(hDlg,DM_CLOSE,0,0); } return TRUE; } switch (EditInsertMode) { case 0: //Hex if((Param2>='0' && Param2<='9') || (Param2>='a' && Param2<='f') || (Param2>='A' && Param2<='F')) { CharTxt[CharTxtPos++] = Param2; CharTxt[CharTxtPos] = '\0'; if (CharTxtPos>1) CharTxtPos=0; FSF.sscanf(CharTxt,"%X",&i); ret=TRUE; } break; case 1: //Decimal if((Param2>='0' && Param2<='9')) { CharTxt[CharTxtPos++] = Param2; CharTxt[CharTxtPos] = '\0'; FSF.sscanf(CharTxt,"%d",&i); if (i>255) { CharTxt[CharTxtPos=0] = Param2; CharTxt[++CharTxtPos] = '\0'; } if (CharTxtPos>2) CharTxtPos=0; ret=TRUE; } break; case 2: //Char if((Param2>31 && Param2<256)) { CharTxt[CharTxtPos++] = Param2; CharTxt[CharTxtPos] = '\0'; CharTxtPos=0; FSF.sscanf(CharTxt,"%c",&i); ret=TRUE; } } if (ret) { struct FarListPos lp; Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,7,(long)CharTxt); VBufASCII[coord.X+32*coord.Y].Char.AsciiChar = i; newtable.cts.DecodeTable[coord.X+32*coord.Y] = i; Info.SendDlgMessage(hDlg,DM_LISTGETCURPOS,8,(long)&lp); LoadFile(example,hDlg,&newtable.cts); Info.SendDlgMessage(hDlg,DM_LISTSETCURPOS,8,(long)&lp); CopyVBufSmart(DlgASCII.VBuf,VBufASCII,256); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,3,(long)&DlgASCII); Info.SendDlgMessage(hDlg,DMCM_REDRAW,0,1); return TRUE; } return FALSE; } else { if (Param2<256 && Param2>31) { coord.X = Param2%32; coord.Y = Param2/32; break; } return FALSE; } } if (EditMode) { int xxx; const char *XXX; xxx=VBufASCII[coord.X+32*coord.Y].Char.AsciiChar; switch (EditInsertMode) { case 0: XXX = x2; break; case 1: XXX = d3; break; case 2: XXX = c1; } FSF.sprintf(CharTxt,XXX,xxx); CharTxtPos = 0; Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,7,(long)CharTxt); } Info.SendDlgMessage(hDlg,DMCM_REDRAW,0,1); return TRUE; } case DN_MOUSECLICK: switch (Param1) { case 3: coord = ((MOUSE_EVENT_RECORD *)Param2)->dwMousePosition; Info.SendDlgMessage(hDlg,DMCM_REDRAW,0,1); if (((MOUSE_EVENT_RECORD *)Param2)->dwButtonState == RIGHTMOST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMCM_SETEDIT,0,0); } else { if (((MOUSE_EVENT_RECORD *)Param2)->dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) if (((MOUSE_EVENT_RECORD *)Param2)->dwEventFlags & DOUBLE_CLICK) Info.SendDlgMessage(hDlg,DMCM_ENTER,0,0); } return TRUE; case 1: if (((MOUSE_EVENT_RECORD *)Param2)->dwButtonState == RIGHTMOST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,2,0); } else { if (((MOUSE_EVENT_RECORD *)Param2)->dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,0,0); } } return TRUE; case 5: if (((MOUSE_EVENT_RECORD *)Param2)->dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMCM_BS,0,0); } else { if (((MOUSE_EVENT_RECORD *)Param2)->dwButtonState == RIGHTMOST_BUTTON_PRESSED) { Info.SendDlgMessage(hDlg,DMCM_DEL,0,0); } } return TRUE; } return FALSE; case DMCM_REDRAW: if (Param1) { SetVBufChars(VBufASCII,cts.DecodeTable,256); CopyVBufSmart(DlgASCII.VBuf,VBufASCII,256); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,3,(long)&DlgASCII); } if (Param1 || Param2) { i = VBufASCII[coord.X+32*coord.Y].Char.AsciiChar; FSF.sprintf((char *)Temp,(const char *)InfoFormat,(unsigned char)(i==0?32:i),(unsigned char)i,(unsigned char)i,(int)(coord.X+32*coord.Y),(int)(coord.X+32*coord.Y)); SetVBufChars(DlgInfo.VBuf,Temp,32); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,6,(long)&DlgInfo); Info.SendDlgMessage(hDlg,DM_SETCURSORPOS,3,(long)&coord); } return TRUE; case DMCM_SETEDIT: if (EditLen < 511) { i = VBufASCII[coord.X+32*coord.Y].Char.AsciiChar; if (i == 0) { switch (POpenFrom) { case OPENF_EDITOR: case OPENF_VIEWER: case OPENF_MANUAL: DlgEdit.Data[EditLen] = 32; break; default: return FALSE; } } else DlgEdit.Data[EditLen] = (unsigned char) i; EditText[EditLen] = (unsigned char) (coord.X+32*coord.Y); DlgEdit.Data[++EditLen] = 0; Info.SendDlgMessage(hDlg,DM_SETDLGITEM,5,(long)&DlgEdit); return TRUE; } return FALSE; case DMCM_ENTER: if (EditLen==0) { i = VBufASCII[coord.X+32*coord.Y].Char.AsciiChar; if (i == 0 && POpenFrom == OPENF_COMMANDLINE) { //MessageBeep(0); return FALSE; } else { EditText[0] = (unsigned char) (coord.X+32*coord.Y); EditLen = 1; } } EditText[EditLen] = 0; if (EncodeBeforeInsertion) if (TargetTable != LastSelectedMenu) Encode((char *)EditText,EditLen,&cts,TargetTable); if (CopyToClipboard) FSF.CopyToClipboard((const char *)EditText); switch (POpenFrom) { case OPENF_COMMANDLINE: Info.Control(INVALID_HANDLE_VALUE,FCTL_INSERTCMDLINE,(void *)EditText); break; case OPENF_EDITOR: egs.StringNumber = -1; Info.EditorControl(ECTL_GETSTRING,(void *)&egs); if (ei.CurPos > egs.StringLength) ess.StringText = (char *)malloc((egs.StringLength+EditLen+(ei.CurPos-egs.StringLength))*sizeof(char)); else ess.StringText = (char *)malloc((egs.StringLength+EditLen)*sizeof(char)); if (!ess.StringText) { Warning(MMemoryError); return FALSE; } if (ei.CurPos > egs.StringLength) { for (i=egs.StringLength; i<ei.CurPos; i++) ess.StringText[i] = cts.EncodeTable[32]; if (EncodeBeforeInsertion) Encode(&ess.StringText[egs.StringLength],ei.CurPos-egs.StringLength,&cts,TargetTable); memcpy(ess.StringText,egs.StringText,egs.StringLength); memcpy(ess.StringText+ei.CurPos,EditText,EditLen); ess.StringLength = EditLen + ei.CurPos; } else { memcpy(ess.StringText,egs.StringText,ei.CurPos); memcpy(ess.StringText+ei.CurPos,EditText,EditLen); memcpy(ess.StringText+ei.CurPos+EditLen,egs.StringText+ei.CurPos,egs.StringLength-ei.CurPos); ess.StringLength = EditLen + egs.StringLength; } ess.StringNumber = -1; ess.StringEOL = (char *)egs.StringEOL; Info.EditorControl(ECTL_SETSTRING,(void *)&ess); esp.CurPos = ei.CurPos + EditLen; esp.CurLine = esp.CurTabPos = esp.TopScreenLine = esp.LeftPos = esp.Overtype = -1; Info.EditorControl(ECTL_SETPOSITION,(void *)&esp); free(ess.StringText); break; case OPENF_VIEWER: break; case OPENF_MANUAL: { memcpy(Str,EditText,EditLen); *Ret=EditLen; } } Info.SendDlgMessage(hDlg,DM_CLOSE,0,0); return TRUE; case DMCM_TABLESELECT: if (EditLen > 0) return FALSE; switch (Param1) { case 0: i = Info.Menu(Info.ModuleNumber,-1,-1,0,FMENU_WRAPMODE|FMENU_AUTOHIGHLIGHT,GetMsg(MTableSelect),NULL,NULL,NULL,NULL,MenuItems,TotalMenuItems); break; case 1: i = Param2; break; case 2: i = (LastSelectedMenu == 1 ? 0 : 1); break; case 3: i = LastSelectedMenu + Param2; if (i<0) i = TotalMenuItems-1; if (i >= TotalMenuItems) i = 0; break; } if (i!=-1) { FSF.sprintf(DlgText.Data,s32,MenuItems[i].Text); MenuItems[LastSelectedMenu].Selected = 0; MenuItems[LastSelectedMenu=i].Selected = 1; GetCharTable(i,&cts); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,1,(long)&DlgText); Info.SendDlgMessage(hDlg,DMCM_REDRAW,1,0); return TRUE; } return FALSE; case DMCM_DEL: case DMCM_BS: if (EditLen > 0) { if (Msg == DMCM_DEL) EditLen=1; DlgEdit.Data[--EditLen] = 0; Info.SendDlgMessage(hDlg,DM_SETDLGITEM,5,(long)&DlgEdit); } return TRUE; case DMCM_SHOWTABLEINFO: { struct InitDialogItem InitItems[]= { {DI_DOUBLEBOX,3,1,57,8,0,MTitle}, {DI_TEXT,5,2,0,0,0,MTableName}, {DI_EDIT,5,3,55,0,0,-1}, {DI_TEXT,5,4,0,0,0,MStatusTableName}, {DI_EDIT,5,5,55,0,0,-1}, {DI_TEXT,5,6,0,0,0,MRFCCharset}, {DI_EDIT,5,7,55,0,0,-1}, {DI_BUTTON,3,9,0,0,0,MOk}, }; struct FarDialogItem DialogItems[8]; if (Param1||EditMode) InitItems[0].Data=MEnterTableInfo; InitDialogItems(InitItems,DialogItems,8); DialogItems[7].DefaultButton = 1; lstrcpy(DialogItems[2].Data,EditMode?newtable.cts.TableName:(Param1?"":cts.TableName)); if (!EditMode) { if (!Param1) { DialogItems[2].Flags|=DIF_READONLY; for (i=4; i<=6; i+=2) { DialogItems[i].Flags|=DIF_READONLY; lstrcpy(DialogItems[i].Data,GetMsg(MUnavailable)); } } } else { lstrcpy(DialogItems[4].Data,newtable.ShortName); lstrcpy(DialogItems[6].Data,newtable.RFCName); } if (Info.Dialog(Info.ModuleNumber,-1,-1,60,10,NULL,DialogItems,8)!=7) return FALSE; if (EditMode||Param1) { lstrcpyn(newtable.cts.TableName,DialogItems[2].Data,128); lstrcpyn(newtable.ShortName,DialogItems[4].Data,128); lstrcpyn(newtable.RFCName,DialogItems[6].Data,128); FSF.sprintf(DlgText.Data,s32,*(newtable.cts.TableName)?newtable.cts.TableName:newtable.ShortName); Info.SendDlgMessage(hDlg,DM_SETDLGITEM,1,(long)&DlgText); } } return TRUE; case DMCM_EDITTABLE: if (Param2==0) { SMALL_RECT sr; COORD dcoord; if (Param1) { Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,1,0); newtable.cts=cts; *newtable.ShortName='\0'; *newtable.RFCName='\0'; Info.SendDlgMessage(hDlg,DMCM_SHOWTABLEINFO,1,0); } else { newtable.cts=cts; *newtable.ShortName='\0'; *newtable.RFCName='\0'; } dcoord.X = 61; dcoord.Y=25; Info.SendDlgMessage(hDlg,DM_RESIZEDIALOG,0,(long)&dcoord); sr.Left = 3; sr.Top=1; sr.Right=36; sr.Bottom=23; Info.SendDlgMessage(hDlg,DM_SETITEMPOSITION,0,(long)&sr); Info.SendDlgMessage(hDlg,DM_SHOWITEM,5,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,8,1); Info.SendDlgMessage(hDlg,DM_SHOWITEM,7,1); Info.SendDlgMessage(hDlg,DM_SHOWITEM,9,1); Info.SendDlgMessage(hDlg,DM_SHOWITEM,10,1); Info.SendDlgMessage(hDlg,DM_SHOWITEM,11,1); *example = '\0'; Info.SendDlgMessage(hDlg,DM_LISTDELETE,8,0); EditInsertMode = 0; i=VBufASCII[coord.X+32*coord.Y].Char.AsciiChar; FSF.sprintf(CharTxt,x2,i); CharTxtPos = 0; Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,7,(long)CharTxt); Info.SendDlgMessage(hDlg,DM_SETTEXTPTR,9,(long)GetMsg(MEditModeHex+EditInsertMode)); Info.SendDlgMessage(hDlg,DMCM_REDRAW,1,0); EditMode=TRUE; } else { if (Param1) { static struct InitDialogItem InitItems[]= { {DI_DOUBLEBOX,3,1,57,4,0,MTitle}, {DI_TEXT,5,2,0,0,0,MSaveToFile}, {DI_EDIT,5,3,55,0,0,-1}, {DI_BUTTON,3,5,0,0,0,MOk}, }; struct FarDialogItem DialogItems[4]; InitDialogItems(InitItems,DialogItems,4); DialogItems[3].DefaultButton = 1; lstrcpy(DialogItems[2].Data,*(newtable.cts.TableName)?newtable.cts.TableName:newtable.ShortName); lstrcat(DialogItems[2].Data,".reg"); if (Info.Dialog(Info.ModuleNumber,-1,-1,60,6,NULL,DialogItems,4)==3) { HANDLE fp; DWORD transfered; char buf[256]; FSF.Unquote(DialogItems[2].Data); fp = CreateFile(DialogItems[2].Data,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,0,NULL); if (fp==INVALID_HANDLE_VALUE) { Warning(MFileError); return FALSE; } lstrcpy(buf,"REGEDIT4\r\n[HKEY_CURRENT_USER\\Software\\Far\\CodeTables\\"); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); lstrcpy(buf,*(newtable.ShortName)?newtable.ShortName:newtable.cts.TableName); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); lstrcpy(buf,"]\r\n"); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); if (*(newtable.cts.TableName)&&*(newtable.ShortName)) { lstrcpy(buf,"\"TableName\"=\""); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); lstrcpy(buf,newtable.cts.TableName); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); lstrcpy(buf,"\"\r\n"); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); } if (*(newtable.RFCName)) { lstrcpy(buf,"\"RFCCharset\"=\""); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); lstrcpy(buf,newtable.RFCName); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); lstrcpy(buf,"\"\r\n"); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); } lstrcpy(buf,"\"Mapping\"=hex:\\\r\n"); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); for (i=0; i<16; i++) { int j; *buf = '\0'; for (j=0; j<16; j++) { char hex[4]; FSF.sprintf(hex,"%02X,",newtable.cts.DecodeTable[i*16+j]); lstrcat(buf,hex); } if ((i*16+j)<255) lstrcat(buf,"\\"); else buf[lstrlen(buf)-1] = '\0'; lstrcat(buf,"\r\n"); WriteFile(fp,buf,lstrlen(buf),&transfered,NULL); } CloseHandle(fp); } } else { SMALL_RECT sr; COORD coord; const char *Msg[2]; Msg[0] = GetMsg(MTitle); Msg[1] = GetMsg(MSureToExit); i = Info.Message(Info.ModuleNumber,FMSG_WARNING|FMSG_MB_YESNO,NULL,Msg,2,0); if (i==1 || i==-1) return FALSE; Info.SendDlgMessage(hDlg,DM_LISTDELETE,8,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,8,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,9,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,7,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,10,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,11,0); Info.SendDlgMessage(hDlg,DM_SHOWITEM,5,1); sr.Left = 3; sr.Top=1; sr.Right=36; sr.Bottom=15; Info.SendDlgMessage(hDlg,DM_SETITEMPOSITION,0,(long)&sr); coord.X = 40; coord.Y=17; Info.SendDlgMessage(hDlg,DM_RESIZEDIALOG,0,(long)&coord); Info.SendDlgMessage(hDlg,DMCM_TABLESELECT,1,0); Info.SendDlgMessage(hDlg,DMCM_REDRAW,1,0); EditMode=FALSE; } } return TRUE; case DN_CLOSE: if (MenuItems) free(MenuItems); SetRegKey(®[REG_LASTCOORDX],coord.X); SetRegKey(®[REG_LASTCOORDY],coord.Y); return TRUE; } return Info.DefDlgProc(hDlg,Msg,Param1,Param2); }
int FarAppMain(int argc, char **argv) { Opt.IsUserAdmin = (geteuid()==0); _OT(SysLog(L"[[[[[[[[New Session of FAR]]]]]]]]]")); FARString strEditName; FARString strViewName; FARString DestNames[2]; int StartLine=-1,StartChar=-1; int CntDestName=0; // количество параметров-имен каталогов /*$ 18.04.2002 SKV Попользуем floating point что бы проинициализировался vc-ный fprtl. */ #ifdef _MSC_VER float x=1.1f; wchar_t buf[15]; swprintf(buf,L"%f",x); #endif // если под дебагером, то отключаем исключения однозначно, // иначе - смотря что указал юзвер. #if defined(_DEBUGEXC) Opt.ExceptRules=-1; #else Opt.ExceptRules=-1;//IsDebuggerPresent()?0:-1; #endif // Opt.ExceptRules=-1; #ifdef __GNUC__ Opt.ExceptRules=0; #endif //_SVS(SysLog(L"Opt.ExceptRules=%d",Opt.ExceptRules)); SetRegRootKey(HKEY_CURRENT_USER); Opt.strRegRoot = L"Software/Far2"; // По умолчанию - брать плагины из основного каталога Opt.LoadPlug.MainPluginDir=TRUE; Opt.LoadPlug.PluginsPersonal=TRUE; Opt.LoadPlug.PluginsCacheOnly=FALSE; g_strFarPath = g_strFarModuleName; bool translated = TranslateFarString<TranslateInstallPath_Bin2Share>(g_strFarPath); CutToSlash(g_strFarPath, true); if (translated) { // /usr/bin/something -> /usr/share/far2l g_strFarPath+= L"/" FAR_BASENAME; } WINPORT(SetEnvironmentVariable)(L"FARHOME", g_strFarPath); AddEndSlash(g_strFarPath); // don't inherit from parent process in any case WINPORT(SetEnvironmentVariable)(L"FARUSER", nullptr); WINPORT(SetEnvironmentVariable)(L"FARADMINMODE", Opt.IsUserAdmin?L"1":nullptr); // макросы не дисаблим Opt.Macro.DisableMacro=0; for (int I=1; I<argc; I++) { std::wstring arg_w = MB2Wide(argv[I]); if ((arg_w[0]==L'/' || arg_w[0]==L'-') && arg_w[1]) { switch (Upper(arg_w[1])) { case L'A': switch (Upper(arg_w[2])) { case 0: Opt.CleanAscii=TRUE; break; case L'G': if (!arg_w[3]) Opt.NoGraphics=TRUE; break; } break; case L'E': if (iswdigit(arg_w[2])) { StartLine=_wtoi((const wchar_t *)&arg_w[2]); wchar_t *ChPtr=wcschr((wchar_t *)&arg_w[2],L':'); if (ChPtr) StartChar=_wtoi(ChPtr+1); } if (I+1<argc) { strEditName = argv[I+1]; I++; } break; case L'V': if (I+1<argc) { strViewName = argv[I+1]; I++; } break; case L'M': switch (Upper(arg_w[2])) { case 0: Opt.Macro.DisableMacro|=MDOL_ALL; break; case L'A': if (!arg_w[3]) Opt.Macro.DisableMacro|=MDOL_AUTOSTART; break; } break; case L'I': Opt.SmallIcon=TRUE; break; case L'X': Opt.ExceptRules=0; #if defined(_DEBUGEXC) if (Upper(arg_w[2])==L'D' && !arg_w[3]) Opt.ExceptRules=1; #endif break; case L'C': if (Upper(arg_w[2])==L'O' && !arg_w[3]) { Opt.LoadPlug.PluginsCacheOnly=TRUE; Opt.LoadPlug.PluginsPersonal=FALSE; } break; case L'?': case L'H': ControlObject::ShowCopyright(1); show_help(); return 0; #ifdef DIRECT_RT case L'D': if (Upper(arg_w[2])==L'O' && !arg_w[3]) DirectRT=1; break; #endif case L'W': { Opt.WindowMode=TRUE; } break; } } else // простые параметры. Их может быть max две штукА. { if (CntDestName < 2) { if (IsPluginPrefixPath((const wchar_t *)arg_w.c_str())) { DestNames[CntDestName++] = (const wchar_t *)arg_w.c_str(); } else { apiExpandEnvironmentStrings((const wchar_t *)arg_w.c_str(), DestNames[CntDestName]); Unquote(DestNames[CntDestName]); ConvertNameToFull(DestNames[CntDestName],DestNames[CntDestName]); if (apiGetFileAttributes(DestNames[CntDestName]) != INVALID_FILE_ATTRIBUTES) CntDestName++; //??? } } } } //Настройка OEM сортировки. Должна быть после CopyGlobalSettings и перед InitKeysArray! //LocalUpperInit(); //InitLCIDSort(); //Инициализация массива клавиш. Должна быть после CopyGlobalSettings! InitKeysArray(); //WaitForInputIdle(GetCurrentProcess(),0); std::set_new_handler(nullptr); if (!Opt.LoadPlug.MainPluginDir) //если есть ключ /p то он отменяет /co Opt.LoadPlug.PluginsCacheOnly=FALSE; if (Opt.LoadPlug.PluginsCacheOnly) { Opt.LoadPlug.strCustomPluginsPath.Clear(); Opt.LoadPlug.MainPluginDir=FALSE; Opt.LoadPlug.PluginsPersonal=FALSE; } InitConsole(); GetRegKey(L"Language",L"Main",Opt.strLanguage,L"English"); if (!Lang.Init(g_strFarPath,true,MNewFileName)) { ControlObject::ShowCopyright(1); LPCWSTR LngMsg; switch(Lang.GetLastError()) { case LERROR_BAD_FILE: LngMsg = L"\nError: language data is incorrect or damaged.\n\nPress any key to exit..."; break; case LERROR_FILE_NOT_FOUND: LngMsg = L"\nError: cannot find language data.\n\nPress any key to exit..."; break; default: LngMsg = L"\nError: cannot load language data.\n\nPress any key to exit..."; break; } Console.Write(LngMsg,StrLength(LngMsg)); Console.FlushInputBuffer(); WaitKey(); // А стоит ли ожидать клавишу??? Стоит return 1; } WINPORT(SetEnvironmentVariable)(L"FARLANG",Opt.strLanguage); SetHighlighting(); initMacroVarTable(1); if (Opt.ExceptRules == -1) { GetRegKey(L"System",L"ExceptRules",Opt.ExceptRules,1); } //ErrorMode=SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX|(Opt.ExceptRules?SEM_NOGPFAULTERRORBOX:0)|(GetRegKey(L"System/Exception", L"IgnoreDataAlignmentFaults", 0)?SEM_NOALIGNMENTFAULTEXCEPT:0); //SetErrorMode(ErrorMode); int Result=MainProcessSEH(strEditName,strViewName,DestNames[0],DestNames[1],StartLine,StartChar); EmptyInternalClipboard(); doneMacroVarTable(1); VTShell_Shutdown();//ensure VTShell deinitialized before statics destructors called _OT(SysLog(L"[[[[[Exit of FAR]]]]]]]]]")); return Result; }