Всем привет!
Такая проблема:
Написал на С библиотеку:
файл unit1.cpp
Код:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #define BUILD_DLL
#include "File1 . h"
#include <vcl . h>
#include <windows . h>
#pragma hdrstop
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
int Messagess (int k)
|
заголовочный файл File1.h
Код:
1 2 3 4 5 6 7 8 9 10 | # if defined(BUILD_DLL)
# define DLL_EXP __declspec(dllexport)
# else
# if defined(BUILD_APP)
# define DLL_EXP __declspec(dllimport)
# else
# define DLL_EXP
# endif
#endif
DLL_EXP int Messagess (int k);
|
нарисовал в Дельфи тестовую форму с кнопкой
Код:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | type
Tcalc_double = function ( k: integer ): integer ;
................
procedure TForm1 . Button2Click(Sender: TObject);
var
hndDLLHandle: THandle;
calc_double: Tcalc_double;
begin
try
hndDLLHandle := loadLibrary ( 'C:\C\t3\project1.dll' );
if hndDLLHandle <> 0 then begin
@calc_double := getProcAddress ( hndDLLHandle, 'Messagess' );
if addr ( calc_double ) <> nil then begin
showMessage ( intToStr ( calc_double ( 105 ) ) );
end else
showMessage ( 'Function not exists...' );
end else
showMessage ( 'DLL not found...' );
finally
freeLibrary ( hndDLLHandle );
end ;
end ;
|
Смотрю в дебаге - библиотеку подцепил, а вот функция getProcAddress ( hndDLLHandle, 'Messagess' ) говорит, что нет такой функции в библиотеке.
Очень хочется разобраться в данном вопросе, т.к. в будущем потребуется подключать к некоторым проектам С-шные библиотеки.
Спасибо.