?
Solved

NT Registry read problem

Posted on 1997-07-17
4
Medium Priority
?
309 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

777 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