2023年全國碩士研究生考試考研英語一試題真題(含答案詳解+作文范文)_第1頁
已閱讀1頁,還剩12頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、<p>  附錄A 外文翻譯-原文部分</p><p>  Computer programming data structure is an important theoretical basis for the design, it is not only the core curriculum of computer disciplines, and has become a popular el

2、ective course other Polytechnic professional, so studied this course well and studied computer are closely related.</p><p>  一、the concept of data structure</p><p>  Computer data structure is t

3、he foundation of science and technology professional classes, is the essential core curriculum. All computer system software and application software to use various types of data structures. Therefore, if we want to make

4、 better use of computers to solve practical problems, only to several computer programming languages are difficult to cope with the many complex issues. To the effective use of computers, give full play to computer perfo

5、rmance, but also must learn and </p><p>  二、why should learn from data structure?</p><p>  In the early development of computers, the use of computer designed primarily to deal with terms. When

6、we use the computer to solve a specific problem, the following general needs through several steps : the first is a specific problem of appropriate abstract mathematical models, and then design or choose a mathematical m

7、odel of the algorithm,the final procedures for debugging, testing, until they have the ultimate answer. </p><p>  Since then the object is INTEGER, REAL, BOOLEAN, the procedures of the main designers of en

8、ergy is focused on programming skills, without attention to the data structure. With the expansion of computer applications and development of software and hardware, the issue of non-terms increasing importance. Accordin

9、g to statistics, Now dealing with the issue of non-occupancy of more than 90% of the machine time. Such issues involve more complex data structure, the relationships between data elements g</p><p>  Descript

10、ion of the terms of such non-mathematical model is not a mathematical equation, but such as tables, trees, such as map data structure. Therefore, it can be said that data structure courses primarily designed to study the

11、 issue of non-value calculation procedures as a computer operations and the relationship between objects and their operating disciplines. </p><p>  The purpose of the study is to understand the structure of

12、data for computer processing of the identity object to the practical problems involved in dealing with that subject at the computer out and deal with them. At the same time, through training algorithms to improve the thi

13、nking ability of students through procedures designed to promote student skills integrated applications and professional qualities.</p><p>  三、the concepts and terminology</p><p>  Systematic st

14、udy of knowledge in the data structure before some of the basic concepts and terminology to give a precise meaning. </p><p>  Data (Data) is the information carrier, it could be computer identification, st

15、orage and processing. It is the computer processing of raw materials, a variety of data processing applications. Computer science, computer processing is the so-called data objects, which can be numerical data can be non

16、 - numerical data. Numerical data are integer, the actual number or plural, mainly for engineering computing, scientific computing and commercial processing; Non - numerical data, including characters,</p><p&g

17、t;  Data elements (Data Element) is the basic unit of data. In different conditions, data elements can be called elements, nodes, the peak, recording. For example, students information retrieval system table information,

18、 a record high, 8 Queen's issue of a state tree, teaching programming issues such as a peak, known as a data element. Sometimes, a data from a number of data elements (Data Item), for example, the student informati

19、on management system students each data element table is a student r</p><p>  Data objects (Data Object) or data element type (Data Element Class) is the nature of the data elements with the same pool. In a

20、specific issue, the data elements have the same nature (not necessarily equal value elements), belonging to the same data objects (data element type), the data element is an example of such data elements. For example, tr

21、affic information systems in the transportation network, is a culmination of all the data elements category, peak a and B each represent an urban middl</p><p>  Data structure (Data Structure) refers to the

22、mutual relationship that exists between one or more data elements together. In any case, between data elements will not be isolated in between them exist in one way or another, such as the relationship between the data e

23、lement structure. According to the data elements of the relationship between different characteristics, usually have the following four basic categories of the structure : </p><p>  1 assembly structures.

24、In the assembly structure, the relationship between data elements is "belonging to the same pool." Assembly elements relations is a very loose structure. </p><p>  2 linear structures. The struct

25、ure of the data elements exist between one-to-one relationship. </p><p>  3 tree structure. The structure of the data elements exist between hierarchical relationship. </p><p>  4graphics st

