Debugge dll i visual c++
Hej,Jeg kan godt kopilere følgende c++ kode og delphi kode men jeg før følgende fjel når chartest kaldes:
access violation at address .....
Er det muligt at starte delphi programmet fra C++ så man kan debugge dll'en?
Tchartest = function ():Pchar; {$IFDEF WIN32} stdcall; {$ENDIF}
...
procedure TForm1.button1Click(Sender: TObject);
var
chartest:Tchartest;
DLLHandle: THandle;
seq:Pchar;
begin
//load dll
DLLHandle := LoadLibrary(Pchar('.\dlls\chartest.dll'));
if DLLHandle <> 0 then
begin
@chartest :=GetProcAddress(DLLHandle, 'chartestF');
seq:=chartest();
end;
end;
FreeLibrary(DLLHandle);
resultmemo.Lines.Add(seq);
end;
// TestScore.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "TestScore.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
TESTSCORE_API int nTestScore=0;
// This is an example of an exported function.
TESTSCORE_API char* chartestF(void)
{
char* pstringchar = "test";
return pstringchar;
}
mvh,
Rune