2011. január 28., péntek

How to use WriteBinaryData


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



  RG: Registry;
  PrinterName: string; {This is just a value}
  Buffer: array[0..1024] of Char; {This is the Binary data}
  J, K: Integer;
  dFiles: array[0..5] of string;
    {The string data that will be converted to Binary Data}
  S, S2: string;
  sChar: Char;

procedure Whatever;
  {Reset buffer}
  for i := 0 to 1024 do
    buffer[i] := #00;
  {Reset S}
  S := '';
  dfiles[0]: 'MyPrint.Drv';
  dfiles[1]: 'MyPrint.DLL';
  dfiles[2]: 'Myunit.DLL';
  dfiles[3]: 'MyPrint.HLP';
  dfiles[4]: 'MyPrnt2.DLL';
  dfiles[5]: 'MyPrnt3.DLL';
  {Copy all items into one string seperated by a NULL ##00}
  for J := 0 to 5 do
    S := S + dFiles[k] + #00; {Copy strings to 1 string and add a #00}
    K := Length(S); {K function is to store the string length}
  {Convert String to char array called buffer}
  for J := 1 to K do
    S2 := Copy(S, J, 1); {Copy 1 char to string S2}
    sChar := S2[1]; {Copy S2 to sChar}
    buffer[J - 1] := sChar; {Copy sChar to buffer}
  {The char array MUST end with 2 NULLS}
  Buffer[K + 1] := #00;
  Printername := 'MyPrinter';
  rg := TRegistry.create;
  rg.rootkey := hkey_local_machine;
    + PrinterName, true);
  rg.writebinarydata('Dependent Files', buffer, K + 1);

Nincsenek megjegyzések:

Megjegyzés küldése