26、ructure. The structure of the data elements of the relationship that existed between Duoduiduo, graphics structure also known as network structure.</p><p>  C++Builder programming experience</p><p

27、>  一、Database programming</p><p>  And the use of Delphi, Borland C++Builder BDE (Borland Database Engine) database interface, in particular its use BDE Administrator unified management database alias,

28、the database operation has nothing to do with the location of the database documents, thus enabling database development easier operation. But in a database application procedures at the same time we have to "releas

29、e" BDE, the database for some simple procedures may BDE than our own design procedures big, but as the use of BDE In</p><p>  Thus, no impact on the debugging phase, will be issued if the application pr

30、ocedures Table1 document on the use of databases or their current catalogue "DB" virus, database procedures can be normal operation. You can even be a database to catalogue the documents in the form of characte

31、r string Register (installed in the installation process), then the procedure in the acquisition of substantially from the catalogue of payrolls, Fuzhi DatabaseName attribute to be. Anyway, you do not need to insta</p

32、><p>  二、the Registry visit</p><p>  As in the design process we often required 9x/NT Windows Registry information visit, such as retrieval of information procedures, preservation of information.

33、Register write a subroutine to visit necessary. When the Register to visit, the library will be directly available without always some duplication operation. The following can be used to access cosmetic Licheng, the char

34、acter string type Jianzhi, and the retrieval of failure to return default value Default.</p><p>  #include < Registry.hpp ></p><p>  int ReadIntFromReg(HKEY Root, AnsiString Key,</p>

35、<p>  AnsiString KeyName, int Default) {</p><p>  int KeyValue;</p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootKey = Root;</p><p>  Re

36、gistry->OpenKey(Key, false);</p><p><b>  try {</b></p><p>  KeyValue = Registry->ReadInteger(KeyName);</p><p><b>  }</b></p><p>  catch(..

37、.) {</p><p>  KeyValue = Default;</p><p><b>  }</b></p><p>  delete Registry;</p><p>  return KeyValue;</p><p><b>  }</b></p>

38、<p>  void SaveIntToReg(HKEY Root, AnsiString Key,</p><p>  AnsiString KeyName, int KeyValue) {</p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootKey

39、= Root;</p><p>  Registry->OpenKey(Key, true);</p><p>  Registry->WriteInteger(KeyName, KeyValue);</p><p>  delete Registry;</p><p><b>  }</b></p&g

40、t;<p>  char *ReadStringFromReg(HKEY Root, AnsiString Key,</p><p>  AnsiString KeyName, char *Default) {</p><p>  AnsiString KeyValue;</p><p>  TRegistry *Registry = new TReg

41、istry();</p><p>  Registry->RootKey = Root;</p><p>  Registry->OpenKey(Key, false);</p><p><b>  try {</b></p><p>  KeyValue = Registry->ReadString(

42、KeyName);</p><p><b>  }</b></p><p>  catch(...) {</p><p>  KeyValue = (AnsiString)Default;</p><p><b>  }</b></p><p>  delete Regist

43、ry;</p><p>  return KeyValue.c_str();</p><p><b>  }</b></p><p>  void SaveStringToReg(HKEY Root, AnsiString Key, </p><p>  AnsiString KeyName, char *KeyValu

44、e) {</p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootKey = Root;</p><p>  Registry->OpenKey(Key, true);</p><p>  Registry->WriteString(K

45、eyName, (AnsiString)KeyValue);</p><p>  delete Registry;</p><p><b>  } </b></p><p>  We may use the following access methods (to Windows wallpaper documents) :</p>

46、<p>  AnsiString WallPaperFileName = </p><p>  ReadStringFromReg(HKEY_CURRENT_USER,</p><p>  "\\Control Panel\\Desktop", "Wallpaper", "");</p><p&g

47、t;  三、show / hide icons task column </p><p>  Standard Windows applications generally operating in the mission mandate column on the chart shows, users can directly use the mouse clicking column logo for th

48、e mission task cut over, but some applications do not use task column signs, such as the typical Office tools, There are also procedures that can be shown or hidden customization tasks column icon, such as Winamp. We can

