Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Начинающим";
Текущий архив: 2006.03.05;
Скачать: [xml.tar.bz2];

Вниз

Что написано в 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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.015 c
1-1138973753
DUDAS
2006-02-03 16:35
2006.03.05
выравнивание по вертикали в DBGrid


2-1139857337
аматор
2006-02-13 22:02
2006.03.05
выловить сообщения Indi клиента к серверу (чат)


1-1138957761
t0mk4
2006-02-03 12:09
2006.03.05
Image1. как вывести только один кусок картинки?


4-1134495543
Volf_555
2005-12-13 20:39
2006.03.05
Как в реестре можно сделать расширенное контекстное меню?


1-1138967347
Darvin
2006-02-03 14:49
2006.03.05
Запретить закрытие не основной формы по Alt-F4





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский