Bonjour,

me voilà encore avec ma DLL pas bien documentée.

Alors, je dois envoyer à une fonction un string nul terminated, du moins un pointeur.

J'arrive vie un for à remplir mon array of AnsiChar, puis après cela j'essaie de mettre un pointeur vers cet array, mais là, je trouve que le résultat est un peu spécial.

La valaur du pointeur est égale au string...

j'explique, si mon array vaut '0807012012AE', et bien, la valeur de mon pointeur sera lui aussi de '0807012012AE'. mais je m'attendrais à trouver une adresse mémoire ? non ??


voici ma fonction

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
procedure TForm1.b_set_timeClick(Sender: TObject);
var
  res3, i: integer;
  temp_time: String;
  t_now: TDateTime;
  pSetTime: PAnsiChar;
  SetTime: array[1..15] of AnsiChar;
  t_year, t_month, t_day, t_dayw, t_hour, t_min, t_sec: String;
  myYear, myMonth, myDay, myHour, myMin, mySec, myMilli: word;
begin
 
  device_open();
 
  t_now := now;
  DecodeDateTime(t_now, myYear, myMonth, myDay, myHour, myMin, mySec, myMilli);
 
  t_year := IntToHex(myYear-2000, 2);
  t_month := IntToHex(myMonth, 2);
  t_day := IntToHex(myDay, 2);
  t_dayw := IntToHex(DayOfTheWeek(t_now), 2);
  t_hour := IntToHex(myHour, 2);
  t_min := IntToHex(myMin, 2);
  t_sec := IntToHex(mySec, 2);
 
  temp_time := PAnsiChar(concat(t_year, t_month, t_day, t_dayw, t_hour, t_min, t_sec));
  for i := 1 to 14 do
  begin
    SetTime[i] := temp_time[i];
  end;
  SetTime[15] := #0;
  pSetTime := addr(SetTime[1]);
 
  res3 := WriteTime(dev_address, pSetTime);
 
  CloseCommPort(hCom);
 
end;
Alors, est-ce que tout est correcte ?
Sinon, à la place de la déclaration du pointeur en tant que PAnsiChar, j'ai pensé à mettre une déclaration en Pointer ???

Est-ce mieux ?