Главная страница
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.48 MB
Время: 0.045 c
15-1139562745
Marat
2006-02-10 12:12
2006.03.05
IB Expert


2-1140347658
Officeman
2006-02-19 14:14
2006.03.05
GetFileTime()


3-1136482144
VST
2006-01-05 20:29
2006.03.05
Соединение Delphi и mySQL


1-1138722806
pound
2006-01-31 18:53
2006.03.05
Графическое изображение


4-1134560930
kami
2005-12-14 14:48
2006.03.05
как определить, под каким именем запущен процесс?