мне нужно создать dll в Visual C++ 6.0 а использовать ее в Delphi Подскажите как...? Вот пльзуясь стандартным мастером создаю: cpp
| Код | #include "stdafx.h" #include "SpyFound.h"
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; }
// This is an example of an exported variable SPYFOUND_API int nSpyFound=0;
// This is an example of an exported function. SPYFOUND_API int fnSpyFound(void) { return 42; }
// This is the constructor of a class that has been exported. // see SpyFound.h for the class definition CSpyFound::CSpyFound() { return; }
|
h
| Код | #ifdef SPYFOUND_EXPORTS #define SPYFOUND_API __declspec(dllexport) #else #define SPYFOUND_API __declspec(dllimport) #endif
// This class is exported from the SpyFound.dll class SPYFOUND_API CSpyFound { public: CSpyFound(void); // TODO: add your methods here. };
extern SPYFOUND_API int nSpyFound;
SPYFOUND_API int fnSpyFound(void);
|
вот так чочу использовать:
| Код | type TExecDialog=function():Integer; stdcall;
procedure TForm1.Button1Click(Sender: TObject); var ExecDialog:TExecDialog; HLib:THandle; ret:Integer; begin HLib:=0; try HLib:=LoadLibrary('SpyFound.dll'); if HLib>HINSTANCE_ERROR then begin ExecDialog:=GetProcAddress(HLib,'fnSpyFound'); if Assigned(ExecDialog) then begin ret:=ExecDialog(); end; end; finally if HLib>HINSTANCE_ERROR then FreeLibrary(HLib); end; end;
|
но ничего не получается ExecDialog:=GetProcAddress(HLib,'fnSpyFound'); возвращает NULL и все тут как быть подправте пожалуйста?
Если можно дайте какой-нибудь пример. |