49、 do the procedure, as long as access Windows SetWindowLong function can drive, as follows : </p><p>  // hidden task column chart : </p><p>  SetWindowLong (Application->Handle. </

50、p><p>  GWL_EXSTYLE, WS_EX_TOOLWINDOW); </p><p>  // task column shows signs : </p><p>  SetWindowLong (Application->Handle. </p><p>  GWL_EXSTYLE, WS_EX_APPWINDO

51、W);</p><p>  四、the establishment of a simple "on" window</p><p>  A complete Windows applications typically contain a "on the" window to show version information. We customiz

52、ed a dialog box as usual "on the" window of the "on" free customized window, indicates that more information, even including super links. If only show simple version information, </p><p>

53、  Windows ShellAbout function shelf items have sufficient, following this line of code can be "on" Duihuakuang and is Windows standard "on the" Duihuakuang and procedures may show signs such as the us

54、e of resources and systems. </p><p>  ShellAbout (Handle, ( "on" +Application->Title+ "#"). C_str () ( "\n" +Application->Title+ "V1.0\n\n" + "夏登城 版權(quán)所有!

55、"). C_str () Application->Icon->Handle);</p><p>  五、the two methods to choice catalogue</p><p>  In our applications, allowing users to choose the regular catalogue, such as softwar

56、e manufacturers, users choose catalogue. This involves catalogue option, we may use the following methods for users to choose one of the catalogue : </p><p>  1, use SHBrowseForFolder and SHGetPathFromIDLi

57、st function; Company affirms its function as follows : </p><p>  WINSHELLAPI LPITEMIDLIST WINAPI SHBrowseForFolder(LPBROWSEINFO lpbi); WINSHELLAPI BOOL WINAPI SHGetPathFromIDList(LPCITEMIDLIST pidl, LPSTR

58、pszPath); LPBROWSEINFO和LPITEMIDLIST structure refer Win32 files. This method of selecting catalogues available Windows desktop all available inventory, including networks of other computers sharing catalogue neighbors, b

59、ut not the new catalogue. Li Cheng allows users to choose the following directory, the directory of choice Licheng return at all trails char</p><p>  #include < shlobj.h ></p><p>  char *G

60、etDir(char *DisplayName, HWND Owner) {</p><p>  char dir[MAX_PATH] = "";</p><p>  BROWSEINFO *bi = new BROWSEINFO;</p><p>  bi->hwndOwner = Owner;</p><p> 

61、 bi->pidlRoot = NULL;</p><p>  bi->pszDisplayName = NULL;</p><p>  bi->lpszTitle = DisplayName;</p><p>  bi->ulFlags = BIF_RETURNONLYFSDIRS;</p><p>  bi->

62、;lpfn = NULL;</p><p>  bi->lParam = NULL;</p><p>  bi->iImage = 0;</p><p>  ITEMIDLIST *il = SHBrowseForFolder(bi);</p><p>  if(il!=NULL) {</p><p>  

63、SHGetPathFromIDList(il, dir);</p><p><b>  }</b></p><p>  delete bi;</p><p>  return dir;</p><p><b>  }</b></p><p>  We can use the

64、following list to be chosen from : </p><p>  AnsiString at Dir = (AnsiString) GetDir ( "Please select catalogue :" Handle);</p><p>  2, the use of SelectDirectory function. C++Builder

65、 the function SelectDirectory achievable catalogue of options, which showed that similar "open" / "preserve" Duihuakuang, but its advantage is to use / non-use keyboard input catalogue members, and al

66、low the creation of new directories. Its original definition as follows : </p><p>  Extern package bool __fastcall SelectDirectory ( AnsiString &Directory, TSelectDirOpts Options, 103-116 HelpCtx);

67、 </p><p>  Licheng SelectDir allow you to choose the following directory : </p><p>  #include < FileCtrl.hpp ></p><p>  AnsiString SelectDir(AnsiString Dir) {</p>&l

68、t;p>  if(SelectDirectory(Dir, TSelectDirOpts()</p><p>  << sdAllowCreate << sdPerformCreate << sdPrompt,0))</p><p>  return Dir;</p><p><b>  else</b>

69、;</p><p>  return "";</p><p><b>  }</b></p><p>  for the following redeployed to the users choice catalogue : </p><p>  AnsiString SelectedDir =

70、 SelectDir ( "C:\\My Documents");</p><p>  附錄B 外文翻譯-譯文部分</p><p>  數(shù)據(jù)結(jié)構(gòu)是計(jì)算機(jī)程序設(shè)計(jì)的重要理論設(shè)計(jì)基礎(chǔ),它不僅是計(jì)算機(jī)學(xué)科的核心課程,而且已成為其他理工專業(yè)的熱門選修課,所以學(xué)好這門課程是與學(xué)好計(jì)算機(jī)專業(yè)是息息相關(guān)的。</p><p><b>  一,數(shù)據(jù)結(jié)構(gòu)的

71、概念</b></p><p>  數(shù)據(jù)結(jié)構(gòu)是計(jì)算機(jī)科學(xué)與技術(shù)專業(yè)的專業(yè)基礎(chǔ)課,是十分重要的核心課程。所有的計(jì)算機(jī)系統(tǒng)軟件和應(yīng)用軟件都要用到各種類型的數(shù)據(jù)結(jié)構(gòu)。因此,要想更好地運(yùn)用計(jì)算機(jī)來解決實(shí)際問題,僅掌握幾種計(jì)算機(jī)程序設(shè)計(jì)語言是難以應(yīng)付眾多復(fù)雜的課題的。要想有效地使用計(jì)算機(jī)、充分發(fā)揮計(jì)算機(jī)的性能,還必須學(xué)習(xí)和掌握好數(shù)據(jù)結(jié)構(gòu)的有關(guān)知識。打好“數(shù)據(jù)結(jié)構(gòu)”這門課程的扎實(shí)基礎(chǔ),對于學(xué)習(xí)計(jì)算機(jī)專業(yè)的其他課程,

72、如操作系統(tǒng)、編譯原理、數(shù)據(jù)庫管理系統(tǒng)、軟件工程、人工智能等都是十分有益的。</p><p>  二,為什么要學(xué)習(xí)數(shù)據(jù)結(jié)構(gòu)</p><p>  在計(jì)算機(jī)發(fā)展的初期,人們使用計(jì)算機(jī)的目的主要是處理數(shù)值計(jì)算問題。當(dāng)我們使用計(jì)算機(jī)來解決一個(gè)具體問題時(shí),一般需要經(jīng)過下列幾個(gè)步驟:首先要從該具體問題抽象出一個(gè)適當(dāng)?shù)臄?shù)學(xué)模型,然后設(shè)計(jì)或選擇一個(gè)解此數(shù)學(xué)模型的算法,最后編出程序進(jìn)行調(diào)試、測試,直至得到最終

73、的解答。例如,求解梁架結(jié)構(gòu)中應(yīng)力的數(shù)學(xué)模型的線性方程組,該方程組可以使用迭代算法來求解。</p><p>  由于當(dāng)時(shí)所涉及的運(yùn)算對象是簡單的整型、實(shí)型或布爾類型數(shù)據(jù),所以程序設(shè)計(jì)者的主要精力是集中于程序設(shè)計(jì)的技巧上,而無須重視數(shù)據(jù)結(jié)構(gòu)。隨著計(jì)算機(jī)應(yīng)用領(lǐng)域的擴(kuò)大和軟、硬件的發(fā)展,非數(shù)值計(jì)算問題越來越顯得重要。據(jù)統(tǒng)計(jì),當(dāng)今處理非數(shù)值計(jì)算性問題占用了90%以上的機(jī)器時(shí)間。這類問題涉及到的數(shù)據(jù)結(jié)構(gòu)更為復(fù)雜,數(shù)據(jù)元素之間

74、的相互關(guān)系一般無法用數(shù)學(xué)方程式加以描述。因此,解決這類問題的關(guān)鍵不再是數(shù)學(xué)分析和計(jì)算方法,而是要設(shè)計(jì)出合適的數(shù)據(jù)結(jié)構(gòu),才能有效地解決問題。</p><p>  描述這類非數(shù)值計(jì)算問題的數(shù)學(xué)模型不再是數(shù)學(xué)方程,而是諸如表、樹、圖之類的數(shù)據(jù)結(jié)構(gòu)。因此,可以說數(shù)據(jù)結(jié)構(gòu)課程主要是研究非數(shù)值計(jì)算的程序設(shè)計(jì)問題中所出現(xiàn)的計(jì)算機(jī)操作對象以及它們之間的關(guān)系和操作的學(xué)科。</p><p>  學(xué)習(xí)數(shù)據(jù)結(jié)構(gòu)的

