hi there experts!!!
i have the following dll. (part 1-see code below).
it has an exported function that returns as a string the physical memory
available to the system
in part 2)(see code below) i just call the exported function from a simple form with a button but i get an error back.
the dll and the project i call the dll are in the same folder.
please advise
1)************************
**********
****
library thenewdll;
{ Important note about DLL memory management: ShareMem must be the
first unit in your library's USES clause AND your project's (select
Project-View Source) USES clause if your DLL exports any procedures or
functions that pass strings as parameters or function results. This
applies to all strings passed to and from your DLL--even those that
are nested in records and classes. ShareMem is the interface unit to
the BORLNDMM.DLL shared memory manager, which must be deployed along
with your DLL. To avoid using BORLNDMM.DLL, pass string information
using PChar or ShortString parameters. }
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StdCtrls,
shellapi,
shlobj,
CommCtrl,
comobj;
{$R *.res}
function gettotalmem():string;
var
GlobalMemoryInfo: TMemoryStatus; // holds the global memory status information
begin
{set the size of the structure before the call}
GlobalMemoryInfo.dwLength := SizeOf(GlobalMemoryInfo);
{retrieve the global memory status...}
GlobalMemoryStatus(GlobalM
emoryInfo)
;
{and display the information}
gettotalmem := IntToStr(GlobalMemoryInfo.
dwTotalPhy
s);
end;
exports gettotalmem;
end.
**************************
**
2)*******
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
procedure gettotalmem; external 'thenewdll.dll'
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender
: TObject);
var
x:string;
begin
x:=gettotalmem;
showmessage(x);
end;
end.
*********************