من می خواهم یک Dll بسازم که توش یک تابع باشه این تابع یک عدد بگیره و بعد آن عدد را در 3 ضرب کنه .
یکی زحمت بکشه و بگه کدش را چه جوری بنویسم ؟
من می خواهم یک Dll بسازم که توش یک تابع باشه این تابع یک عدد بگیره و بعد آن عدد را در 3 ضرب کنه .
یکی زحمت بکشه و بگه کدش را چه جوری بنویسم ؟
اینم مثال نه اون چیزی که می خواهی :
library Persian;
{ 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
SysUtils,
Classes,
DateUtils,
Utils;
{$R *.res}
Function PrintDate: ShortString;
begin
Result := datetostr(date);
End;
Exports
PrintDate;
begin
end.
آقای توسکا خیلی ممنون
من همه ای اون کدهایی که شما نوشتید را استفاده کردم همه مراحل خوب پیش میره حتی تو پروژه ای که هم که از آن Dll استفاده می کنم قشنگ تابع را میشناسه
اما
موقع اجرای برنامه این خطا را میدهد
راستی شما بعد از این که اون کدها را نوشتید دیگه چه کارهایی می کنید به طور مثال کامپایل می کنید یا کارهای دیگه
شما چه جوری ازش استفاده کردید کد استفاده رو بنویسید.
library Project1;
{ 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
SysUtils,
Classes;
{$R *.res}
Function Test: ShortString;
begin
Result := 'Laia' ;
End;
Exports
Test;
begin
end.
آقای توسکا شما بعد از این که کد را نوشتید چی کار می کنید ؟
از برنامه خارج می شوید .!
کامپایل می کنید .!
من نه در کد شما و نه در کد آقای Touska تابعی به اسم PrintNormal نمی بینم. پیغام خطا هم میگه که همچین تابعی در DLL مربوطه وجود نداره
به این شکل البته بصورت استاتیک :
Function PrintDate: ShortString;بعد ازش استفاده می کنم.
External 'persian.dll';
از این روش هم برای خواندن استفاده کردم اما بازم همون خطای با لا را میدهنوشته شده توسط Touska
Function PrintDate: ShortString;
External 'persian.dll';
آقای توسکا خیلی ممنون که پیگیر این مسئله شده اید
میشه پروژه Dll را ذخیره کرده و اینجا آپلود کنید ؟