Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to use WriteBinaryData Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-Sep-02
Category
Win API
Language
Delphi 2.x
Views
65
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: William Gerbert 

Can someone explain exactly how to use WriteBinaryData? I've tried several 
different ways but the output is never what it should be.

Answer:

1   uses
2     Registry
3   
4   var
5     RG: Registry;
6     PrinterName: string; {This is just a value}
7     Buffer: array[0..1024] of Char; {This is the Binary data}
8     J, K: Integer;
9     dFiles: array[0..5] of string;
10      {The string data that will be converted to Binary Data}
11    S, S2: string;
12    sChar: Char;
13  
14  procedure Whatever;
15  begin
16    {Reset buffer}
17    for i := 0 to 1024 do
18      buffer[i] := #00;
19    {Reset S}
20    S := '';
21    dfiles[0]: 'MyPrint.Drv';
22    dfiles[1]: 'MyPrint.DLL';
23    dfiles[2]: 'Myunit.DLL';
24    dfiles[3]: 'MyPrint.HLP';
25    dfiles[4]: 'MyPrnt2.DLL';
26    dfiles[5]: 'MyPrnt3.DLL';
27    {Copy all items into one string seperated by a NULL ##00}
28    for J := 0 to 5 do
29    begin
30      S := S + dFiles[k] + #00; {Copy strings to 1 string and add a #00}
31      K := Length(S); {K function is to store the string length}
32    end;
33    {Convert String to char array called buffer}
34    for J := 1 to K do
35    begin
36      S2 := Copy(S, J, 1); {Copy 1 char to string S2}
37      sChar := S2[1]; {Copy S2 to sChar}
38      buffer[J - 1] := sChar; {Copy sChar to buffer}
39    end;
40    {The char array MUST end with 2 NULLS}
41    Buffer[K + 1] := #00;
42    Printername := 'MyPrinter';
43    rg := TRegistry.create;
44    rg.rootkey := hkey_local_machine;
45    
46  rg.Openkey('System\CurrentControlSet\Control\Print\Environments\Windows4.0\Drivers\'
47      + PrinterName, true);
48    rg.writebinarydata('Dependent Files', buffer, K + 1);
49    rg.Closekey;
50  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC