Solved

NT Registry read problem

Posted on 1997-07-17
4
305 Views
Last Modified: 2010-04-06
I'm programming some Network Information program with Delphi 2.Program reads NT registry like as 'DefalutGateway' or 'Subnetmask' value(that is TCP/IP information).I used
TRegistry to read get value of 'subnetmask' and 'defaultGateway'.These two fields data type are 'REG_MULTI_SZ' but actual data are binary not string.How can I read these fields? I tried to read these fields with
Registry.ReadString.I wanna your help !!
0
Comment
Question by:rnxotj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Expert Comment

by:ygolan
ID: 1339124
You can't access REG_MULTI_SZ with TRegistry, you will need to use the API.
0
 
LVL 4

Accepted Solution

by:
erajoj earned 10 total points
ID: 1339125
Try this wrapper, it works (tested) but it has no errorchecking
(i.e. it doesn't see if the data is REG_MULTI_SZ or if List is
<>nil):

type
  TMultiStrRegistry = class(TRegistry)
  public
    function ReadMultiString(const Name: string; List: TStrings): Integer;
  end;

...

function TMultiStrRegistry.ReadMultiString(const Name: string; List: TStrings): Integer;
{$ifopt R+}
  {$RANGECHECKS OFF}
{$endif}
type
  PData  = ^TData;
  TData  = Array[0..0] of Char;
var
  Len    : Integer;
  RegData: TRegDataType;
  Data   : PData;
  DataOrg: PData;
begin
  Len := GetDataSize(Name);
  if Len > 0 then
  begin
    GetMem(DataOrg, Len);
    GetData(Name, DataOrg, Len, RegData);
    Data := DataOrg;
    Result := 0;
    repeat
      frmMain.ListBox1.Items.Add(StrPas(Data^));
      Inc(Result);
      Inc(Data, StrLen(Data^)+1);
    until (Data^[0]=#0);
    FreeMem(DataOrg, Len); // release from original pointer
  end else Result := 0;
end;

...

with TMultiStrRegistry do begin
  ...
  StringCount := ReadMultiString(..., MyList);
  ...

/// John

0
 
LVL 4

Expert Comment

by:erajoj
ID: 1339126
Sorry! Wrong list:

"frmMain.ListBox1.Items.Add(StrPas(Data^));"
  should be
"List.Add(StrPas(Data^));"

/// John

0
 

Author Comment

by:rnxotj
ID: 1339127
Thanks your help !
I programmed with your answer but I got compile error
message.That is,'This form of method call only allowed
fo class methods' at 'ReadMultiString(...,...)'.
I added your class below form class .
Like this,

type
  Tsysteminfo = class(TForm)
    Panel1: TPanel;
          :
          :
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  TMultiStrRegistry = class(TRegistry)
  public
    function ReadMultiString(const Name: string; List: TStrings):          Integer;
  end;

Help me again!!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question