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

下載本文檔

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

文檔簡介

1、<p><b>  外文翻譯原文</b></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

2、a popular elective 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 st

3、ructure is the 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

4、want to make 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 co

5、mputer performance, 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

6、terms. When 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 ma

7、thematical model 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 des

8、igners of energy 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 importan

9、ce. According 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&g

10、t;  Description 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

11、to study the 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 s

12、tructure of 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 imp

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

14、ystematic study 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 identi

15、fication, storage 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 dat

16、a can be non - 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&

17、gt;<p>  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

18、information, 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 stude

19、nt information 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

20、 pool. In a 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

21、 example, traffic 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) re

22、fers to the 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 betwee

23、n the data element 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

24、structures. 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

25、. The structure 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>  

26、4graphics structure. 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</

27、p><p>  一、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 data

28、base alias, 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

29、"release" 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 ap

30、plication procedures 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

31、 of character 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

32、 insta</p><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 i

33、nformation. 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 Liche

34、ng, the character 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 Ke

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

36、lt;p>  Registry->OpenKey(Key, false);</p><p><b>  try {</b></p><p>  KeyValue = Registry->ReadInteger(KeyName);</p><p><b>  }</b></p><p&g

37、t;  catch(...) {</p><p>  KeyValue = Default;</p><p><b>  }</b></p><p>  delete Registry;</p><p>  return KeyValue;</p><p><b>  }</b&g

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

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

40、></p><p>  char *ReadStringFromReg(HKEY Root, AnsiString Key,</p><p>  AnsiString KeyName, char *Default) {</p><p>  AnsiString KeyValue;</p><p>  TRegistry *Registr

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

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

43、elete Registry;</p><p>  return KeyValue.c_str();</p><p><b>  }</b></p><p>  void SaveStringToReg(HKEY Root, AnsiString Key, </p><p>  AnsiString KeyName, c

44、har *KeyValue) {</p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootKey = Root;</p><p>  Registry->OpenKey(Key, true);</p><p>  Registry->W

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

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

47、gt;<p>  三、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

48、 logo for the 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 Wi

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

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

51、_EX_APPWINDOW);</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.

52、 We customized 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>

53、;<p>  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 su

