C w Delphi

0

Witam
Potrzebuje napisać ten kawałek kodu w delphi

typedef void _Point(int typ, char* text);

struct TData
{
_Point *Point;
int line;
char text[256];
};
TData = record
Point : ^_Point;
line : integer;
text : array [1..256] of char;
end;

Tutaj problem z parametrem point którym jest funkcja _Point

procedure _Point (typ :Integer; array [1..256] of char);

I taka funkcja

void Thread(TData *data)
{
data->Point(data->line, data->text);
}

Jest możliwości napisania tego w Delphi 7?

0

Nie wiem czy zamiast ^ nie powinno być @.

poza tym próbowałeś to kompilować? Jeżeli jest błąd, to co mówi delphi?

0

Delphi mówi
"[Error] Unit1.pas(31): Undeclared identifier: '_Point'"
z @
"[Error] Unit1.pas(31): Type expected but '@' found"

0

To znaczy że nie zadeklarowałeś procedury albo jej nie zdefiniowałeś.
Pokaż kod jaki już napisałeś.

0

Dodałem ją

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;


type
TData = packed record
Point : ^_Point;
line : integer;
text : array [1..256] of char;
end;






type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  procedure _Point (line :Integer; text:String);


implementation

{$R *.dfm}

procedure Thread(data : TCast);
var
Datas : ^TCast;
begin
Data.Cast := @datas.typ ;
begin

end;
0

A gdzie deklaracja funkcji? Czy jej nie wkleiłeś. Jeśli jej nie ma to może najpierw ogarnij podstawy Delphi.

0

Dd początku

typedef void _Point(int line, char* text);

struct TData
{
    _Point *Point;
     int line;
     char text[256];
};

void Thread(TData *data)
{
    data->Point(data->line, data->text);
}

Ta procedura to typ, to gdzie mam ja zdefiniować
Tdata.Point jest ta procedura

0

tak ?

type
  _Point = procedure(typ :Integer; text: array of char);

  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  TData = record
    Point : _Point;
    line : integer;
    text : array [1..256] of char;
  end;

Ale na niewiele się to zda, bo jeszcze trzeba przypisać adres funkcji temu wskaźnikowi. Może ktoś inny się wypowie :>

2

powinno być tak:

type _Point = procedure(typ:integer; text:pansichar); cdecl;

type TData = record
  Point:_Point;
  line:integer;
  text:array[0..255] of char;
end;
0

Tak teraz się kompiluje ale czy wszystko zadziała
to nie wiem, jak by co to jeszcze napisze
dzięki

0

jakby nie działało spróbuj:
text:PChar
ale możliwe że pchar to to samo co pansichar (nie sprawdzałem)

0

PChar jest wskaźnikiem na Char; PAnsiChar jest wskaźnikiem na AnsiChar; w Delphi dla Win32 Char == AnsiChar

nie całkiem: w Delphi 2007 i starszych Char = AnsiChar, w Delphi 2009 i nowszych Char = WideChar.

0

Mam jeszcze problem z wyświetleniem odpowiednich znaków
W delphi text powinien być tak

type _Point = procedure(line:integer;text : Pchar); cdecl;
type TData = record
  Point:_Point;
  line:integer;
  text : array [0..255] of char;
end;
PData = ^TData;
procedure Thread(data: PData) stdcall;
begin
  data.Point(data.line,data.text);
end;

i jest wszystko dobrze
ale dalej jest problem bo następna funkcja w C wygląda tak

void PointInject(DWORD pID, int line, char* text)
 TData data;
.
.    
sprintf(data.text, text);

W delphi

procedure PointInject(pID: Cardinal;line: Integer; text : Pchar);

i tylko ten sprintf zostaje którego nie wiem jak zapisać
próbowałem zmieniać na data.text na Pchar i rożne typy ale zawsze wyświetlana zły text

@@@@@@@@@@@@@
PROBLEM ROZWIĄZANY

1 użytkowników online, w tym zalogowanych: 0, gości: 1