Ich hoffe es kann helfen
hier bi daten zu lesen und in ein string zu tun
Delphi-Quellcode:
//******************************************************************************
//HilfsFunction
//BI lesen
Function Reg_BI_Lesen_RYU(input_r : G_Reg): String;
const
bufsize = 500;
var
reg : TRegistry;
byte_size_i : Integer;
byte_len_i : Integer;
i : Integer;
hexstr_s : String;
byte_buffer_dab : Array of Byte;
output_s : String;
begin
reg := TRegistry.Create;
try
reg.RootKey := input_r.h1;
reg.OpenKey(input_r.k1, True);
SetLength(byte_buffer_dab, byte_size_i);
byte_len_i := Reg.ReadBinaryData(input_r.v1, PChar(byte_buffer_dab)^, byte_size_i);
hexstr_s := '';
output_s := '';
for i := 0 to byte_len_i - 1 do
begin
hexstr_s := IntToHex(byte_buffer_dab[i], 2);
output_s := output_s + '$' + hexstr_s;
end;
Result := output_s;
finally
reg.Free;
end;
end;
und hier aus den string in die reg zu tun
Delphi-Quellcode:
//******************************************************************************
//HilfsFunction
//BI schreiben
Procedure Reg_BI_Schreiben_RYU(input_r : G_Reg; daten_s : String);
type
PByteArray = ^TByteArray;
TByteArray = array[0..500] of Byte;
var
buffer_sl : TStringList;
reg : TRegistry;
datasize_i : Integer;
i : Integer;
j : Integer;
hexstr_s : String;
buffer_ba : PByteArray;
buffer_temp_s : String;
begin
try
buffer_sl := TStringList.Create;
buffer_sl.Clear;
hexstr_s := '';
hexstr_s := daten_s;
hexstr_s := '';
hexstr_s := daten_s;
//Alles in String Liste
for i := 0 to Length(hexstr_s) do
begin
if (hexstr_s <> '') then
begin
buffer_temp_s := '';
buffer_temp_s := Copy(hexstr_s, 1, 3);
Delete(hexstr_s, 1, 3);
buffer_sl.Append(buffer_temp_s);
end;
end;
datasize_i := buffer_sl.Count;
//Buffer grösse
if datasize_i > 0 then
begin
System.GetMem(buffer_ba, datasize_i);
end;
j := 0;
for i := 0 to buffer_sl.Count - 1 do
begin
hexstr_s := '';
hexstr_s := buffer_sl.Strings[i];
if j >= 0 then
begin
if hexstr_s <> '' then
begin
buffer_ba^[j] := StrToInt(hexstr_s);
end;
end;
Inc(j, 1);
end;
reg := TRegistry.Create;
try
reg.RootKey := input_r.h1;
reg.OpenKey(input_r.k1, True);
reg.WriteBinaryData(input_r.v1, buffer_ba^, datasize_i);
finally
reg.Free;
end;
System.FreeMem(buffer_ba);
finally
buffer_sl.Free;
end;
end;
wobei Reg_daten bei mir ein record ist wo ich den key, daten und value zu tun habe
ps die daten sehen dann so im String aus $a2$23 usw.
[edit=Daniel B]Delphi-Tags korrigiert. Mfg, Daniel B[/edit]