Using ssdeep DLL in Delphi 2010

I try to use ssdeep DLL from this http://ssdeep.sourceforge.net in Delphi 2010. This is just a simple DLL i think, but I still have no luck. Error always occurred.

The export function prototype:

/* Opens, reads, and hashes the contents of the file 'filename'
   The result must be allocated to hold FUZZY_MAX_RESULT characters.
   Returns 0 on success, non-zero on error. */
extern int fuzzy_hash_filename(char * filename, char * result);


const
  SPAMSUM_LENGTH = 64;
  //FUZZY_MAX_RESULT = (SPAMSUM_LENGTH + (SPAMSUM_LENGTH /2 + 20));

// int fuzzy_hash_filename(char * filename, char * result);
function fuzzy_hash_filename(filename : PAnsiChar; var result : PAnsiChar) : integer; external 'fuzzy.dll' name 'fuzzy_hash_filename';

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  Res : PAnsiChar;
  FUZZY_MAX_RESULT : integer;
  i : integer;
begin
  FUZZY_MAX_RESULT := (SPAMSUM_LENGTH + (SPAMSUM_LENGTH div 2 + 20));
  GetMem(Res, FUZZY_MAX_RESULT);
  i := fuzzy_hash_filename('C:\Windows\Notepad.exe', Res);
  ShowMessage('Result: '+ IntToStr(i));
  ShowMessage(AnsiString(Res));
  FreeMem(Res);
end;

Open in new window

rajatopAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Emmanuel PASQUIERFreelance Project ManagerCommented:
most certainly your result parameter is not a VAR (it is already a pointer)

function fuzzy_hash_filename(filename : PAnsiChar; result : PAnsiChar) : integer; external 'fuzzy.dll' name 'fuzzy_hash_filename';
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rajatopAuthor Commented:
Ahh..my bad. Thanks again epasquier!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.