• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1277
  • Last Modified:

Problem reading REG_BINARY data from the registry

Hi Friends,

I am having some problems in reading the REG_BINARY data from windows registry. I want to retrive the password of a SMTP account. Please see the code segemnt.

buf: Array[0..255] of char;
csSMTPPassword : string;

Registry.OpenKey('\Software\Microsoft\Internet Account Manager\Accounts\00000001')
Registry.ReadBinaryData('SMTP Password2', buf, Sizeof(buf));
csSMTPPassword :=  buf;


But I am receiving junk values in csSMTPPassword. What might be the reason

regards,
Partha
0
perthg
Asked:
perthg
2 Solutions
 
geobulCommented:
Hi,

1. The password might be encrypted

2. Try the following (the size of the buffer is not fixed):

buf: array of char;
ASize : integer;
csSMTPPassword : string;

Registry.OpenKey('\Software\Microsoft\Internet Account Manager\Accounts\00000001');
ASize := Registry.GetDataSize('SMTP Password2');
SetLength(buf,ASize);
Registry.ReadBinaryData('SMTP Password2', buf, ASize);
csSMTPPassword :=  buf;

Regards, Geo
0
 
shaneholmesCommented:
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now