Thema: Delphi C in Delphi Übersetzen

Einzelnen Beitrag anzeigen

Gehstock

Registriert seit: 28. Jan 2006
Ort: Görlitz / Sachsen
489 Beiträge
 
Delphi 2007 Professional
 
#4

Re: C in Delphi Übersetzen

  Alt 21. Apr 2007, 19:52
Delphi-Quellcode:
unit Unit3;

interface

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

type
  TForm3 = class(TForm)
    MemoInfo: TMemo;
    Button1: TButton;
    EditIMEI: TEdit;
    Check: TEdit;
    procedure Button1Click(Sender: TObject);
    procedure EditIMEIChange(Sender: TObject);
    procedure EditIMEIKeyPress(Sender: TObject; var Key: Char);
    procedure MemoInfoKeyPress(Sender: TObject; var Key: Char);
    procedure CheckKeyPress(Sender: TObject; var Key: Char);
    procedure FormCreate(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;
  IMEI,std:char;
  IMEI_PATCH,IMEI74,IMEI9C:array [0..16] of char;
  IMEICC:array [0..32] of char;
// Argv:array [0..9] of Pchar;
   IMEI15:string;
implementation

{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
var
NCKKN,NSCKN,SPCKS,CKCCK,PCKKP : string;
NCKKN2,NSCKN2,SPCKS2,CKCCK2,PCKKP2 : string;
begin


//Start
//+++++++++++++++++++++++++++++++++++++++++++++++++
MemoInfo.lines.add('Prüfe eingegebene IMEI');
If length(EditIMEI.Text)<14 then begin
MemoInfo.lines.add('Falsche IMEI eingegeben');
end
else begin
IMEI15:= EditIMEI.Text+Check.Text;
MemoInfo.Lines.Add('Codes für IMEI : '+imei15);
{int IMEI_code(char* IMEI, char *std);



int IMEI_code(char* IMEI, char *std)  }

{

char std1[]="DG1";

char dest[16];
int b=0;
int i;





for (i=0;i<16;i := i + 1)
  dest[i]=0;


for (i=0;i<37;i := i + 1)
  IMEICC[i]=0;

  strcpy(dest,std1);




for(i=0;i<8;i := i + 1)
{
  b+=IMEI[i+6];
  IMEI_PATCH[i]=IMEI[i+6];


for(i=0;i<8;i := i + 1)

  IMEI_PATCH[i+8]=0x64-IMEI_PATCH[i];


IMEI_PATCH[16]=0;



switch(b%3)
{
default:
case 0: for(i=0;i<16;i := i + 1)
{
  IMEI74[i]=IMEI_PATCH[i];
;break;


case 1: for(i=0;i<16;i := i + 1)
{
  IMEI74[15-i]=IMEI_PATCH[i];
;break;

  case 2:
for(i=0;i<16;i := i + 1)
{
  if(!(i%2))
  {
    IMEI74[i]=IMEI_PATCH[i+1];

  else
  {
  IMEI74[i]=IMEI_PATCH[i-1];

;




  strcat(dest,std);
  strcat(dest,std1);
  strcat(dest,std);



for(i=0;i<16;i := i + 1)
{
IMEI9C[i]=(IMEI74[i]+dest[i])%100;



IMEI74[16]=0;
IMEI9C[16]=0;




switch(b%10)
{
case 1:
for(i=0;i<8;i := i + 1)
{
IMEICC[i*4]=(IMEI74[i*2]|dest[i*2]|IMEI9C[i*2]|IMEI9C[i*2])%10;

break;
case 2:
  for(i=0;i<8;i := i + 1)
{
IMEICC[i*4]=(IMEI74[(i*2)+1]|dest[(i*2)+1]|IMEI9C[(i*2)+1]|IMEI9C[(i*2)+1])%10;

  break;
case 3:
  for(i=0;i<8;i := i + 1)
{
IMEICC[i*4]=((IMEI74[i*2]|dest[i*2])&IMEI9C[i*2]|IMEI9C[i*2])%10;

break;
case 4:
for(i=0;i<8;i := i + 1)
{

IMEICC[i*4]=((IMEI74[(i*2)+1]|dest[(i*2)+1])&IMEI9C[(i*2)+1]|IMEI9C[(i*2)+1])%10;

break;
case 5:
for(i=0;i<8;i := i + 1)
{
IMEICC[i*4]=((IMEI74[i*2]|dest[i*2]|IMEI9C[i*2])&IMEI9C[i*2])%10;

break;
case 6:
for(i=0;i<8;i := i + 1)
{
IMEICC[i*4]=((IMEI74[(i*2)+1]|dest[(i*2)+1]|IMEI9C[(i*2)+1])&IMEI9C[(i*2)+1])%10;

break;
case 7:
for(i=0;i<8;i := i + 1)

  IMEICC[i*4]=((IMEI74[i*2]&dest[i*2])|IMEI9C[i*2]|IMEI9C[i*2])%10;

break;
case 8:
for(i=0;i<8;i := i + 1)
{
IMEICC[i*4]=((IMEI74[(i*2)+1])&dest[(i*2)+1]|IMEI9C[(i*2)+1]|IMEI9C[(i*2)+1])%10;

break;
case 9:
for(i=0;i<8;i := i + 1)
{
IMEICC[i*4]=(((IMEI74[i*2]&dest[i*2])|IMEI9C[i*2])&IMEI9C[i*2])%10;

break;
default:
  for(i=0;i<8;i := i + 1)
{
IMEICC[i*4]=(((IMEI74[(i*2)+1]&dest[(i*2)+1])|IMEI9C[(i*2)+1])&IMEI9C[(i*2)+1])%10;





for(i=0;i<8;i := i + 1)
  printf("%d",IMEICC[i*4]);


}


MemoInfo.lines.add('NCKKN Code: **00012*'+(NCKKN)+'#');
MemoInfo.lines.add('NCKKN2 Code: **00012*'+(NCKKN2)+'#');
MemoInfo.lines.add('NSCKN Code: **00022*'+(NSCKN)+'#');
MemoInfo.lines.add('NSCKN2 Code: **00022*'+(NSCKN2)+'#');
MemoInfo.lines.add('SPCKS Code: **00032*'+(SPCKS)+'#');
MemoInfo.lines.add('SPCKS2 Code: **00032*'+(SPCKS2)+'#');
MemoInfo.lines.add('CKCCK Code: **00042*'+(CKCCK)+'#');
MemoInfo.lines.add('CKCCK2 Code: **00042*'+(CKCCK2)+'#');
MemoInfo.lines.add('PCKKP Code: **00052*'+(PCKKP)+'#');
MemoInfo.lines.add('PCKKP2 Code: **00052*'+(PCKKP2)+'#');
end;
end;


procedure TForm3.CheckKeyPress(Sender: TObject; var Key: Char);
begin
if not(Key in [#9,#8,'0'..'9']) then Key:=#0;
end;


procedure TForm3.EditIMEIChange(Sender: TObject);

var
i,x,c : integer;
s,si : string;
i15: char;
begin
  x:=length(EditIMEI.text);
  if x < 14 then begin
  exit;
  check.Text:='';
  end;
  c:=0;
  for i:=1 to 14 do begin
    if (EditIMEI.text[i]<'0') or (EditIMEI.text[i]>'9') then exit;
    if ((i and 1)<>0) then c := c +(Byte(EditIMEI.text[i]) and $0F)
    else
     if (EditIMEI.text[i]>'4') then c := c +((Byte(EditIMEI.text[i]) and $0F)shl 1) - 9
     else c := c + ((Byte(EditIMEI.text[i]) and $0F) shl 1);
  end;

  s:=IntToStr(c);
  i:=length(s);
  i15:=s[i];
  if i15<>'0then Byte(i15):=$6A-Byte(i15);
check.Text:=i15;
end;



procedure TForm3.EditIMEIKeyPress(Sender: TObject; var Key: Char);
var
x:integer;
begin
 if not(Key in [#9,#8,'0'..'9']) then Key:=#0;
 x:=length(EditIMEI.text);
  if x < 14 then begin
  exit;
  check.Text:='';
  end;
end;

procedure TForm3.FormCreate(Sender: TObject);
begin
//
end;

procedure TForm3.MemoInfoKeyPress(Sender: TObject; var Key: Char);
begin
 Key:=#0;
end;

end.

Komm net weiter kann mir jemend n klkeinen teil vormachen Bitte?
Marcel
  Mit Zitat antworten Zitat