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
Solved

NT Registry read problem

Posted on 1997-07-17
4
304 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
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Working this component WebCopy with proxy, help 3 92
Downloading email attachments 2 79
RESTRequest Parameter 4 42
Delphi Seattle StructureView color 1 14
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…

808 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