54、ch as the use of resources and systems. </p><p>  ShellAbout (Handle, ( "on" +Application->Title+ "#"). C_str () ( "\n" +Application->Title+ "V1.0\n\n" + &qu

55、ot;夏登城 版權(quán)所有!"). 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, suc

56、h as software 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 SHGet

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

58、pidl, LPSTR 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

59、neighbors, but 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&

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

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

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

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

64、can use the 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

65、. C++Builder 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 mem

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

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

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

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

70、electedDir = SelectDir ( "C:\\My Documents");</p><p><b>  外文翻譯譯文</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><

71、;p><b>  一,數(shù)據(jù)結(jié)構(gòu)的概念</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í)。打好“數(shù)據(jù)結(jié)構(gòu)”這

72、門課程的扎實(shí)基礎(chǔ),對(duì)于學(xué)習(xí)計(jì)算機(jī)專業(yè)的其他課程,如操作系統(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é)模型

73、的算法,最后編出程序進(jìn)行調(diào)試、測(cè)試,直至得到最終的解答。例如,求解梁架結(jié)構(gòu)中應(yīng)力的數(shù)學(xué)模型的線性方程組,該方程組可以使用迭代算法來求解。</p><p>  由于當(dāng)時(shí)所涉及的運(yùn)算對(duì)象是簡單的整型、實(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í)間

74、。這類問題涉及到的數(shù)據(jù)結(jié)構(gòu)更為復(fù)雜,數(shù)據(jù)元素之間的相互關(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ī)操作對(duì)象以及它們之間的關(guān)系和操作的學(xué)科。</p

75、><p>  學(xué)習(xí)數(shù)據(jù)結(jié)構(gòu)的目的是為了了解計(jì)算機(jī)處理對(duì)象的特性,將實(shí)際問題中所涉及的處理對(duì)象在計(jì)算機(jī)中表示出來并對(duì)它們進(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í)之前,先對(duì)一

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

77、t;  數(shù)據(jù)元素(Data Element)是數(shù)據(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é)號(hào)

78、、姓名、性別、籍貫、出生年月、成績等數(shù)據(jù)項(xiàng)。這些數(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ù)對(duì)象(Data Object)或數(shù)據(jù)元素類(Data Element Class)是具有

79、相同性質(zhì)的數(shù)據(jù)元素的集合。在某個(gè)具體問題中,數(shù)據(jù)元素都具有相同的性質(zhì)(元素值不一定相等),屬于同一數(shù)據(jù)對(duì)象(數(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ù)元素的集合。在

80、任何問題中,數(shù)據(jù)元素之間都不會(huì)是孤立的,在它們之間都存在著這樣或那樣的關(guān)系,這種數(shù)據(jù)元素之間的關(guān)系稱為結(jié)構(gòu)。根據(jù)數(shù)據(jù)元素間關(guān)系的不同特性,通常有下列四類基本的結(jié)構(gòu):</p><p>  ⑴集合結(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ù)元素之間存在著一對(duì)一的關(guān)系。</p><p

81、> ?、菢湫徒Y(jié)構(gòu)。該結(jié)構(gòu)的數(shù)據(jù)元素之間存在著一對(duì)多的關(guān)系。</p><p> ?、葓D形結(jié)構(gòu)。該結(jié)構(gòu)的數(shù)據(jù)元素之間存在著多對(duì)多的關(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++Build

82、er與Delphi一樣使用BDE(Borland </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,對(duì)于一些簡單的數(shù)據(jù)庫程序來說,可能BDE比我們的自己設(shè)計(jì)的程序還大,而且如使用InstallShield配置BDE,

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

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

85、然后在程序初始化時(shí)從注冊(cè)表獲取目錄名,賦值給DatabaseName屬性即可。無論怎樣,您不必強(qiáng)迫用戶安裝相對(duì)龐大的BDE了。</p><p><b>  二、 注冊(cè)表存取 </b></p><p>  在我們?cè)谠O(shè)計(jì)Windows 9x/NT程序時(shí)經(jīng)常需進(jìn)行注冊(cè)表信息的存取,如讀取程序配置信息、保存配置信息等。寫一個(gè)注冊(cè)表存取子程序就很有必要。當(dāng)需存取注冊(cè)表時(shí),直接調(diào)

86、用此子程序即可,而不必每次都重復(fù)一些操作。下面的例程可用來存取整型、字符串型鍵值,并可在讀取失敗時(shí)返回缺省值Default。 </p><p>  #include < Registry.hpp ></p><p>  int ReadIntFromReg(HKEY Root, AnsiString Key,</p><p>  AnsiString K

87、eyName, int Default) {</p><p>  int KeyValue;</p><p>  TRegistry *Registry = new TRegistry();</p><p>  Registry->RootKey = Root;</p><p>  Registry->OpenKey(Key, f

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

89、  KeyValue = Default;</p><p><b>  }</b></p><p>  delete Registry;</p><p>  return KeyValue;</p><p><b>  }</b></p><p>  void SaveInt

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

91、gt;  Registry->OpenKey(Key, true);</p><p>  Registry->WriteInteger(KeyName, KeyValue);</p><p>  delete Registry;</p><p><b>  }</b></p><p>  char *Read

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

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

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

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

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

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

98、dStringFromReg(HKEY_CURRENT_USER,</p><p>  "\\Control Panel\\Desktop", "Wallpaper", "");</p><p>  三、 顯示/隱藏任務(wù)欄圖標(biāo) </p><p>  標(biāo)準(zhǔn)的Windows應(yīng)用程序運(yùn)行時(shí)一般都會(huì)在任務(wù)欄上顯示任

99、務(wù)圖標(biāo),用戶可直接用鼠標(biāo)點(diǎn)擊任務(wù)欄圖標(biāo)進(jìn)行任務(wù)切換,但有些應(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>  S

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

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

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

103、uot;\n"+Application->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);

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

106、所選擇目錄的全路徑字符串。 </p><p>  #include < shlobj.h ></p><p>  char *GetDir(char *DisplayName, HWND Owner) {</p><p>  char dir[MAX_PATH] = "";</p><p>  BROWSEIN

107、FO *bi = new BROWSEINFO;</p><p>  bi->hwndOwner = Owner;</p><p>  bi->pidlRoot = NULL;</p><p>  bi->pszDisplayName = NULL;</p><p>  bi->lpszTitle = DisplayN

108、ame;</p><p>  bi->ulFlags = BIF_RETURNONLYFSDIRS;</p><p>  bi->lpfn = NULL;</p><p>  bi->lParam = NULL;</p><p>  bi->iImage = 0;</p><p>  ITEMI

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

110、  return dir;</p><p><b>  }</b></p><p>  我們可作如下調(diào)用得到選擇的目錄名: </p><p>  AnsiString Dir = (AnsiString)GetDir("請(qǐng)選擇目錄:", Handle);</p><p>  2、 使用SelectDi

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

溫馨提示

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

評(píng)論

0/150

提交評(píng)論