Solved

NT Registry read problem

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now