?
Solved

How to convert binary data to string

Posted on 2003-03-10
6
Medium Priority
?
330 Views
Last Modified: 2010-05-18
 Registry.RootKey := HKEY_CURRENT_USER;
  Registry.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\Folder',False)
   Registry.ReadBinaryData('VALUE7', Buffer , Sizeof(Buffer))
  How to convert binary data to string.

0
Comment
Question by:rsivam
[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
6 Comments
 
LVL 2

Expert Comment

by:Ray_Adams
ID: 8108817
This is just UNICODE string. Use
var
  data:array[0..255] of WideChar;
as a buffer for reading.
0
 
LVL 2

Accepted Solution

by:
steve_hsk earned 1000 total points
ID: 8110035
Hi Rsivam ...

If you want the recent docs info, then there may be a better approach ... I thought there was a shell api function  like this one ...

procedure DoStuff(const Filename: string);
begin
  SHAddToRecentDocs(SHARD_PATH, @Filename[1]);
end;

I think this what your currently trying to do, although the output isn't completely clean :

procedure TForm1.Button1Click(Sender: TObject);
VAR Registry : TRegistry;
    Buffer   : array[1..255] of char;
    isize : Integer;
    sOutput : String;
    iCharCount : Integer;
begin
    Registry := TRegistry.Create;

    Registry.RootKey := HKEY_CURRENT_USER;
    Registry.OpenKey('\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs\Folder',False);
    iSize := sizeof(Buffer);
    Registry.ReadBinaryData('a', Buffer, isize);
    Registry.Free;

    sOutput := '';
    For iCharCount := 0 To iSize do
    begin
        IF Buffer[iCharCount] <> #0 THEN
        begin
            sOutput := sOutput + Buffer[iCharCount];
        end;
    end;
    // NOTE >> Need a memo and a button on a form :
    Memo1.Lines.Add(sOutput);
end;

Here are 2 good examples of bin to string conversion :

http://www.latiumsoftware.com/en/delphi/00004.php

http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_10111505.html

Hope this helps,
Steve
0
 
LVL 1

Expert Comment

by:merry_prince
ID: 8110221
Carry out below method, you can use buffer var as string.

var Registry: TRegistry;
    Buffer   : array[1..255] of char;
    isize : Integer;
begin
   Registry := TRegistry.Create;

   Registry.RootKey := HKEY_LOCAL_MACHINE;
   Registry.OpenKey('\SOFTWARE\Prn\DEMO2',False);
   iSize := sizeof(Buffer);
   Registry.ReadBinaryData('PASSWD', Buffer, isize);
   Registry.Free;
   Buffer[isize] := #0;
   ShowMessage(buffer);
end;
0
 

Expert Comment

by:CleanupPing
ID: 9316849
rsivam:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 5

Expert Comment

by:snehanshu
ID: 10091017
Hi!
No comment has been added lately and this question is therefore classified abandoned.

If asker wishes to close the question, then refer to
http://www.experts-exchange.com/help/closing.jsp

Otherwise, I will leave a recommendation in the Cleanup topic area that this question is:

Answered by: steve_hsk

Please leave any comments here within the next seven days. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

...Snehanshu
EE Cleanup Volunteer
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

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