75、目的是為了了解計(jì)算機(jī)處理對象的特性,將實(shí)際問題中所涉及的處理對象在計(jì)算機(jī)中表示出來并對它們進(jìn)行處理。與此同時(shí),通過算法訓(xùn)練來提高學(xué)生的思維能力,通過程序設(shè)計(jì)的技能訓(xùn)練來促進(jìn)學(xué)生的綜合應(yīng)用能力和專業(yè)素質(zhì)的提高。</p><p><b>  三,有關(guān)概念和術(shù)語</b></p><p>  在系統(tǒng)地學(xué)習(xí)數(shù)據(jù)結(jié)構(gòu)知識之前,先對一些基本概念和術(shù)語賦予確切的含義。</p&g

76、t;<p>  數(shù)據(jù)(Data)是信息的載體,它能夠被計(jì)算機(jī)識別、存儲和加工處理。它是計(jì)算機(jī)程序加工的原料,應(yīng)用程序處理各種各樣的數(shù)據(jù)。計(jì)算機(jī)科學(xué)中,所謂數(shù)據(jù)就是計(jì)算機(jī)加工處理的對象,它可以是數(shù)值數(shù)據(jù),也可以是非數(shù)值數(shù)據(jù)。數(shù)值數(shù)據(jù)是一些整數(shù)、實(shí)數(shù)或復(fù)數(shù),主要用于工程計(jì)算、科學(xué)計(jì)算和商務(wù)處理等;非數(shù)值數(shù)據(jù)包括字符、文字、圖形、圖像、語音等。</p><p>  數(shù)據(jù)元素(Data Element)是數(shù)

77、據(jù)的基本單位。在不同的條件下,數(shù)據(jù)元素又可稱為元素、結(jié)點(diǎn)、頂點(diǎn)、記錄等。例如,學(xué)生信息檢索系統(tǒng)中學(xué)生信息表中的一個(gè)記錄、八皇后問題中狀態(tài)樹的一個(gè)狀態(tài)、教學(xué)計(jì)劃編排問題中的一個(gè)頂點(diǎn)等,都被稱為一個(gè)數(shù)據(jù)元素。</p><p>  有時(shí),一個(gè)數(shù)據(jù)元素可由若干個(gè)數(shù)據(jù)項(xiàng)(Data Item)組成,例如,學(xué)籍管理系統(tǒng)中學(xué)生信息表的每一個(gè)數(shù)據(jù)元素就是一個(gè)學(xué)生記錄。它包括學(xué)生的學(xué)號、姓名、性別、籍貫、出生年月、成績等數(shù)據(jù)項(xiàng)。這些

78、數(shù)據(jù)項(xiàng)可以分為兩種:一種叫做初等項(xiàng),如學(xué)生的性別、籍貫等,這些數(shù)據(jù)項(xiàng)是在數(shù)據(jù)處理時(shí)不能再分割的最小單位;另一種叫做組合項(xiàng),如學(xué)生的成績,它可以再劃分為數(shù)學(xué)、物理、化學(xué)等更小的項(xiàng)。通常,在解決實(shí)際應(yīng)用問題時(shí)是把每個(gè)學(xué)生記錄當(dāng)作一個(gè)基本單位進(jìn)行訪問和處理的。</p><p>  數(shù)據(jù)對象(Data Object)或數(shù)據(jù)元素類(Data Element Class)是具有相同性質(zhì)的數(shù)據(jù)元素的集合。在某個(gè)具體問題中,數(shù)據(jù)

