Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2005.09.18;
Скачать: CL | DM;

Вниз

Помогите переделать статистичн. вызов DLL в динамичный.   Найти похожие ветки 

 
rolex   (2005-08-27 22:57) [0]

Вот так функция вызывается статистически:

function GetProfilesDirectory:string;
function ProfilesDirectory_Exp(lpProfilesDir:PChar; var lpcchSize:DWord):Bool;
stdcall; external "userenv.dll" name "GetProfilesDirectoryA";

var szBuffer:array[0..MAX_PATH] of Char; dwSize:DWord;
begin
dwSize := MAX_PATH;
if ProfilesDirectory_Exp(szBuffer, dwSize) then result:=szBuffer;
end;


А как сделать динамический? Делаю так:
unit Unit1;

interface

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

type
 TProfi = function(lpProfilesDir: PChar; var lpcchSize: DWord): Bool;

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

var
 Form1: TForm1;

implementation

{$R *.dfm}

function GetProfilesDirectory: string;
var
 hndDLLHandle: THandle;
 Profi: TProfi;
 szBuffer: array[0..MAX_PATH] of Char; dwSize: DWord;
begin
 dwSize := MAX_PATH;
 Result:="";
 try
   hndDLLHandle := loadLibrary("userenv.dll");
   if hndDLLHandle <> 0 then
   begin
     @Profi := getProcAddress(hndDLLHandle, "GetProfilesDirectoryA");
     if addr(Profi) <> nil then
     begin
       Profi(szBuffer, dwSize);
       Result := szBuffer;
     end;
   end;
 finally
   freeLibrary(hndDLLHandle);
 end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
caption:=GetProfilesDirectory;
end;

end.


Ничего не вышло (кроме ошибки :) ).


 
DiamondShark ©   (2005-08-27 23:35) [1]


> type
>  TProfi = function(lpProfilesDir: PChar; var lpcchSize:
> DWord): Bool;

TProfi = function(lpProfilesDir: PChar; var lpcchSize: DWord): Bool; stdcall;


 
rolex   (2005-08-28 12:42) [2]

спасибо огромное!



Страницы: 1 вся ветка

Текущий архив: 2005.09.18;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.026 c
1-1125041794
ruslan_as
2005-08-26 11:36
2005.09.18
Afalina Soft XL Report 4 - "Ошибка сервера"


14-1124668594
Piter
2005-08-22 03:56
2005.09.18
Тест на дальтонизм :)


1-1124786728
ищущий ответ
2005-08-23 12:45
2005.09.18
Куда пропадает кнопка?


14-1124867021
Santrope
2005-08-24 11:03
2005.09.18
Подскажите кто поёт, очень прошу...


4-1122287537
AxelBlack
2005-07-25 14:32
2005.09.18
Вопрос об использовании параметров WM_SysCommand в Perform