//--------------------------------------------------------------------- __fastcall TFormMain::TFormMain(TComponent *Owner) : TForm(Owner) { ProcIndex = -1; HIDE = 0; Caption = "Process Monitor"; TIniFile *Ini = new TIniFile( FILE_INI ); if ( Ini == NULL ) { exit(1); } NMUDP1->LocalPort = Ini->ReadInteger( "CONF", "Port", 8081 ); for ( int i = 1; i < 20; i++ ) { String str; String section = "PROC"; section = section + i; str = Ini->ReadString( section, "File", "" ); // remove as plicas "" e outros caracteres do caminho str = str.Trim(); if ( str != "" ) { Processos.push_back( str ); // caminho completo do executável Args.push_back( Ini->ReadString(section, "Args", "") ); // argumentos de linha de comando Modo.push_back( Ini->ReadInteger(section, "Mode", 0) ); // modo WDCnt.push_back(0); // contagem inicial zerada WDCntToRestart.push_back( Ini->ReadInteger(section, "RestartCount", 12) ); // tempo para restart } } HIDE = Ini->ReadInteger( "CONF", "Hide", 0 ); }
//--------------------------------------------------------------------------- void __fastcall CIniFile::StoreHistory(int nYear,int nMonth,int nDate,AnsiString strMessage) { AnsiString strFileName; TIniFile *pIniFile; int nFileMonth,nIndex; strFileName.sprintf("%s\\Message History\\%4d_%02d_%02d.ini",IniFile_Dir,nYear,nMonth,nDate); pIniFile = new TIniFile(strFileName); nFileMonth=pIniFile->ReadInteger("Control","Month",1); nIndex=pIniFile->ReadInteger("Control","Index",1); if(nFileMonth!=nMonth) { nIndex=1; pIniFile->WriteInteger("Control","Month",nMonth); } AnsiString strID; strID.sprintf("No%08d",nIndex); pIniFile->WriteString("History",strID,strMessage); nIndex++; strID.sprintf("No%08d",nIndex); pIniFile->WriteString("History",strID,"//-------------以下做作廢--------------------//"); pIniFile->WriteInteger("Control","Index",nIndex); delete pIniFile; }
//--------------------------------------------------------------------------- void __fastcall TDllTestForm::FormShow(TObject *Sender) { TIniFile *IniFile; if (!FInitialized) { FInitialized = TRUE; IniFile = new TIniFile(FIniFileName); Top = IniFile->ReadInteger(SectionWindow, KeyTop, Top); Left = IniFile->ReadInteger(SectionWindow, KeyLeft, Left); Width = IniFile->ReadInteger(SectionWindow, KeyWidth, Width); Height = IniFile->ReadInteger(SectionWindow, KeyHeight, Height); delete IniFile; DisplayMemo->Clear(); DllHandle = LoadLibraryA("OverbyteIcsDLL1.dll"); if (DllHandle == 0) { MyMessageBox("OverbyteIcsDLL1.dll not found", "Error", MB_OK); Application->Terminate(); return; } IcsDllDemo = (TIcsDllDemo)GetProcAddress(DllHandle, "IcsDllDemo"); if (IcsDllDemo == NULL) { MyMessageBox("IcsDllDemo not found (OverbyteIcsDLL1.dll)", "Error", MB_OK); Application->Terminate(); return; } } }
void __fastcall TMailSndForm::FormShow(TObject *Sender) { TIniFile *IniFile; if (!FInitialized) { FInitialized = TRUE; IniFile = new TIniFile(FIniFileName); HostEdit->Text = IniFile->ReadString(SectionData, KeyHost, "localhost"); PortEdit->Text = IniFile->ReadString(SectionData, KeyPort, "smtp"); FromEdit->Text = IniFile->ReadString(SectionData, KeyFrom, "first->last@company->com"); ToEdit->Text = IniFile->ReadString(SectionData, KeyTo, "john->doe@acme;tartempion@brol->fr"); SubjectEdit->Text = IniFile->ReadString(SectionData, KeySubject, "This is the message subject"); SignOnEdit->Text = IniFile->ReadString(SectionData, KeySignOn, "your name"); Top = IniFile->ReadInteger(SectionWindow, KeyTop, (Screen->Height - Height) / 2); Left = IniFile->ReadInteger(SectionWindow, KeyLeft, (Screen->Width - Width) / 2); Width = IniFile->ReadInteger(SectionWindow, KeyWidth, Width); Height = IniFile->ReadInteger(SectionWindow, KeyHeight, Height); delete IniFile; } }
//--------------------------------------------------------------------------- void __fastcall TForm1::ReadConfig () //读取配置 { TIniFile *ini; ini = new TIniFile(ChangeFileExt(Application->ExeName,".INI ")); Form1->Top = ini->ReadInteger( "Form ", "Top ", 100 ); Form1->Left = ini->ReadInteger( "Form ", "Left ", 100 ); AnsiString Caption = ini->ReadString( "Form ", "Caption ", "科传接驳数据合规性检查程序" ); Form1->Edit1->Text = ini->ReadString( "Form ", "DefaultDir", "c:\\" ); delete ini; }
//--------------------------------------------------------------------------- void __fastcall CIniFile::StoreHistoryNew() { AnsiString strFileName; TIniFile *pIniFile; int nFileMonth,nIndex; time_t timer; struct tm *tblock; int nSize=m_vecMsg.size(); if(nSize==0) return; AnsiString strMsg; strMsg.sprintf("訊息共有 %d 筆\n每筆花費時間約 10 ms\n是否要儲存訊息??",nSize); if(Application->MessageBoxA(strMsg.c_str(),"Confirm",MB_ICONQUESTION|MB_OKCANCEL)!=IDOK) return; /* gets time of day */ timer = time(NULL); /* converts date/time to a structure */ tblock = localtime(&timer); int nMonth=tblock->tm_mon; int nDate=tblock->tm_mday; strFileName.sprintf("%s\\Message History\\%d.ini",IniFile_Dir,nDate); pIniFile = new TIniFile(strFileName); nFileMonth=pIniFile->ReadInteger("Control","Month",1); nIndex=pIniFile->ReadInteger("Control","Index",1); if(nFileMonth!=nMonth) { DeleteFile(strFileName); nIndex=1; pIniFile->WriteInteger("Control","Month",nMonth); } AnsiString strID; for(int nSz=0;nSz<nSize;nSz++) { strID.sprintf("No%08d",nIndex); pIniFile->WriteString("History",strID,m_vecMsg[nSz]); nIndex++; } m_vecMsg.clear(); strID.sprintf("No%08d",nIndex); pIniFile->WriteString("History",strID,"//-------------以下做作廢--------------------//"); pIniFile->WriteInteger("Control","Index",nIndex); delete pIniFile; }
// retrieves the default user settings void PREFERENCES::GetDefaultSettings() { TIniFile* storage = new TIniFile( ExtractFilePath( Application->ExeName ) + INIFILENAME_PREFERENCES ); try { UserLevel = storage->ReadInteger( "Various", "DefaultUserLevel", USERLEVEL_ADVANCED ); #define READ_SCRIPT( name ) \ if( !mCmdlineSpecified[ name ] ) \ Script[ name ] = storage->ReadString( "Scripts", #name, "" ); READ_SCRIPT( AfterModulesConnected ); READ_SCRIPT( OnExit ); READ_SCRIPT( OnSetConfig ); READ_SCRIPT( OnResume ); READ_SCRIPT( OnSuspend ); READ_SCRIPT( OnStart ); #define READ_BUTTON( number ) \ Buttons[ number ].Name = storage->ReadString( "Buttons", "Button" #number "Name", "" );\ Buttons[ number ].Cmd = storage->ReadString( "Buttons", "Button" #number "Cmd", "" ); READ_BUTTON( 1 ); READ_BUTTON( 2 ); READ_BUTTON( 3 ); READ_BUTTON( 4 ); } catch(...) {} delete storage; }
//--------------------------------------------------------------------------- void __fastcall CTerminalRobotTyper::RestoreKeyInterval(){ TIniFile *ini = new TIniFile(GetCurrentDir() + "\\app.ini"); int keyInterval = ini->ReadInteger(terminal->xmlConfig->TerminalID , "KeyboardInterval", terminal->panel->TrackBarKey->Position); delete ini; terminal->panel->TrackBarKey->Position =keyInterval; keyIntervalRestored =true; }
void __fastcall TFrmMain::PopupMenu1Popup(TObject* Sender) { if (OpenOk == true) { AnsiString iniSetFile = ExtractFilePath(Application->ExeName) + "BcdEditer.ini"; AnsiString SectionName = ExtractFileName(CurrentOpenFile); int ColType; TIniFile* ini; ini = new TIniFile(iniSetFile); ColType = ini->ReadInteger(SectionName, "ColType" + IntToStr(sgEdit->Col), 0); delete ini; switch (ColType) { case 0: btIntType->Checked = true; btFloatType->Checked = false; btTxtType->Checked = false; break; case 1: btIntType->Checked = false; btFloatType->Checked = true; btTxtType->Checked = false; break; case 2: btIntType->Checked = false; btFloatType->Checked = false; btTxtType->Checked = true; break; default: btIntType->Checked = true; btFloatType->Checked = false; } } }
//--------------------------------------------------------------------------- void __fastcall TMainForm::FormShow(TObject *Sender) { static BOOL FirstTime = TRUE; TIniFile *IniFile; if (FirstTime) { FirstTime = FALSE; IniFile = new TIniFile(FIniFileName); Top = IniFile->ReadInteger(SectionWindow, KeyTop, Top); Left = IniFile->ReadInteger(SectionWindow, KeyLeft, Left); Width = IniFile->ReadInteger(SectionWindow, KeyWidth, Width); Height = IniFile->ReadInteger(SectionWindow, KeyHeight, Height); PortEdit->Text = IniFile->ReadString(SectionData, KeyPort, "600"); MessageEdit->Text = IniFile->ReadString(SectionData, KeyMessage, ""); delete IniFile; } }
//--------------------------------------------------------------------------- void __fastcall TTcpSrvForm::FormShow(TObject *Sender) { TIniFile *IniFile; if (!FInitialized) { FInitialized = TRUE; IniFile = new TIniFile(FIniFileName); Top = IniFile->ReadInteger(SectionWindow, KeyTop, Top); Left = IniFile->ReadInteger(SectionWindow, KeyLeft, Left); Width = IniFile->ReadInteger(SectionWindow, KeyWidth, Width); Height = IniFile->ReadInteger(SectionWindow, KeyHeight, Height); delete IniFile; DisplayMemo->Clear(); // Delay startup code until our UI is ready and visible PostMessage(Handle, WM_APPSTARTUP, 0, 0); } }
//--------------------------------------------------------------------------- void __fastcall TFtpServerForm::FormShow(TObject *Sender) { TIniFile *IniFile; int Minim; if (!FInitialized) { FInitialized = TRUE; Caption = "Starting " MainTitle; Left = -Width; IniFile = new TIniFile(FIniFileName); FXTop = IniFile->ReadInteger(SectionWindow, KeyTop, Top); FXLeft = IniFile->ReadInteger(SectionWindow, KeyLeft, Left); FXWidth = IniFile->ReadInteger(SectionWindow, KeyWidth, Width); FXHeight = IniFile->ReadInteger(SectionWindow, KeyHeight, Height); Minim = IniFile->ReadInteger(SectionWindow, KeyMinim, 0); IniFile->Free(); LoadConfig(); SaveConfig(); // Create the inifile keys if they don't exists // Be sure to always have the window visible // with a reasonable width and height if (FXLeft < 0) FXLeft = 0; if (FXTop < 0) FXTop = 0; if (FXWidth < 310) FXWidth = 310; if (FXHeight <= 250) FXHeight = 250; if ((FXLeft + FXWidth) > Screen->Width) FXLeft = Screen->Width - FXWidth; if ((FXTop + FXHeight) > Screen->Height) FXTop = Screen->Height - FXHeight; StartMinimizedCheckBox->Checked = (Minim != 0); // We use a custom message to initialize things once the form // is visible PostMessage(Handle, WM_APPSTARTUP, 0, 0); } }
//--------------------------------------------------------------------------- void __fastcall TMainForm::FormShow(TObject *Sender){ // 读取本地的一些设置,或是上次的配置参数 TIniFile *ini = new TIniFile(GetCurrentDir() + "\\app.ini"); int userId = ini->ReadInteger("Center", "UserId", 0); AnsiString st = ini->ReadString("Center", "ST", ""); DateTimePicker->Time = ini->ReadTime("Center", "ShutdownTime", StrToTime("23:45:00")); //是否跳过登录界面 if (userId ==0 || st ==""){ LoginForm->ShowModal(); }else{ controller->centerId =userId; controller->centerSt =st; } TimerTask->Enabled =true; // 创建一个ActionList用于动态保存各个标签页的Action actionList = new TActionList(MainForm); // 读取本地的一些设置,或是上次的配置参数 MainForm->Width = ini->ReadInteger("FormSize", "Width", 1024); MainForm->Height = ini->ReadInteger("FormSize", "Height", 768); delete ini; // FrameMonitor =new TFrameMonitor(this); //用这个Frame,主要是用来加竖滚动条的,并且支持鼠标滑轮滚动 FrameMonitor->Parent =PanelMonitorGroup; //文件打印内容明细 StringGridTxt->Cells[0][0] ="行数"; StringGridTxt->Cells[1][0] ="游戏ID"; StringGridTxt->Cells[2][0] ="玩法类型"; StringGridTxt->Cells[3][0] ="投注方式"; StringGridTxt->Cells[4][0] ="彩票号码"; StringGridTxt->Cells[5][0] ="倍"; StringGridTxt->Cells[6][0] ="金额分"; for (int i =0; i <StringGridTxt->RowCount; i++) StringGridTxt->Cells[0][i+1] =IntToStr(i +1); //后台管理浏览器加载,防止Document设置Cookie时为空 WideString HomePage =LOGIN_URL; WebBrowser->Navigate(HomePage.c_bstr()); //显示登录页并且最大化窗口 PageControl->ActivePageIndex =1; //总控制器初始化 controller->Init(); //调整位置 FormResize(this); ShowErrMessage(); }
//--------------------------------------------------------------------------- void __fastcall TMainForm::FormShow(TObject *Sender) { static BOOL FirstTime = TRUE; TIniFile *IniFile; if (FirstTime) { FirstTime = FALSE; IniFile = new TIniFile(FIniFileName); Top = IniFile->ReadInteger(SectionWindow, KeyTop, Top); Left = IniFile->ReadInteger(SectionWindow, KeyLeft, Left); Width = IniFile->ReadInteger(SectionWindow, KeyWidth, Width); Height = IniFile->ReadInteger(SectionWindow, KeyHeight, Height); PortEdit->Text = IniFile->ReadString(SectionData, KeyPort, "600"); ServerEdit->Text = IniFile->ReadString(SectionData, KeyServer, "0.0.0.0"); delete IniFile; DataAvailableLabel->Caption = ""; InfoLabel->Caption = "Click on Start button"; StartButton->Enabled = TRUE; StopButton->Enabled = FALSE; } }
//--------------------------------------------------------------------------- void __fastcall TSocksTestForm::FormShow(TObject *Sender) { TIniFile *IniFile; if (!FInitialized) { FInitialized = TRUE; DisplayMemo->Clear(); IniFile = new TIniFile(FIniFileName); Width = IniFile->ReadInteger(SectionWindow, KeyWidth, Width); Height = IniFile->ReadInteger(SectionWindow, KeyHeight, Height); Top = IniFile->ReadInteger(SectionWindow, KeyTop, (Screen->Height - Height) / 2); Left = IniFile->ReadInteger(SectionWindow, KeyLeft, (Screen->Width - Width) / 2); TargetHostEdit->Text = IniFile->ReadString(SectionData, KeyTargetHost, ""); TargetPortEdit->Text = IniFile->ReadString(SectionData, KeyTargetPort, ""); SocksServerEdit->Text = IniFile->ReadString(SectionData, KeySocksServer, ""); SocksPortEdit->Text = IniFile->ReadString(SectionData, KeySocksPort, "1080"); SocksUsercodeEdit->Text = IniFile->ReadString(SectionData, KeySocksUsercode, ""); SocksPasswordEdit->Text = IniFile->ReadString(SectionData, KeySocksPassword, ""); SocksAuthCheckBox->Checked = IniFile->ReadInteger(SectionData, KeySocksAuth, 0); Socks4RadioButton->Checked = IniFile->ReadInteger(SectionData, KeySocks4, 0); Socks5RadioButton->Checked = IniFile->ReadInteger(SectionData, KeySocks5, 1); delete IniFile; } }
//--------------------------------------------------------------------------- void __fastcall TWebServForm::FormShow(TObject *Sender) { TIniFile *IniFile; WSAData wsi; if (!FInitialized) { FInitialized = TRUE; IniFile = new TIniFile(FIniFileName); Top = IniFile->ReadInteger(SectionWindow, KeyTop, Top); Left = IniFile->ReadInteger(SectionWindow, KeyLeft, Left); Width = IniFile->ReadInteger(SectionWindow, KeyWidth, Width); Height = IniFile->ReadInteger(SectionWindow, KeyHeight, Height); DocDirEdit->Text = IniFile->ReadString(SectionData, KeyDocDir, "c:\WwwRoot"); DefaultDocEdit->Text = IniFile->ReadString(SectionData, KeyDefaultDoc, "index.html"); PortEdit->Text = IniFile->ReadString(SectionData, KeyPort, "80"); DisplayHeaderCheckBox->Checked = IniFile->ReadInteger(SectionData, KeyDisplayHeader, 0); delete IniFile; DisplayMemo->Clear(); // Initialize client count caption ClientCountLabel->Caption = "0"; // Display version info for program and use components wsi = WinsockInfo(); Display(CopyRight); Display("Using:"); Display(" Winsock:"); Display(Format(" Version %d.%d", ARRAYOFCONST((wsi.wHighVersion >> 8, wsi.wHighVersion & 15)))); Display(Format(" %s", ARRAYOFCONST((&wsi.szDescription[0])))); Display(Format(" %s", ARRAYOFCONST((&wsi.szSystemStatus[0])))); if (wsi.lpVendorInfo != NULL) Display(Format(" %s", ARRAYOFCONST((wsi.lpVendorInfo)))); // Automatically start server StartButtonClick(this); }
void TSettings::LoadFromFile(String filename) { TIniFile *ini = new TIniFile(filename); Fullscreen = ini->ReadBool("Global", "FullScreen", false); FormsWidth = ini->ReadInteger("Global", "Width", 1024); FormsHeight = ini->ReadInteger("Global", "Height", 1024); FormsLeft = ini->ReadInteger("Global", "Left", 0); FormsTop = ini->ReadInteger("Global", "Top", 0); SoundEnabled = ini->ReadBool("Global", "Sound", false); SoundVolume = ini->ReadInteger("Global", "SoundVolume", 100); SetVolumeSFX(SoundVolume/100.); MusicEnabled = ini->ReadBool("Global", "Music", false); MusicVolume = ini->ReadInteger("Global", "MusicVolume", 100); SetVolumeMusic(MusicVolume/100.); HostMode = ini->ReadBool("Global", "HostMode", false); MinWidth = 1024; MinHeight = 768; for (int i = 1; i <= 5; i++) { PlayerNames[i - 1] = ini->ReadString("Players", "Player" + IntToStr(i), "PlayerName"); PlayerType[i - 1] = (TBotType)ini->ReadInteger("Players", "PlayerType" + IntToStr(i), 0); } LastBase = ini->ReadString("Global", "LastBase", ""); if (LastBase == "") { if (FileExists("base\\main.dat")) { LastBase = "main.dat"; } else { MessageBox(Application->Handle, "Ошибка загрузки последней базы вопросов\n" "Попытка загрузить base\\main.dat также провалилась - файла не существует.", "Критическая ошибка", MB_OK | MB_ICONSTOP); Application->Terminate(); } } int i = 0; BaseFiles.clear(); BaseNames = new TStringList; while (1) { String name = ini->ReadString("Bases", "basename" + IntToStr(i), ""); String file = ini->ReadString("Bases", "base" + IntToStr(i), ""); if ((name != "") && (file != "")) { BaseFiles[name] = file; BaseNames->Add(name); } else { break; } i++ ; } ini->Free(); }
//--------------------------------------------------------------------------- void __fastcall THttpTestForm::FormShow(TObject *Sender) { TIniFile *IniFile; if (!FInitialized) { FInitialized = TRUE; IniFile = new TIniFile(FIniFileName); UserIDEdit->Text = IniFile->ReadString(SectionData, KeyUserID, "27313"); EMailEdit->Text = IniFile->ReadString(SectionData, KeyEMail, "*****@*****.**"); ProxyEdit->Text = IniFile->ReadString(SectionData, KeyProxy, ""); MessageEdit->Text = IniFile->ReadString(SectionData, KeyMessage, "Hello World ! (Message sent by HttpPg)."); Top = IniFile->ReadInteger(SectionWindow, KeyTop, Top); Left = IniFile->ReadInteger(SectionWindow, KeyLeft, Left); Width = IniFile->ReadInteger(SectionWindow, KeyWidth, Width); Height = IniFile->ReadInteger(SectionWindow, KeyHeight, Height); delete IniFile; } }
//--------------------------------------------------------------------------- void __fastcall TClientForm::FormShow(TObject *Sender) { TIniFile *IniFile; if (Initialized) return; Initialized = TRUE; IniFile = new TIniFile(IniFileName); Top = IniFile->ReadInteger("Window", "Top", Top); Left = IniFile->ReadInteger("Window", "Left", Left); Width = IniFile->ReadInteger("Window", "Width", Width); Height = IniFile->ReadInteger("Window", "Height", Height); PortEdit->Text = IniFile->ReadString("Data", "Port", "telnet"); ServerEdit->Text = IniFile->ReadString("Data", "Server", "localhost"); SendEdit->Text = IniFile->ReadString("Data", "Command", "LASTNAME CAESAR"); delete IniFile; DisplayMemo->Clear(); ActiveControl = SendEdit; SendEdit->SelectAll(); }
//--------------------------------------------------------------------------- void __fastcall THttpTestForm::FormShow(TObject *Sender) { TIniFile *IniFile; if (!Initialized) { Initialized = TRUE; IniFile = new TIniFile(FIniFileName); Width = IniFile->ReadInteger(SectionWindow, KeyWidth, Width); Height = IniFile->ReadInteger(SectionWindow, KeyHeight, Height); Top = IniFile->ReadInteger(SectionWindow, KeyTop, (Screen->Height - Height) / 2); Left = IniFile->ReadInteger(SectionWindow, KeyLeft, (Screen->Width - Width) / 2); URLEdit->Text = IniFile->ReadString(SectionData, KeyUrl, "https://localhost"); DateTimeEdit->Text = IniFile->ReadString("Data", "DateTime", ""); SocksServerEdit->Text = IniFile->ReadString(SectionData, KeySocksServer, ""); SocksPortEdit->Text = IniFile->ReadString(SectionData, KeySocksPort, "1080"); ProxyHostEdit->Text = IniFile->ReadString(SectionData, KeyProxyHost, ""); ProxyPortEdit->Text = IniFile->ReadString(SectionData, KeyProxyPort, "8080"); DocEdit->Text = IniFile->ReadString(SectionData, KeyDoc, "/index.html"); CertFileEdit->Text = IniFile->ReadString(SectionData, KeyCertFile, "01cert.pem"); PrivKeyFileEdit->Text = IniFile->ReadString(SectionData, KeyPrivKeyFile, "01key.pem"); PassPhraseEdit->Text = IniFile->ReadString(SectionData, KeyPassPhrase, "password"); CAFileEdit->Text = IniFile->ReadString(SectionData, KeyCAFile, "cacert.pem"); CAPathEdit->Text = IniFile->ReadString(SectionData, KeyCAPath, ""); SocksLevelComboBox->ItemIndex = IniFile->ReadInteger(SectionData, KeySocksLevel, 0); AcceptableHostsEdit->Text = IniFile->ReadString(SectionData, KeyAcceptableHosts, "www.overbyte.be;www.borland.com"); VerifyPeerCheckBox->Checked = IniFile->ReadBool(SectionData, KeyVerifyPeer, 0); HttpVersionComboBox->ItemIndex = IniFile->ReadInteger(SectionData, KeyHttpVer, 0); SessCacheCheckBox->Checked = IniFile->ReadBool(SectionData, KeySessCache, False); DebugEventCheckBox->Checked = IniFile->ReadBool(SectionData, KeyDebugEvent, False); DebugOutputCheckBox->Checked = IniFile->ReadBool(SectionData, KeyDebugOutput, False); DebugFileCheckBox->Checked = IniFile->ReadBool(SectionData, KeyDebugFile, False); delete IniFile; DisplayMemo->Clear(); } }
//--------------------------------------------------------------------------- void __fastcall TMainFrm::ReadConfiguration() { TIniFile * MailIni; MailIni = new TIniFile(ExtractFilePath(ParamStr(0)) + "Mail.ini"); Pop3ServerName = MailIni->ReadString("Pop3", "ServerName", "pop3.server.com"); Pop3ServerPort = StrToInt(MailIni->ReadString("Pop3", "ServerPort", "110")); Pop3ServerUser = MailIni->ReadString("Pop3", "ServerUser", "your_login"); Pop3ServerPassword = MailIni->ReadString("Pop3", "ServerPassword", "your_password"); SmtpServerName = MailIni->ReadString("Smtp", "ServerName", "smtp.server.com"); SmtpServerPort = StrToInt(MailIni->ReadString("Smtp", "ServerPort", "25")); SmtpServerUser = MailIni->ReadString("Smtp", "ServerUser", "your_login"); SmtpServerPassword = MailIni->ReadString("Smtp", "ServerPassword", "your_password"); SmtpAuthType = MailIni->ReadInteger("Smtp", "SMTPAuthenticationType", 0); UserEmail = MailIni->ReadString("Email", "PersonalEmail", "*****@*****.**"); delete MailIni; }
//--------------------------------------------------------------------------- void TForm1::ReadIniSettings() { // This example is derived from the corresponding Delphi example. // To be compatible with Delphi 1 the Delphi example uses INI files // rather than using the registry to store configuration data. // This program uses INI files as well since it has been converted // from the Delphi example. Normally you would use the registry // to store configuration data in a 32-bit program. // int Value; bool Exists; TIniFile* ini = new TIniFile(ChangeFileExt(Application->ExeName, ".INI")); try { // view menu Exists = ini->ReadBool("General", "Exists", false); if (Exists) { AbZipOutline1->Attributes.Clear(); if (ini->ReadBool("View", "CSize", false)) AbZipOutline1->Attributes = AbZipOutline1->Attributes << zaCompressedSize; if (ini->ReadBool("View", "CMethod", false)) AbZipOutline1->Attributes = AbZipOutline1->Attributes << zaCompressionMethod; if (ini->ReadBool("View", "CRatio", false)) AbZipOutline1->Attributes = AbZipOutline1->Attributes << zaCompressionRatio; if (ini->ReadBool("View", "CRC", false)) AbZipOutline1->Attributes = AbZipOutline1->Attributes << zaCRC; if (ini->ReadBool("View", "EFA", false)) AbZipOutline1->Attributes = AbZipOutline1->Attributes << zaExternalFileAttributes; if (ini->ReadBool("View", "IFA", false)) AbZipOutline1->Attributes = AbZipOutline1->Attributes << zaInternalFileAttributes; if (ini->ReadBool("View", "Encryption", false)) AbZipOutline1->Attributes = AbZipOutline1->Attributes << zaEncryption; if (ini->ReadBool("View", "TimeStamp", false)) AbZipOutline1->Attributes = AbZipOutline1->Attributes << zaTimeStamp; if (ini->ReadBool("View", "USize", false)) AbZipOutline1->Attributes = AbZipOutline1->Attributes << zaUncompressedSize; if (ini->ReadBool("View", "MadeBy", false)) AbZipOutline1->Attributes = AbZipOutline1->Attributes << zaVersionMade; if (ini->ReadBool("View", "Needed", false)) AbZipOutline1->Attributes = AbZipOutline1->Attributes << zaVersionNeeded; if (ini->ReadBool("View", "Comment", false)) AbZipOutline1->Attributes = AbZipOutline1->Attributes << zaComment; AbZipOutline1->Hierarchy = ini->ReadBool("View", "Hierarchy", true); Value = ini->ReadInteger("View", "OutlineStyle", -1); // if (Value != -1) // AbZipOutline1->OutlineStyle = TOutlineStyle(Value); // preferences menu AbZipOutline1->BaseDirectory = ini->ReadString( "Preferences", "BaseDirectory", ExtractFilePath(Application->ExeName)); if (!AbDirectoryExists(AbZipOutline1->BaseDirectory)) AbZipOutline1->BaseDirectory = ExtractFilePath(Application->ExeName); Confirmations1->Checked = ini->ReadBool("Preferences", "Confirmations", false); SpeedButton7->Down = Confirmations1->Checked; Value = ini->ReadInteger( "Preferences", "CompressionMethodToUse", (int)smBestMethod); AbZipOutline1->CompressionMethodToUse = TAbZipSupportedMethod(Value); Value = ini->ReadInteger("Preferences", "DeflationOption", doNormal); AbZipOutline1->DeflationOption = TAbZipDeflationOption(Value); AbZipOutline1->ExtractOptions.Clear(); if (ini->ReadBool("Preferences", "CreateDirs", false)) AbZipOutline1->ExtractOptions = AbZipOutline1->ExtractOptions << eoCreateDirs; if (ini->ReadBool("Preferences", "RestorePath", false)) AbZipOutline1->ExtractOptions = AbZipOutline1->ExtractOptions << eoRestorePath; AbZipOutline1->StoreOptions.Clear(); if (ini->ReadBool("Preferences", "StripPath", false)) AbZipOutline1->StoreOptions = AbZipOutline1->StoreOptions << soStripPath; if (ini->ReadBool("Preferences", "RemoveDots", false)) AbZipOutline1->StoreOptions = AbZipOutline1->StoreOptions << soRemoveDots; if (ini->ReadBool("Preferences", "Recurse", false)) AbZipOutline1->StoreOptions = AbZipOutline1->StoreOptions << soRecurse; StubName = ini->ReadString("Self Extracting", "StubName", "selfex.exe"); FilterComboBox1->Filter = ini->ReadString("Navigator", "Filter", "All files (*.*)|*.*|Zip Files (*.ZIP)|*.ZIP|" "Executable Files (*.EXE)|*.EXE|Text files (*.TXT)|*.TXT|"); } } // try catch (...) { delete ini; return; } delete ini; }
//--------------------------------------------------------------------------- void __fastcall TPrefsForm::SetHotkeyButtonClick(TObject* Sender) { CheckPrefsInterOpt(); CheckReadonlyOpt(PrefFileOpt); TIniFile* Ini = new TIniFile(PrefFileOpt); long int HotKey = HotKeyComb->HotKey; int Mods = 0; int Key = 0; if (HotKeyComb->Modifiers.Contains(hkShift)) HotKey -= 8192; if (HotKeyComb->Modifiers.Contains(hkAlt)) HotKey -= 32768; if (HotKeyComb->Modifiers.Contains(hkCtrl)) HotKey -= 16384; try { if (HotKeyComb->Modifiers.Contains(hkShift)) Ini->WriteBool("Options", "Mod_Shift", 1); else Ini->WriteBool("Options", "Mod_Shift", 0); if (HotKeyComb->Modifiers.Contains(hkAlt)) Ini->WriteBool("Options", "Mod_Alt", 1); else Ini->WriteBool("Options", "Mod_Alt", 0); if (HotKeyComb->Modifiers.Contains(hkCtrl)) Ini->WriteBool("Options", "Mod_Ctrl", 1); else Ini->WriteBool("Options", "Mod_Ctrl", 0); Ini->WriteInteger("Options", "HotKey", HotKey); } catch (...) { Application->MessageBoxA(LMessagesOpt.WritePrefsError, LMessagesOpt.Error, MB_OK + MB_ICONERROR); } try { if (Ini->ReadBool("Options", "Mod_Shift", 0)) Mods += MOD_SHIFT; if (Ini->ReadBool("Options", "Mod_Alt", 0)) Mods += MOD_ALT; if (Ini->ReadBool("Options", "Mod_Ctrl", 0)) Mods += MOD_CONTROL; Key = Ini->ReadInteger("Options", "HotKey", 165); } catch (...) { Application->MessageBoxA(LMessagesOpt.ReadPrefsError, LMessagesOpt.Error, MB_OK + MB_ICONERROR); } try { Ini->WriteInteger("Options", "Hot2", HotKeyComb->HotKey); } catch (...) { Application->MessageBoxA(LMessagesOpt.WritePrefsError, LMessagesOpt.Error, MB_OK + MB_ICONERROR); } if (HotKeyComb->HotKey != 0) { UnregisterHotKey(Application->Handle, 1); bool HotKey2 = RegisterHotKey(Application->Handle, 1, Mods, Key); if (!HotKey2) Application->MessageBoxA(LMessagesOpt.HotExists, LMessagesOpt.Error, MB_OK + MB_ICONWARNING); } delete Ini; SetHotkeyButton->Enabled = false; }
//--------------------------------------------------------------------------- void __fastcall TPrefsForm::FormShow(TObject* Sender) { CheckPrefsInterOpt(); try { OSdetectOpt(); TRegistry* Reg = new TRegistry; TIniFile* Ini = new TIniFile(PrefFileOpt); MinOnClose->Checked = Ini->ReadBool("Options", "MinOnClose", 1); if (Ini->ReadBool("Options", "TopPages", 1)) TopPages->Checked = true; else BottomPages->Checked = true; if (Ini->ReadBool("Options", "WorkMode", 1)) NormalMode->Checked = true; else HighMode->Checked = true; FontComboBox1->FontName = Ini->ReadString("Options", "DefaultFont", "MS Sans Serif"); DefaultFontSizePosition->Position = Ini->ReadInteger("Options", "DefaultFontSize", 10); FadeShow->Checked = Ini->ReadBool("Options", "FadeShow", 1); URLDetect->Checked = Ini->ReadBool("Options", "URLDetect", 1); Transparency->Checked = Ini->ReadBool("Options", "Transparency", 0); TransValue->Position = Ini->ReadInteger("Options", "TransValue", 255); MultiLines->Checked = Ini->ReadBool("Options", "MultiLines", 0); FadeSpeedPosition->Position = Ini->ReadInteger("Options", "FadeSpeed", 2); FadeHide->Checked = Ini->ReadBool("Options", "FadeHide", 1); IconInTray->Checked = Ini->ReadBool("Options", "TrayIcon", 1); TaskbarCheck->Checked = Ini->ReadBool("Options", "TaskbarIcon", 1); XPEffects->Checked = Ini->ReadBool("Options", "XPEffects", 1); StyleBox->ItemIndex = Ini->ReadInteger("Options", "Style", 1); HideWind->Checked = Ini->ReadBool("Options", "HideWindow", 0); HideTimePosition->Position = Ini->ReadInteger("Options", "HideTimeout", 30); AskFormat->Checked = Ini->ReadBool("Options", "AskOnFormatChange", 1); if (Ini->ReadString("Options", "DefaultPageFormat", "RTF") == "RTF") FormatPageBox->ItemIndex = 0; else FormatPageBox->ItemIndex = 1; StyleIs = StyleBox->ItemIndex; FadeShowClick(Sender); TransparencyClick(Sender); HideWindClick(Sender); if ((OSopt != "WinXP") && (OSopt != "Win2K") && (OSopt != "Win2003")) { Transparency->Checked = false; Transparency->Enabled = false; TransValue->Position = 255; TransValue->Enabled = false; FadeShow->Checked = false; FadeShow->Enabled = false; FadeSpeed->Enabled = false; FadeSpeedPosition->Enabled = false; FadeHide->Enabled = false; } StyleBoxChange(Sender); Reg->RootKey = HKEY_CURRENT_USER; Reg->OpenKey("\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", true); if (Reg->ValueExists("SimpleNotes") && (Reg->ReadString("SimpleNotes") == Application->ExeName)) StartWithWindows->Checked = true; else StartWithWindows->Checked = false; HotKeyComb->Modifiers.Clear(); int Key = Ini->ReadInteger("Options", "Hot2", 145); HotKeyComb->HotKey = Key; if (Ini->ReadBool("Options", "Mod_Shift", 0)) HotKeyComb->Modifiers << hkShift; if (Ini->ReadBool("Options", "Mod_Alt", 0)) HotKeyComb->Modifiers << hkAlt; if (Ini->ReadBool("Options", "Mod_Ctrl", 0)) HotKeyComb->Modifiers << hkCtrl; BackupPath->Text = Ini->ReadString("Options", "BackUpPath", ""); WasTop = TopPages->Checked; WasXPEffects = SNotesXMForm->TBXSwitcher1->EnableXPStyles; WasMultiLine = SNotesXMForm->AllTabs->MultiLine; WasTrayIcon = SNotesXMForm->CoolTray->IconVisible; WasTrans = SNotesXMForm->AlphaBlend; TransIs = SNotesXMForm->AlphaBlendValue; ApplyButton->Enabled = false; SetHotkeyButton->Enabled = false; PagesTree->Items->operator [](0)->Selected = true; PagesTree->SetFocus(); delete Ini; delete Reg; } catch (...) { Application->MessageBoxA(LMessagesOpt.ReadPrefsError, LMessagesOpt.Error, MB_OK + MB_ICONERROR); } }
void thOpenFile::ReadAndModifyFromBuff(char *pBuff, DWORD dwSize, const char* pszFileName) { char szErrorMsg[MAX_PATH]; char szNewFileName[MAX_PATH]; DWORD w; TIniFile *ini; TypePtr p(pBuff); if('WDBC' != TAG(*p.dw)) { _snprintf(szErrorMsg, 512, "[%s]Not Wow's dbc file!", pszFileName); ShowMessage(szErrorMsg); return; } p.dw++; DWORD dwRows, dwCols, dwRowLen, dwTextLen; dwRows = *p.dw++; dwCols = *p.dw++; dwRowLen = *p.dw++; dwTextLen = *p.dw++; FrmMain->sgEdit->RowCount = dwRows+1; FrmMain->sgEdit->ColCount = dwCols+1; for(int i=0; i<FrmMain->sgEdit->RowCount; i++){ FrmMain->sgEdit->Cells[0][i]=IntToStr(i); if(Terminated) return; } //设定列标题 AnsiString iniSetFile=ExtractFilePath(Application->ExeName)+"BcdEditer.ini"; AnsiString SectionName=ExtractFileName(FrmMain->CurrentOpenFile); ini = new TIniFile( iniSetFile ); for(int j=0; j<FrmMain->sgEdit->ColCount; j++){ FrmMain->sgEdit->Cells[j][0]= ini->ReadString(SectionName,"ColTitle"+IntToStr(j),IntToStr(j)); //sgEdit->Cells[j][0]=IntToStr(j); ColType[j]=ini->ReadInteger(SectionName,"ColType"+IntToStr(j),0); if(Terminated) return; } delete ini; //int *ColType = new int[dwCols]; DWORD dwTextStartPos = dwRows*dwRowLen+20; char* pTextPtr = pBuff + dwTextStartPos; char pszTemp[MAX_PATH]; float fTemp; long lTemp; DWORD i, j; BOOL* pbString = new BOOL[dwRows*dwCols]; float newTmp; //int ColType; ini = new TIniFile( iniSetFile ); for(i=0; i<dwRows; i++) { for(j=0; j<dwCols; j++) { //SleepEx(0,0); if(Terminated) return; lTemp = *p.l; newTmp = *p.f; memcpy(&fTemp, &newTmp, 4); if(j==0) //ID FrmMain->sgEdit->Cells[j+1][i+1]=IntToStr(lTemp); else{ //ColType= ini->ReadInteger(SectionName,"ColType"+IntToStr(j),0); switch (ColType[j+1]) { case 0: //整型 FrmMain->sgEdit->Cells[j+1][i+1]=IntToStr(lTemp); break; case 1: //浮点 FrmMain->sgEdit->Cells[j+1][i+1]=FloatToStr(fTemp); break; case 2: //文本 文本类型只能看,不能编辑 if(dwTextStartPos + lTemp < dwSize){ pTextPtr = pBuff + dwTextStartPos + lTemp; FrmMain->sgEdit->Cells[j+1][i+1]=pTextPtr; }else{ FrmMain->sgEdit->Cells[j+1][i+1]="该列不是文本"; } break; default: //整型 FrmMain->sgEdit->Cells[j+1][i+1]=IntToStr(lTemp); } } p.c += 4; } } delete [] pbString; //delete [] ColType; delete ini; }
//--------------------------------------------------------------------------- //--------------------------------------------------------------------------- void __fastcall TfrmMain::LoadSetting() { if (strcmp(LoginerPath,"")!=0) { if( FileExists( String(LoginerPath) +"\\Data\\"+ GameAccount + "\\Setting.ini" )) { TIniFile* ini = new TIniFile( String(LoginerPath) +"\\Data\\"+ GameAccount + "\\Setting.ini"); AutoGuagi_X = ini->ReadInteger("AutoGuagi","X",0); AutoGuagi_Y = ini->ReadInteger("AutoGuagi","Y",0); AutoGuagi_MapId = ini->ReadInteger("AutoGuagi","MapId",0); this->ck_func_godmode->IsChecked = ini->ReadBool("Setting","godmode",true); this->ck_func_dingua->IsChecked=ini->ReadBool("Setting","dingua",this->ck_func_dingua->IsChecked); ck_func_csx->IsChecked =ini->ReadBool("Setting","csx",this->ck_func_csx->IsChecked); //ck_func_autolr->IsChecked =ini->ReadBool("Setting","autolr",this->ck_func_autolr->IsChecked); this->ck_func_chardir->IsChecked =ini->ReadBool("Setting","chardir",this->ck_func_chardir->IsChecked); this->sw_func_chardir->IsChecked =ini->ReadBool("Setting","chardir_v",this->sw_func_chardir->IsChecked); this->ck_func_dingwei->IsChecked =ini->ReadBool("Setting","dingwei",this->ck_func_dingwei->IsChecked); this->ck_func_hidebk->IsChecked =ini->ReadBool("Setting","hidebk",this->ck_func_hidebk->IsChecked); this->ck_func_hidedmg->IsChecked =ini->ReadBool("Setting","hidedmg",this->ck_func_hidedmg->IsChecked); this->ck_func_hideskill->IsChecked =ini->ReadBool("Setting","hideskill",this->ck_func_hideskill->IsChecked); this->ck_func_itemvac->IsChecked =ini->ReadBool("Setting","itemvac",this->ck_func_itemvac->IsChecked); this->ck_func_jmp->IsChecked =ini->ReadBool("Setting","jmp",this->ck_func_jmp->IsChecked); this->ck_func_stupid->IsChecked =ini->ReadBool("Setting","stupid",this->ck_func_stupid->IsChecked); this->ck_hp->IsChecked =ini->ReadBool("Protect","hp",this->ck_hp->IsChecked); this->ck_mp->IsChecked =ini->ReadBool("Protect","mp",this->ck_mp->IsChecked); this->ck_att->IsChecked =ini->ReadBool("Protect","att",this->ck_att->IsChecked); this->ck_pick->IsChecked =ini->ReadBool("Protect","pick",this->ck_pick->IsChecked); this->ck_key1->IsChecked =ini->ReadBool("Protect","key1",this->ck_key1->IsChecked); this->ck_key2->IsChecked =ini->ReadBool("Protect","key2",this->ck_key2->IsChecked); this->ck_key3->IsChecked =ini->ReadBool("Protect","key3",this->ck_key3->IsChecked); this->ck_key4->IsChecked =ini->ReadBool("Protect","key4",this->ck_key4->IsChecked); this->txt_hp->Text =ini->ReadString("Protect","hp_v",this->txt_hp->Text); this->txt_mp->Text =ini->ReadString("Protect","mp_v",this->txt_mp->Text); this->txt_att->Text =ini->ReadString("Protect","att_v",this->txt_att->Text); this->txt_pick->Text =ini->ReadString("Protect","pick_v",this->txt_pick->Text); this->txt_key1->Text =ini->ReadString("Protect","key1_v",this->txt_key1->Text); this->txt_key2->Text =ini->ReadString("Protect","key2_v",this->txt_key2->Text); this->txt_key3->Text =ini->ReadString("Protect","key4_v",this->txt_key3->Text); this->txt_key4->Text =ini->ReadString("Protect","key3_v",this->txt_key4->Text); this->cb_att->Selected->Text =ini->ReadString("Protect","att_k",this->cb_att->Selected->Text); this->cb_att->ItemIndex = ini->ReadInteger("Protect","att_k",this->cb_att->ItemIndex); this->cb_pick->ItemIndex = ini->ReadInteger("Protect","pick_k",this->cb_pick->ItemIndex); this->cb_key1->ItemIndex=ini->ReadInteger("Protect","key1_k",this->cb_key1->ItemIndex); this->cb_key2->ItemIndex= ini->ReadInteger("Protect","key2_k",this->cb_key2->ItemIndex); this->cb_key3->ItemIndex=ini->ReadInteger("Protect","key4_k",this->cb_key3->ItemIndex); this->cb_key4->ItemIndex=ini->ReadInteger("Protect","key3_k",this->cb_key4->ItemIndex); AutoKey_HP_Value = StrToInt(txt_hp->Text); AutoKey_MP_Value = StrToInt(txt_mp->Text); AutoKey_Att_Time = StrToInt(txt_att->Text); AutoKey_Pick_Time = StrToInt(txt_pick->Text); AutoKey_Skill_Time[0] = StrToInt(txt_key1->Text); AutoKey_Skill_Time[1] = StrToInt(txt_key2->Text); AutoKey_Skill_Time[2] = StrToInt(txt_key3->Text); AutoKey_Skill_Time[3] = StrToInt(txt_key4->Text); AutoKey_Att_Key = GetVirtualKeyCodeByName(AnsiString(cb_att->Selected->Text).c_str()); AutoKey_Pick_Key = GetVirtualKeyCodeByName(AnsiString(cb_pick->Selected->Text).c_str()); AutoKey_Skill_Key[0] = GetVirtualKeyCodeByName(AnsiString(cb_key1->Selected->Text).c_str()); AutoKey_Skill_Key[1] = GetVirtualKeyCodeByName(AnsiString(cb_key2->Selected->Text).c_str()); AutoKey_Skill_Key[2] = GetVirtualKeyCodeByName(AnsiString(cb_key3->Selected->Text).c_str()); AutoKey_Skill_Key[3] = GetVirtualKeyCodeByName(AnsiString(cb_key4->Selected->Text).c_str()); } } }