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

Вниз

Что написано в DLL неверно???   Найти похожие ветки 

 
Volf_555   (2006-02-14 21:57) [0]

Вот мой код 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 MyFact(s:Integer):Integer; stdcall;
var
a:Integer;
res:Integer;
begin
if s=0 then
 res:=1 else
if s>0 then
 for a:=1 to s do
  res:=res*a else
if s<0 then
begin
 for a:=1 to abs(s) do
  res:=res*a;
 res:=res*-1;
end;
result:=res;
end;

function MyStep(chislo:Integer;stepen:Integer):Integer; stdcall;
var
a:Integer;
res:Integer;
begin
res:=1;
if stepen>0 then
begin
 for a:=1 to stepen do
  res:=res*chislo;
end else
if stepen<0 then
begin
 for a:=1 to abs(stepen) do
  res:=res*chislo;
 res:=1 div res;
end else
if stepen=0 then
 res:=1;

result:=res;
end;

exports
function MyFact;
function MyStep;

begin

end.


При компиляции выскакивает ошибка:
[Error] Project1.dpr(62): Identifier expected but "FUNCTION" found
[Error] Project1.dpr(62): Function needs result type


Что в моей DLL неверно?!


 
begin...end ©   (2006-02-14 22:03) [1]

> Volf_555   (14.02.06 21:57)

> exports
> function MyFact;
> function MyStep;

exports
 MyFact, MyStep;


 
kaZaNoVa ©   (2006-02-14 22:04) [2]

....

exports  MyFact, MyStep;

begin

end.


 
Volf_555   (2006-02-14 22:08) [3]

Точно! Спасибо :)


 
evvcom ©   (2006-02-15 09:05) [4]


> begin
> if s=0 then
>  res:=1 else
> if s>0 then
>  for a:=1 to s do
>   res:=res*a else

А вот на Warning "Variable "res" might not have been initialized" стоит обратить внимание!


 
AbrosimovA   (2006-02-16 11:46) [5]

Зачем вводить промежуточную переменную res, если можно использовать Result, например:
function MyFact(s:Integer):Integer; stdcall;
var
a:Integer;
begin
Result:=1;
if s>0 then
for a:=1 to s do
 Result:=Result*a;
if s<0 then
begin
for a:=1 to abs(s) do
 Result:=Result*a;
Result:=Result*-1;
end;
end;



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

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

Наверх




Память: 0.47 MB
Время: 0.051 c
2-1139933525
nyron
2006-02-14 19:12
2006.03.05
связка с excel


3-1136733352
VadimSpb
2006-01-08 18:15
2006.03.05
Как программно подключить БД?


2-1139992784
Mishenka
2006-02-15 11:39
2006.03.05
Работа с множествами


15-1139774347
ArtemESC
2006-02-12 22:59
2006.03.05
NTFS


8-1127629243
VVA
2005-09-25 10:20
2006.03.05
MediaPlayer медляк