Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

NT Registry read problem

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

618 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