Einzelnen Beitrag anzeigen

QuickAndDirty

Registriert seit: 13. Jan 2004
Ort: Hamm(Westf)
1.889 Beiträge
 
Delphi 12 Athens
 
#6

Re: C Code in Delphi

  Alt 6. Mär 2008, 11:25
Zitat von caN:
Hallo,
Also Ich möchte gern wissen wie ich das in Delphi machen kann.
Ich danke euch schonmal im Vorraus für die Antworten.




Delphi-Quellcode:
Type
  TFunktion = Function(b1:Pchar; l:integer; p:TPointer):integer

  Tstruct = record
        n1 : longword;
        it : Pchar;
        n2 :longword;
        n3 : longword;
        n4 : longword;
        len : longword;
        n5 : longword;
        n6 : array [0..39] of char;
  end;

var
  funcdll:TFunktion ;
  struct_DLL:TStruct;
    
Begin
  hLib := LoadLibrary(DLL);
  if not hLib then
    Raise exception.create('kaputt');

  funcdll = GetProccAddress(Hlib, 'MeineProzedur');
  // initialisieren von struct_dll kann ich nicht auswendig
  funcdll(stritt, length(stritt), @struct_dll)
// es = strdup(struct_dll.it); // Kenne ich nicht
  FreeLibrary(hLib);
end.
Könnte so ähnlich gehen

Code:
int (*funcdll)(const uint8_t *p, const int length, const void *xp);

    struct {
        uint32_t   n1;      
        uint8_t    *it;    
        uint32_t   n2;      
        uint32_t   n3;      
        uint32_t   n4;    
        uint32_t   len;  
        uint32_t   n5;      
        uint8_t    n6[40];
    } struct_dll;

    hLib = LoadLibrary(DLL);
    if(!hLib) std_err();

    funcdll = (void *)hLib + OFFSET;

    memset(&struct_dll, 0, sizeof(struct_dll));

    funcdll(stritt, strlen(stritt), &struct_dll);

    es = strdup(struct_dll.it);
    FreeLibrary(hLib);
[edit=SirThornberry]c-tags gesetzt - nächstes mal bitte selbst machen - Mfg, SirThornberry[/edit]
Andreas
Monads? Wtf are Monads?
  Mit Zitat antworten Zitat