在线等候解答:Delphi中的string[10] 对应C++Builder的什么含义?

Pasp 2005-09-21 02:10:12
例如: Delphi声明: name : string[10];
转化成C++应该如何声明?
...全文
93 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
7rainbow 2005-09-21
  • 打赏
  • 举报
回复
楼上说的对,
String[n] 老式的Delphi字符串, n = 1..255字节

类似C中字符串操作。 char name[n]
hellolongbin 2005-09-21
  • 打赏
  • 举报
回复
错了,那样定义的话成了string数组了

就定义成
char name[10];
好了
hellolongbin 2005-09-21
  • 打赏
  • 举报
回复
AnsiString name[10]
mee123456 2005-09-21
  • 打赏
  • 举报
回复
应该是声明一个字符串数组,在BCB中这样写:
String name[10];
Pasp 2005-09-21
  • 打赏
  • 举报
回复
有没人会啊?
SQLMemTable for Delphi / C++ Builder: README============================================Please read this file carefully (especially the INSTALLATION chapter) before installing the program to your computer.Contents-------- Program information Company information Description Specification Features and Benefits Installation Purchasing / Registration Copyright and licenses Warranty and guarantee Technical support Important note Other products recommended to useProgram information-------------------Program Name: SQLMemTableLicense Types: Personal (for personal use, without source code) Com (for 1 developer, without source code) Pro (for 1 developer, with source code) Team4 (for 4 developers, with source code) Team8 (for 8 developers, with source code) Enterprise (Enterprise License - for entire company, with source code)Program Version: 1.00Program Release Date: 07/15/2003Program Purpose: SQLMemTable is a compact, fast and powerful in-memory table with SQL support. Target Environment: Delphi 4, 5, 6, 7 and C++ Builder 4, 5, 6.Company information-------------------Company Name: AidAim SoftwareContact E-mail Address: support@aidaim.comContact WWW URL: http://www.aidaim.comDescription-----------SQLMemTable is a compact in-memory table with SQL support for Delphi and C++ Builder. SQLMemTable does not require BDE and provides all the TTable‘s functionssuch as Master/Detail relationship, Filtering, Searching, Sorting, Key, Range, BLOB fields, and has some advanced features such as BLOB data compression, multi-indexes and table restructuring, shareable in memory capabilities. It is fully compatible with all standard DB controls, supports calculated and lookup fields as well as internationalization/localization and Unicode, provides data importing from and exporting to any dataset, includes SQLConsole utility with source code, comprehensive help and demos.SQLMemTable provides the following services: - SQL support - Master / detail relationship - Creating, renaming, emptying, deleting and restructuring tables - Creating, editing, deleting, navigating and searching for records - Creating and deleting multiple indexes - Calculated and lookup fields - Filtering support - Using BLOB fields with data compression ability - Importing from and exporting to any dataset in fast and easy way - Internationalization/Localization and Unicode supportSQLMemTable does not require BDE or any external drivers and has small footprint. Its search performance is excellent and data access speed is extremely fast.Specification-------------Data types: ftAutoInc, ftInteger, ftSmallInt, ftFloat, ftDateTime, ftDate, ftTime, ftBLOB, ftMemo, ftGraphic, ftString (any fixed length string), ftCurrency, ftWord, ftBoolean, ftLargeInt, ftFmtMemo, ftBytes, ftWideString.Advanced data types: aftExtended, aftWideMemoMaximum records quantity: up to 2^31 (over 2 billions). Maximum fields per table: 2^31 (over 2 billions). Maximum indexes per table: 2^31 (over 2 billions). Maximum index fields per index: 2^31 (over 2 billions). Maximum field name‘s length: 255 characters.Maximum index name‘s length: 255 characters.BLOB fields block size: > 1 byte, default 100 Kb. BLOB compression: ZLib, BZip, PPM Search operators: <,>,=,<>,<=,>=, like, not like, is null, is not null, and, or, not, (). Features and Benefits---------------------Compactness. - Short compiled code with approximate size 300 Kb, no external drivers (such as BDE) required. - Small memory consumption by SQLMemTable database engine. - Fast BLOB data compression. Your large data fields will need less memory. SQLMemTable can compress data on the fly. The compression routines used in the SQLMemTable are much faster than most of popular archivers like PKZip, WinRar, Arj. High performance. - Fast search by B-tree indexes. At the moment SQLMemTable is one of the fastest existing in-memory tables for Delphi and C++ Builder. - High-speed memory operations performance is achieved by means of using specially optimized memory manager and tuned algorithms. - Quick operations with strings. SQLMemTable compares strings up to 3 times faster than standard Delphi string routines. High performance is achieved by using a special library written in Assembler and an advanced sorting algorithm. - Advanced SQL optimizer often makes query execution several times faster by choosing the best execution plans. Functionality. - A subset of SQL‘92 including DDL operators is supported by TSQLMemQuery component. With SQLMemTable you can create SQL scripts for creating tables, inserting, editing and deleting records, retrieving data by SELECT command. - Advanced search engine. SQLMemTable supports ‘LIKE‘ operator with wildcards ‘%‘ and ‘_‘, as well as ‘IS NULL‘ and ‘IS NOT NULL‘ in filters and queries. - Full multiple index support, i.e. numerous fields in a table may comprise an index. SQLMemTable provides descending and ascending indexes, case-sensitive and insensitive indexes for string fields. - Shareable in-memory tables. SQLMemTable supports simultaneous access to a table by multiple TSQLMemTable components within a single application. - Default values support. - Record-level constraints, i.e. constraints that must be met when editing the data. Compatibility. - SQLMemTable supports most of TTable field data types, including BLOB fields, moreover it allows to create string and wide string fields of any fixed length. - SQLMemTable is fully compatible with standard DB-aware visual controls such as QuickReport, DBGrid, DBNavigator, DBImage, DBMemo, DBRichEdit, as well as with third party vendor‘s products supporting TDataset descendant components - FastReport, DBFlyTreeView and others. - Calculated and lookup fields can be used in the same way as TTable. - Most of TTable functions are supported including Key and Range methods. Convenience. - Table restructuring is being performed in the easiest way keeping all the existing data. - Data importing from and exporting to any dataset is supported. SQLMemTable provides you with the simplest way to import and export tables using ImportTable and ExportTable methods. - Internationalization / localization support. All text search and sorting functions use current system locale, so localizing your program with SQLMemTable is a very simple task. - Unicode support. All the text operations work with multi-byte encoding using ftWideString. - Comprehensive help. SQLMemTable comes with full documentation presented in SQLMemTable Developer‘s Guide and SQLMemTable Reference. Installation------------1) Make sure that all copies of Delphi (or C++ Builder) are currently closed and not running on the target system. Also, if you are replacing an existing version of SQLMemTable, please remove all files and the package of the prior version before running the new setup program.2) Unpack zip archive containing SQLMemTable into any directory. 3) Run the INSTALL.EXE from this directory.4) Follow on-screen instructions of step-by-step setup wizard to install SQLMemTable.5) If after the installation SQLMemTable components don‘t appear in Components Palette of the IDE, please follow the next instructions: * From the IDE, select ‘Component | Install Packages...‘. * Click the ‘Add‘ button. * In the ..SQLMemTableLibDelphi# (or ..SQLMemTableLibC++ Builder#) directory, select the dclSQLMemTableD#.BPL (or dclSQLMemTableB#.BPL) file. * Click the ‘OK‘ button to close the dialog. * Finally, select ‘Tools | Environment Options‘ from the main menu. From this dialog, select the ‘Library‘ tab and insure that the ..SQLMemTableLibDelphi# (or ..SQLMemTableLibC++ Builder#) directory is included in the ‘Library Path‘ line.Purchasing / Registration-------------------------Visit our site http://www.aidaim.com to purchase or register the product.Copyright and license---------------------See "license.txt" file.Warranty and guarantee----------------------See "license.txt" file.Technical support-----------------Before you contact us, please do the following: - Make sure you have performed all the required steps correctly. - Look at the Help files and Demos: it may already contain an answer to your question. A lot of people ask us something like "how do I:", though the complete information is there. - Visit our Internet site at http://www.aidaim.com. It‘s a good chance that you‘ll find the newer version of our product there.If the problem persists, please, inform us about the following: - SQLMemTable version. - Where did you obtain SQLMemTable (http or ftp site). - Compiler information: Delphi or C++ Builder, Version, Edition, Service Pack - Environmental information: your OS and Service Pack - Description of your problem (as much information as possible to retrieve the problem). - Attach a test project where the problem could be reproduced (it helps us to solve your issue as soon as possible)Typically AidAim Software Support Team answer messages in 24 hours, but depending on singularity and difficulty of your question it may take a bit longer.Should you have any ideas on improving the existing functions of this product after you have downloaded and used it, be easy to e-mail us. All registered users who buy this product may also send their offers to add new possibilities and/or to change the product‘s functions.We consider any ideas and we may take them into account while creating new versions of our products.Other products AidAim Software recommended-------------------------------------------All the products in this chapter are fully compatible with SQLMemTable and recommended to work with our product. AidAim Software had tested all these products released by our partner companies for complete compatibility with SQLMemTable. In its turn, all the partner companies have carried out similar testing of the compatibilityof SQLMemTable with their own products. All the companies whose products present here are technology partners of AidAim Software. It means that both partner companies guarantee the correct joint work of the products. In case of encountering bugs in the time of joint work and owing to it, the partners incur the obligation to resolve such problems for their clients for FREE. FastReport Software -------------------Advanced report generators for Delphi and Kylix.Web Site: http://www.fast-report.comFastReport VCL--------------FastReport VCL is reporting tool component for Borland Delphi 2-6 and Borland C++Builder 3-5. It consists of report engine, designer and preview. Some FastReport possibilities are really unique. The generator allows you to create tables, queries and databases in run-time. Built-in dialog designer allows you creation of dialog forms (they can be used for asking some parameters before printing a report). You also able to use built-in Pascal-like interpreter to do rather complex data processing. In spite of power of FastReport, its code is quite small. Probably FastReport is leader in correlation of functionality/size. The FastReport kernel (without designer) adds to your program the small footprint (less than QR3), but its functionality is like in ReportBuilder‘s one.FastReport CLX edition----------------------FastReport CLX edition is powerfull of FastReport for Borland Delphi 6 and Borland Kylix 1-2 for Linux. It use new CLX-library. Do you want to create reports for Linux as well as for Windows? Use FastReport CLX edition!FastReport VCL 2.3 lite-----------------------FreeWare version of FastReport. Imca Systems DevTeam --------------------Imca Systems DevTeam - Flexible and powerful Delphi/C++ Builder/ActiveX trees, grids and editors.Web Site: http://www.9rays.netDBFlyTreeView Suite-------------------Add grid and treeview functionality with a single component. DBFlyTreeView is a fully customizable, data-bound grid and tree view component that allows you to add huge arrays of nodes. OLE drag-and-drop is supported and the component is customizable at both design-time and runtime. DBFlyTreeView supports custom colors, fonts, and alignment for each cell, and you can even create scrollable background wallpapers without creating huge bitmaps.Included: RapidTree, FlyTreeView, PropertiesTree, DBFlyTreeView controls.DBFlyTreeViewPro Suite----------------------Enable your Delphi and C++Builder applications to display and browse hierarchical, table, and list data. DBFlyTreeViewPro Suite is a set of VCL components that are a direct descendent from FlyTreeViewPro. It supports more than 40 types of in place editors plus your custom format. It is data-aware and allows you to draw any array of cells directly to a printer, Metafile, or Bitmap canvas.Included: RapidTree, IsPlugeditor, FlyTreeViewPro, PropertiesTreePro, DBFlyTreeViewPro controls.
TsiLang® Components Suite includes a number of highly professional, easy-to-use VCL components, wizards and tools for building multi-language applications under Delphi and C++Builder. On the one hand, our product dramatically simplifies the entire process of globalization, and on the other hand it allows you to provide your customers with quality, user-friendly applications that can switch from one locale to another on-the-fly. We would like to describe some of the features of TsiLang Components Suite that make the product unique: Our suite enables you to localize everything that should be localized: string-type properties of components, "hard-coded" string constants, resource strings, system locale and standard dialog strings, as well as other properties that may affect the appearance of controls (for example, the size and position of labels may be changed for each language if required). You can choose where to store the translation data: either internally (this is ideal for lightweight applications – a single EXE file, no DLLs, databases, etc) or externally in special files (this approach allows you to change translations without recompiling the project, so even your end-user may update the translations at run-time). Such essential tools as TsiLang Expert and Resource Strings Wizard, which are included in the suite, help you to manage the translation process of you projects in a simple and convenient fashion. So, a large project might be prepared for globalization literally in a few minutes. The TsiLang Expert adds TsiLang components to the project's forms and data modules, adjusts their properties, and scans the project files for "hard-coded" strings. TheResource Strings Wizard allows you to extract and add to translation data the resource strings of your project even if they are hidden somewhere in a .dcu (.obj) file without the source code. A specialized tool shipped with the suite, the SIL Editor, can be freely redistributed and allows you to separate the tra
unit TreeViewFunctions; interface uses Windows, Messages, SysUtils, Variants, Classes, ComCtrls, Controls, Forms, FileCtrl, StrUtils, Masks, Vcl.OleCtrls, SHDocVw, IOUtils; procedure SaveTreeViewExplandState(TreeView: TTreeView; FileName: string); procedure LoadTreeViewExplandState(TreeView: TTreeView; FileName: string); function ExtractNewFolderPath(FileName: string; NewText: string): string; procedure HideHideHorizontalScrollBar(TreeView: TTreeView); function IsEmptyDir(sDir: String): Boolean; function AttachMentsExists(FileName: String): Boolean; procedure SetIcons(TreeView: TTreeView; list: TStringList); procedure EnumText(s: string; aItem: TTreeNode); function AttachmentsFolder(FileName: String): string; function ExtractNodeFullPath(TreeView: TTreeView): string; function Get_node_path(node: TTreeNode): string; function ExtractTreeViewFileName(RootPath: string; TreeView: TTreeView): string; /// /// Node.Selected := true; Node.Focused := true; /// /// /// Node.Selected := true; Node.Focused := true; /// /// /// Node.Selected := true; Node.Focused := true; /// function OpenFile(Path: string; RichEdit: TRichEdit; TreeView: TTreeView) : Boolean; overload; function OpenFile(Path: string; Webbrowser: TWebbrowser; TreeView: TTreeView) : Boolean; overload; procedure GetDirectories(Tree: TTreeView; Directory: string; Item: TTreeNode; IncludeFiles: Boolean); procedure DirToTreeView(Tree: TTreeView; Directory: string; Root: TTreeNode; IncludeFiles: Boolean; FileExt: string); procedure QSetPerpoty(TreeView: TTreeView); function ItemExist(Text: string; TreeView: TTreeView): Boolean; function RemoveDirs(folderPath: string): Boolean; function __RenameFile(OldName: string; Title: string): Boolean; function RenameFolder(filePath: string; Title: string): Boolean; var list: TStringList; implementation { // "D:\C++Builder学习大全文版\index.htm" // "D:\C++Builder学习大全文版\" // "index_files" // "D:\C++Builder学习大全文版\index_files" var s, s1, s2: string; begin s := 'D:\C++Builder学习大全文版\index.htm'; s1:=ExtractNewFolderPath(s,'_files'); s2 := ExtractNewFolderPath(s, '_AttachMents'); Memo1.lines.Add(s); Memo1.Lines.Add(s1); Memo1.lines.Add(s2); end; } function ExtractNewFolderPath(FileName: string; NewText: string): string; var _filesFolder: string; // "D:\C++Builder学习大全文版\" _filesFolderName: string; // "index_files" _filesFolderPath: String; begin _filesFolder := ExtractFilePath(FileName); _filesFolderName := ChangeFileExt(ExtractFileName(FileName), '') + NewText; _filesFolderPath := _filesFolder + _filesFolderName; Result := _filesFolderPath; end; { SaveTreeViewExplandState(TreeView1,'TreeView.txt'); } procedure SaveTreeViewExplandState(TreeView: TTreeView; FileName: string); var list: TStringList; i: Integer; begin list := TStringList.Create; With TreeView do begin for i := 0 to Items.Count - 1 do begin if Items.Item[i].Expanded then list.Add(IntToStr(i)); end; list.Add(IntToStr(Selected.AbsoluteIndex)); end; list.SaveToFile(FileName); list.free; end; { LoadTreeViewExplandState(TreeView1, 'abc.txt'); } procedure LoadTreeViewExplandState(TreeView: TTreeView; FileName: string); var list: TStringList; i: Integer; node: TTreeNode; begin list := TStringList.Create; with list do begin list.LoadFromFile(FileName); for i := 0 to Count - 2 do // 最后一行放的是最后选的那个节点索引 begin TreeView.Items[StrToInt(list[i])].Expand(False); end; node := TreeView.Items[StrToInt(list[Count - 1])]; TreeView.Select(TreeView.Items[StrToInt(list[Count - 1])], []); // node.Selected := True; // node.Focused := True; TreeView.SetFocus; TreeView.Focused; free; end; end; { FUNCTION ulong ShowScrollBar(ulong hwnd,ulong wBar,ulong bShow) LIBRARY "user32.dll" constant long SB_HORZ = 0 constant long SB_VERT = 1 constant long SB_BOTH = 3 } procedure HideHideHorizontalScrollBar(TreeView: TTreeView); begin // no responed NEW FORM TEST // ShowScrollBar(TreeView.Handle,SB_HORZ,False); end; // procedure // begin // { 当拖拽的高度不够的时候自动滚动滚动条 } // with TreeView1 do // begin // if (Y < 15) then // SendMessage(Handle, WM_VSCROLL, SB_LINEUP, 0) // else if (Height - Y < 15) then // SendMessage(Handle, WM_VSCROLL, SB_LINEDOWN, 0); // end; // end; { 返回 附件文件夹 "D:\C++Builder学习大全文版\新建文本文档.htm" D:\C++Builder学习大全文版\新建文本文档_Attachments } function AttachmentsFolder(FileName: String): string; begin Result := ExtractFilePath(FileName) + ChangeFileExt(ExtractFileName(FileName), '') + '_Attachments'; end; function AttachMentsExists(FileName: String): Boolean; var f: string; begin f := ExtractFilePath(FileName) + ChangeFileExt(ExtractFileName(FileName), '') + '_Attachments'; Result := DirectoryExists(f); end; procedure EnumText(s: string; aItem: TTreeNode); var node: TTreeNode; str: string; begin node := aItem; while node nil do begin if s = '' then str := node.Text else str := s + '\' + node.Text; list.Add(str); /// ////////////////////////// if node.HasChildren then EnumText(str, node.getFirstChild); node := node.getNextSibling; end; end; function IsEmptyDir(sDir: String): Boolean; var sr: TSearchRec; begin Result := True; if Copy(sDir, Length(sDir) - 1, 1) '\' then sDir := sDir + '\'; if FindFirst(sDir + '*.*', faAnyFile, sr) = 0 then repeat if (sr.Name '.') and (sr.Name '..') then begin Result := False; break; end; until FindNext(sr) 0; FindClose(sr); end; { 是文件 夹的设置为1 是文件 的设置为 2 } procedure SetIcons(TreeView: TTreeView; list: TStringList); var i: Integer; begin with TreeView do begin for i := 0 to Items.Count - 1 do begin if DirectoryExists(list.Strings[i]) then begin Items[i].ImageIndex := 0; Items[i].SelectedIndex := 0; Items[i].StateIndex := 0; end; if FileExists(list.Strings[i]) then begin Items[i].ImageIndex := 1; Items[i].SelectedIndex := 1; Items[i].StateIndex := 1; end; if (AttachMentsExists(list.Strings[i])) then if not IsEmptyDir(AttachmentsFolder(list.Strings[i])) then begin // Form1.Memo1.LINES.Add( AttachmentsFolder(list.Strings[i])); Items[i].ImageIndex := 2; Items[i].SelectedIndex := 2; Items[i].StateIndex := 2; end; end; end; end; procedure QSetPerpoty(TreeView: TTreeView); begin with TreeView do begin // Align := alBottom; // Anchors := [akLeft, akTop, akBottom, akRight]; Items.Clear; // BorderStyle := bsNone; Cursor := crHandPoint; ReadOnly := True; ShowHint := True; RowSelect := True; ShowButtons := True; ShowRoot := True; ShowLines := False; SortType := stText; HideSelection := False; RightClickSelect := True; DragMode := dmAutomatic; // Color := RGB(238, 243, 246); end; end; { 实际重命名 C:\windows\test.txt C:\windows\csadsajas.txt MoveFile(PChar('C:\1.txt'),PChar('C:\ABC.txt')); if not __RenameFile('C:\tree.txt','TreeView') then Application.MessageBox('重命名文件失败','重命名',MB_ICONERROR); } { 重命名文件 } function __RenameFile(OldName: string; Title: string): Boolean; var NewName: string; begin NewName := Format('%s%s%s', [ExtractFilePath(OldName), Title, ExtractFileExt(OldName)]); Result := MoveFile(PChar(OldName), PChar(NewName)); end; // 重命名文件夹 // RenameFolder('C:\1\','2'); // MoveFile('C:\1','C:\2'); // MoveFile('C:\1\','C:\2\'); function RenameFolder(filePath: string; Title: string): Boolean; var s, s1: string; begin // filePath:='C:\Windows\System32\'; // s = ExtractFileDir(filepath) = 'C:\Windows\System32' s := ExtractFileDir(filePath); // s1 = ExtractFileDir(s) = 'C:\Windows' // s1 ='C:\Windows' +'\'+ titles s1 := ExtractFileDir(s) + '\' + Title; Result := MoveFile(PChar(s), PChar(s1)); end; { IOUtils } function RemoveDirs(folderPath: string): Boolean; begin Result := False; if TDirectory.IsEmpty(folderPath) then begin TDirectory.Delete(folderPath); Result := True; end else begin if Application.MessageBox('确定要删除这个文件夹吗? 删除后无法恢复!', '提示', MB_ICONQUESTION + MB_YESNO) = ID_YES then begin TDirectory.Delete(folderPath, True); Result := True; end; end; // if TDirectory.Exists(folderPath) then // begin // Application.MessageBox('删除文件失败'+#13#10+'文件正确被使用?','错误',MB_ICONERROR+MB_OK); // Result:=False; // end; end; { if not ItemExist('Edit1.Text',TreeView1) then TreeView1.Items.AddChild(Treeview1.Selected,'Edit1.Text'); } function ItemExist(Text: string; TreeView: TTreeView): Boolean; var i: Integer; begin Result := False; if (Trim(Text) '') then begin for i := 0 to TreeView.Items.Count - 1 do if Trim(Text) = Trim(TreeView.Items[i].Text) then begin Result := True; Exit; end; end; Result := False; end; // ------------------------------------------------------------------------------ { TreeView获得选的完整路径 aaaa\ssss\bbbb } function ExtractNodeFullPath(TreeView: TTreeView): string; var Path: string; Parent: TTreeNode; // Node: TTreeNode; begin Path := TreeView.Selected.Text; Parent := TreeView.Selected.Parent; while Parent nil do begin Path := Parent.Text + '\' + Path; Parent := Parent.Parent; end; Result := Path; end; function Get_node_path(node: TTreeNode): string; var Path: string; TreeNode: TTreeNode; begin Path := node.Text; TreeNode := node.Parent; while TreeNode nil do begin Path := TreeNode.Text + '\' + Path; TreeNode := TreeNode.Parent; end; Result := Path; end; { 获得文件完整路径 C:\abc\int.cpp } function ExtractTreeViewFileName(RootPath: string; TreeView: TTreeView): string; var FileName: string; begin Result := ''; if TreeView.Selected = nil then Exit; FileName := RootPath + ExtractNodeFullPath(TreeView); // 当前选的文件名 if not FileExists(FileName) then Exit; Result := FileName; end; { 用RICHEDIT打开TREEVIEW的文件 } function OpenFile(Path: string; RichEdit: TRichEdit; TreeView: TTreeView) : Boolean; overload; var FileName: string; begin Result := False; FileName := ExtractTreeViewFileName(Path, TreeView); if FileExists(FileName) then begin RichEdit.Lines.LoadFromFile(FileName); Result := True; end end; function OpenFile(Path: string; Webbrowser: TWebbrowser; TreeView: TTreeView) : Boolean; overload; var FileName: string; begin Result := False; FileName := ExtractTreeViewFileName(Path, TreeView); if FileExists(FileName) then begin Webbrowser.Navigate(FileName); Result := True; end end; { 将1个目录里面所有的文件添加到TREEVIEW GetDirectories(TreeView1, 'D:\DATA', nil, True); } procedure GetDirectories(Tree: TTreeView; Directory: string; Item: TTreeNode; IncludeFiles: Boolean); var SearchRec: TSearchRec; ItemTemp: TTreeNode; begin Tree.Items.BeginUpdate; if Directory[Length(Directory)] '\' then Directory := Directory + '\'; if FindFirst(Directory + '*.*', faDirectory, SearchRec) = 0 then begin repeat if (SearchRec.Attr and faDirectory = faDirectory) and (SearchRec.Name[1] '.') then begin if (SearchRec.Attr and faDirectory > 0) then Item := Tree.Items.AddChild(Item, SearchRec.Name); ItemTemp := Item.Parent; GetDirectories(Tree, Directory + SearchRec.Name, Item, IncludeFiles); Item := ItemTemp; end else if IncludeFiles then if SearchRec.Name[1] '.' then Tree.Items.AddChild(Item, SearchRec.Name); until FindNext(SearchRec) 0; FindClose(SearchRec); Tree.Items.EndUpdate; end; end; { 将1个目录里面所有的文件添加到TREEVIEW DirToTreeView(TreeView1,'D:\Data\',nil,True,'.cpp'); } procedure DirToTreeView(Tree: TTreeView; Directory: string; Root: TTreeNode; IncludeFiles: Boolean; FileExt: string); var SearchRec: TSearchRec; Node1: TTreeNode; begin with Tree.Items do begin BeginUpdate; if Directory[Length(Directory)] '\' then Directory := Directory + '\'; if FindFirst(Directory + '*.*', faDirectory, SearchRec) = 0 then begin Application.ProcessMessages; repeat { 添加文件夹 } if (SearchRec.Attr and faDirectory = faDirectory) and (SearchRec.Name[1] '.') then begin if SameText(RightStr(SearchRec.Name, 12), '_AttachMents') then // 不添加 _AttachMents这个文件夹 Continue; if (SearchRec.Attr and faDirectory > 0) then Root := AddChild(Root, SearchRec.Name); Node1 := Root.Parent; DirToTreeView(Tree, Directory + SearchRec.Name, Root, IncludeFiles, FileExt); Root := Node1; end else if IncludeFiles then { 添加文件 } if SearchRec.Name[1] '.' then { .TXT .txt .TxT .tXT 为一样的 } if SameText(RightStr(SearchRec.Name, 4), FileExt) then { 只添加 .CPP格式文件 } AddChild(Root, SearchRec.Name); until FindNext(SearchRec) 0; FindClose(SearchRec) end; EndUpdate; end; end; end.

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