79、元素都具有相同的性質(zhì)(元素值不一定相等),屬于同一數(shù)據(jù)對象(數(shù)據(jù)元素類),數(shù)據(jù)元素是數(shù)據(jù)元素類的一個(gè)實(shí)例。例如,在交通咨詢系統(tǒng)的交通網(wǎng)中,所有的頂點(diǎn)是一個(gè)數(shù)據(jù)元素類,頂點(diǎn)A和頂點(diǎn)B各自代表一個(gè)城市,是該數(shù)據(jù)元素類中的兩個(gè)實(shí)例,其數(shù)據(jù)元素的值分別為A和B。</p><p>  數(shù)據(jù)結(jié)構(gòu)(Data Structure)是指互相之間存在著一種或多種關(guān)系的數(shù)據(jù)元素的集合。在任何問題中,數(shù)據(jù)元素之間都不會是孤立的,在它們之

80、間都存在著這樣或那樣的關(guān)系,這種數(shù)據(jù)元素之間的關(guān)系稱為結(jié)構(gòu)。根據(jù)數(shù)據(jù)元素間關(guān)系的不同特性,通常有下列四類基本的結(jié)構(gòu):</p><p> ?、偶辖Y(jié)構(gòu)。在集合結(jié)構(gòu)中,數(shù)據(jù)元素間的關(guān)系是“屬于同一個(gè)集合”。集合是元素關(guān)系極為松散的一種結(jié)構(gòu)。</p><p> ?、凭€性結(jié)構(gòu)。該結(jié)構(gòu)的數(shù)據(jù)元素之間存在著一對一的關(guān)系。</p><p>  ⑶樹型結(jié)構(gòu)。該結(jié)構(gòu)的數(shù)據(jù)元素之間存在

81、著一對多的關(guān)系。</p><p> ?、葓D形結(jié)構(gòu)。該結(jié)構(gòu)的數(shù)據(jù)元素之間存在著多對多的關(guān)系,圖形結(jié)構(gòu)也稱作網(wǎng)狀結(jié)構(gòu)。</p><p>  C++Builder程序設(shè)計(jì)經(jīng)驗(yàn)</p><p><b>  數(shù)據(jù)庫程序設(shè)計(jì)</b></p><p>  Borland C++Builder與Delphi一樣使用BDE(Borland

82、 </p><p>  Database Engine)數(shù)據(jù)庫接口,特別是它使用BDE Administrator統(tǒng)一管理數(shù)據(jù)庫別名,使得數(shù)據(jù)庫操作與數(shù)據(jù)庫文件位置無關(guān),從而使數(shù)據(jù)庫開發(fā)更容易操作。但在發(fā)布應(yīng)用數(shù)據(jù)庫程序時(shí)我們不得不同時(shí)“發(fā)布”BDE,對于一些簡單的數(shù)據(jù)庫程序來說,可能BDE比我們的自己設(shè)計(jì)的程序還大,而且如使用InstallShield配置BDE,添加數(shù)據(jù)庫別名,很可能會配置失敗。所以我們可以采

83、用如下方法:在程序設(shè)計(jì)階段仍采用BDE管理數(shù)據(jù)庫別名進(jìn)行調(diào)試,但在程序初始化時(shí)(如在主窗體的OnCreate事件處理函數(shù)中)修改Table部件的DatabaseName屬性,如使用類似如下語句: </p><p>  Table1->DatabaseName = ExtractFilePath(Application->ExeName);或 Table1->DatabaseName </p

84、><p>  = ExtractFilePath(Application->ExeName+”DB”); </p><p>  這樣,對調(diào)試階段沒有什么影響,發(fā)布應(yīng)用程序時(shí)只要將Table1使用的數(shù)據(jù)庫文件放在當(dāng)前目錄或其“DB”子目錄下,數(shù)據(jù)庫程序即可正常運(yùn)行。甚至您還可以將數(shù)據(jù)庫文件所在目錄以字符串形式寫入注冊表(可在安裝程序中設(shè)置),然后在程序初始化時(shí)從注冊表獲取目錄名,賦值給Da

