Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to read a registry entry of type REG_MULTI_SZ Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
19-Mar-03
Category
Win API
Language
Delphi 2.x
Views
123
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius 

How to read a registry entry of type REG_MULTI_SZ

Answer:

REG_MULTI_SZ is a registry type holding multiple strings. This function reads the 
value into a TStrings object and returns true if successful.
1   
2   function ReadREG_MULTI_SZ(const HK: HKey; const k, v: string; ts: TStrings): 
3   boolean;
4   var
5     vType: DWORD;
6     vLen: DWORD;
7     p, buffer: PChar;
8     key: HKEY;
9   begin
10    result := false;
11    ts.Clear;
12    if (RegOpenKeyEx(HK, PChar(k), 0, KEY_READ, key) = ERROR_SUCCESS) then
13    begin
14      SetLastError(RegQueryValueEx(key, PChar(v), nil, @vType, nil, @vLen));
15      if (GetLastError = ERROR_SUCCESS) and (vType = REG_MULTI_SZ) then
16      begin
17        GetMem(buffer, vLen);
18        try
19          RegQueryValueEx(key, PChar(v), nil, nil, PBYTE(buffer), @vLen);
20          p := buffer;
21          while (p^ <> #0) do
22          begin
23            ts.Add(p);
24            Inc(p, lstrlen(p) + 1)
25          end;
26        finally
27          FreeMem(buffer)
28        end;
29        result := true;
30      end;
31    end;
32  end;
33  
34  //Example to read the 'Pagingfiles' value into a TMemo:
35  
36  procedure TForm1.Button1Click(Sender: TObject);
37  var
38    k, val: string;
39  begin
40    k := 'SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management';
41    val := 'Pagingfiles';
42    ReadREG_MULTI_SZ(HKEY_LOCAL_MACHINE, k, val, Memo1.Lines);
43  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC