Главная страница
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.046 c
2-1139857337
аматор
2006-02-13 22:02
2006.03.05
выловить сообщения Indi клиента к серверу (чат)


1-1138790667
ALS
2006-02-01 13:44
2006.03.05
XPManifest + LoadCursor = глюк


3-1137207954
psyBNC
2006-01-14 06:05
2006.03.05
ПРОБЛЕМА С БАЗОЙ ДАННЫХ


2-1140241181
Хинт
2006-02-18 08:39
2006.03.05
Помогите разобраться с TSocket (WinSock)


2-1140182876
Newbee
2006-02-17 16:27
2006.03.05
Подскажите, почему не работает ?