85、tabaseName屬性即可。無論怎樣,您不必強(qiáng)迫用戶安裝相對龐大的BDE了。</p><p><b>  二、 注冊表存取 </b></p><p>  在我們在設(shè)計(jì)Windows 9x/NT程序時(shí)經(jīng)常需進(jìn)行注冊表信息的存取,如讀取程序配置信息、保存配置信息等。寫一個(gè)注冊表存取子程序就很有必要。當(dāng)需存取注冊表時(shí),直接調(diào)用此子程序即可,而不必每次都重復(fù)一些操作。下面的

86、例程可用來存取整型、字符串型鍵值,并可在讀取失敗時(shí)返回缺省值Default。 </p><p>  #include < Registry.hpp ></p><p>  int ReadIntFromReg(HKEY Root, AnsiString Key,</p><p>  AnsiString KeyName, int Default) {&l

87、t;/p><p>  int KeyValue;</p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootKey = Root;</p><p>  Registry->OpenKey(Key, false);</p><p&

88、gt;<b>  try {</b></p><p>  KeyValue = Registry->ReadInteger(KeyName);</p><p><b>  }</b></p><p>  catch(...) {</p><p>  KeyValue = Default;<

89、;/p><p><b>  }</b></p><p>  delete Registry;</p><p>  return KeyValue;</p><p><b>  }</b></p><p>  void SaveIntToReg(HKEY Root, AnsiStr

90、ing Key,</p><p>  AnsiString KeyName, int KeyValue) {</p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootKey = Root;</p><p>  Registry->OpenKe

91、y(Key, true);</p><p>  Registry->WriteInteger(KeyName, KeyValue);</p><p>  delete Registry;</p><p><b>  }</b></p><p>  char *ReadStringFromReg(HKEY Root,

92、 AnsiString Key,</p><p>  AnsiString KeyName, char *Default) {</p><p>  AnsiString KeyValue;</p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootK

93、ey = Root;</p><p>  Registry->OpenKey(Key, false);</p><p><b>  try {</b></p><p>  KeyValue = Registry->ReadString(KeyName);</p><p><b>  }</b&

94、gt;</p><p>  catch(...) {</p><p>  KeyValue = (AnsiString)Default;</p><p><b>  }</b></p><p>  delete Registry;</p><p>  return KeyValue.c_str()

95、;</p><p><b>  }</b></p><p>  void SaveStringToReg(HKEY Root, AnsiString Key, </p><p>  AnsiString KeyName, char *KeyValue) {</p><p>  TRegistry *Registry =

96、new TRegistry();</p><p>  Registry->RootKey = Root;</p><p>  Registry->OpenKey(Key, true);</p><p>  Registry->WriteString(KeyName, (AnsiString)KeyValue);</p><p&g

97、t;  delete Registry;</p><p><b>  } </b></p><p>  我們可使用如下調(diào)用方法(獲得Windows墻紙文件名): </p><p>  AnsiString WallPaperFileName = </p><p>  ReadStringFromReg(HKEY_CURR

98、ENT_USER,</p><p>  "\\Control Panel\\Desktop", "Wallpaper", "");</p><p>  三、 顯示/隱藏任務(wù)欄圖標(biāo) </p><p>  標(biāo)準(zhǔn)的Windows應(yīng)用程序運(yùn)行時(shí)一般都會在任務(wù)欄上顯示任務(wù)圖標(biāo),用戶可直接用鼠標(biāo)點(diǎn)擊任務(wù)欄圖標(biāo)進(jìn)行任務(wù)切

99、換,但有些應(yīng)用程序不使用任務(wù)欄圖標(biāo),如典型的Office工具條,也有些程序可由用戶定制顯示方式顯示或隱藏任務(wù)欄圖標(biāo),如Winamp。我們的程序中也可以做到,只要調(diào)用Windows </p><p>  API函數(shù)SetWindowLong即可,如下: </p><p>  // 隱藏任務(wù)欄圖標(biāo):</p><p>  SetWindowLong(Application

