Intro Download and install Frequently Asked Questions Tips and tricks

Homepage







© J.C. Kessels 2009
MyDefrag Forum
May 25, 2013, 01:22:35 am *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: defragdll in delphi error  (Read 3131 times)
delphino
Newbie
*
Posts: 1


View Profile
« on: May 18, 2007, 12:39:23 am »

delphino2006 a écrit : Salut...,
j'utilise une dll ecrite en C++,dans delphi,  
type
charp=^char;
var
Form1: TForm;
const
NomDLL = 'DefragDll.dll';
//1° - declaration static:
Function RunDefrag(MountPoint : pchar;Mode:integer):integer;cdecl; external 'DefragDll.dll' name 'RunDefrag';
 
implementation
{$R *.dfm}
 
function LierFonction(DLL: String; var HandleDLL: THandle; NomFct: String; IndexFct: Integer = -1): Pointer;
begin
Result := nil;
HandleDLL := 0;
HandleDLL := LoadLibrary(pAnsiChar(DLL));
If HandleDLL = 0 then
Exit;
If IndexFct < 0 then
Result := GetProcAddress(HandleDLL, pAnsiChar(NomFct))
else
Result := GetProcAddress(HandleDLL, pAnsiChar(IndexFct));
end;
 
2° -declaration denamique.
 
procedure TForm1.Button1Click(Sender: TObject);
var HandleDLL: THandle;
RunDefrag : function(MountPoint:charp;Mode:integer):integer;cdecl ; //Notre fonction, sous forme de variable.
begin
RunDefrag := LierFonction(NomDLL, HandleDLL, 'RunDefrag');
If assigned(RunDefrag) then
begin
RunDefrag(nil,1);
FreeLibrary(HandleDLL);
end
else
ShowMessage('Erreur de chargement de la fonction "rundefrag"');
end;
//----------------------
 
//Static procedure .....
 
procedure TForm1.Button2Click(Sender: TObject);
begin
RunDefrag(nil,1);
end;
mais toujour rien erreur de compilation  ;
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.5 | SMF © 2006-2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!