当前位置: 首页>>代码示例>>C++>>正文


C++ TStringList::AddStrings方法代码示例

本文整理汇总了C++中TStringList::AddStrings方法的典型用法代码示例。如果您正苦于以下问题:C++ TStringList::AddStrings方法的具体用法?C++ TStringList::AddStrings怎么用?C++ TStringList::AddStrings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TStringList的用法示例。


在下文中一共展示了TStringList::AddStrings方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ButtonMergeServersClick

//---------------------------------------------------------------------------
void __fastcall TXirconForm::ButtonMergeServersClick(TObject *Sender)
{
  if ( Memo1->Lines->Count == 0 )
  {
    ShowMessage("No keys to write... first import from mIRC.ini");
    return;
  }

  String StrIdx, TempStr;

  TStringList* pSlNew = new TStringList();
  TStringList* pSlOld = new TStringList();
  TRegistry * MyRegistry = new TRegistry();

  try
  {
    if ( !pSlNew || !pSlOld  )
    {
      ShowMessage("Unable to create string-list!");
      return;
    }

    // Purge duplicates from new mIRC Memo1 servers...
    if ( CheckBoxElimDups->Checked )
    {
      pSlNew->Sorted = true;
      pSlNew->Duplicates = dupIgnore;
      pSlOld->Sorted = true;
      pSlOld->Duplicates = dupIgnore;
    }
    else
    {
      pSlNew->Sorted = false;
      pSlNew->Duplicates = dupAccept;
      pSlOld->Sorted = false;
      pSlOld->Duplicates = dupAccept;
    }

    // Fill StringList from new servers in Memo1, possibly sorting
    // and purging duplicates.
    pSlNew->AddStrings(Memo1->Lines);

    // Read existing server-list
    bool bHaveExisting = ReadXircServers( pSlOld );

    if ( bHaveExisting )
    {
      if ( !EraseXircServers() )
      {
        ShowMessage("Unable to erase old server-list!");
        return;
      }
    }

    MyRegistry->RootKey = HKEY_CURRENT_USER;

    if ( !MyRegistry->OpenKey(RegKey, true) )
    {
      ShowMessage("Unable to create registry key!");
      return;
    }

    // Merge the old list into the new...
    pSlNew->AddStrings(pSlOld);

    int RegIndex = 1;
    int NewIndex = 0;
    String TempStr;

    // Start writing merged server-list, up to 999 max
    for ( ; NewIndex < pSlNew->Count && RegIndex < 1000; NewIndex++ )
    {
      try
      {
        StrIdx = String( RegIndex );

        if ( RegIndex < 100 )
          StrIdx.Insert( "0", 1 );

        if ( RegIndex < 10 )
          StrIdx.Insert( "0", 1 );

        TempStr = pSlNew->Strings[NewIndex];

        if ( TempStr.Length() )
          MyRegistry->WriteString( StrIdx, TempStr );

        RegIndex++;
      }
      catch(...)
      {
        ShowMessage("Registry-write error during list merge!\n" + TempStr);
        return;
      }
    }

    ShowMessage("Wrote " + String(RegIndex-1) + " total servers!" );
    if ( pSlNew->Count > 999 )
      ShowMessage("Warning, " + String(pSlNew->Count-999) + " server(s)\n"
//.........这里部分代码省略.........
开发者ID:dxzl,项目名称:xircon-server-importer,代码行数:101,代码来源:MainForm.cpp


注:本文中的TStringList::AddStrings方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。