100、->Handle, </p><p>  GWL_EXSTYLE, WS_EX_TOOLWINDOW);</p><p>  // 顯示任務(wù)欄圖標(biāo):</p><p>  SetWindowLong(Application->Handle,</p><p>  GWL_EXSTYLE, WS_EX_APPWINDOW);</p

101、><p>  四、 建立簡單的“關(guān)于”窗口 </p><p>  一個(gè)完整的Windows應(yīng)用程序一般都包含一個(gè)“關(guān)于”窗口,用以顯示版本信息等。通常我們是定制一個(gè)對話框作為“關(guān)于”窗口,當(dāng)然這樣的“關(guān)于”窗口可以自由定制,顯示更多信息,甚至可包括超鏈接。但如只需顯示簡單版本信息等,</p><p>  Windows Shell Library 函數(shù)ShellAbou

102、t已足夠了,下面這行代碼就可以顯示“關(guān)于”對話框,而且是Windows標(biāo)準(zhǔn)的“關(guān)于”對話框,同時(shí)可顯示程序圖標(biāo)和系統(tǒng)資源使用情況等。 </p><p>  ShellAbout(Handle, ("關(guān)于"+Application->Title+"#").c_str(),</p><p>  ("\n"+Application

103、->Title+" V1.0\n\n"+"夏登城 版權(quán)所有!").c_str(),</p><p>  Application->Icon->Handle);</p><p>  五、 選擇目錄的兩種方法 </p><p>  在我們的應(yīng)用程序中經(jīng)常需讓用戶選擇目錄,如殺毒軟件中用戶選擇處理目錄等。這就涉及目

104、錄的選擇,我們可使用如下方法之一讓用戶選擇目錄: </p><p>  1、 使用SHBrowseForFolder和SHGetPathFromIDList函數(shù);其函數(shù)原形申明如下: </p><p>  WINSHELLAPI LPITEMIDLIST WINAPI SHBrowseForFolder(LPBROWSEINFO lpbi); </p><p>  

105、WINSHELLAPI BOOL WINAPI SHGetPathFromIDList(LPCITEMIDLIST pidl, LPSTR pszPath); LPBROWSEINFO和LPITEMIDLIST的結(jié)構(gòu)請參考Win32文檔。這種方法選取目錄可獲得Windows桌面下所有可用的目錄,包括網(wǎng)絡(luò)鄰居中其它計(jì)算機(jī)的共享目錄等,但不可新建目錄。下面的例程可讓用戶選擇目錄,該例程返回指向所選擇目錄的全路徑字符串。 </p>

106、<p>  #include < shlobj.h ></p><p>  char *GetDir(char *DisplayName, HWND Owner) {</p><p>  char dir[MAX_PATH] = "";</p><p>  BROWSEINFO *bi = new BROWSEINFO;

107、</p><p>  bi->hwndOwner = Owner;</p><p>  bi->pidlRoot = NULL;</p><p>  bi->pszDisplayName = NULL;</p><p>  bi->lpszTitle = DisplayName;</p><p>

108、;  bi->ulFlags = BIF_RETURNONLYFSDIRS;</p><p>  bi->lpfn = NULL;</p><p>  bi->lParam = NULL;</p><p>  bi->iImage = 0;</p><p>  ITEMIDLIST *il = SHBrowseForF

109、older(bi);</p><p>  if(il!=NULL) {</p><p>  SHGetPathFromIDList(il, dir);</p><p><b>  }</b></p><p>  delete bi;</p><p>  return dir;</p>

110、<p><b>  }</b></p><p>  我們可作如下調(diào)用得到選擇的目錄名: </p><p>  AnsiString Dir = (AnsiString)GetDir("請選擇目錄:", Handle);</p><p>  2、 使用SelectDirectory函數(shù)。C++Builder提供的函

111、數(shù)SelectDirectory可實(shí)現(xiàn)目錄名的選擇,它顯示的是類似“打開”/“保存”的對話框,但其優(yōu)點(diǎn)是可使用/不使用鍵盤輸入目錄名,并允許創(chuàng)建新目錄。其原形定義如下: </p><p>  extern PACKAGE bool __fastcall SelectDirectory(</p><p>  AnsiString &Directory, TSelectDirOpts

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論