델파이에서 dll 로 링크드리스트를 써서 값을 가져올려고 하는데 잘않되네요.
c++에서 값은 잘들어가는데 delphi 에서 가져올때 문제가 있는것 같습니다.
무엇이 문제일까요?
//////////////////////////////////////////////////////
// delphi source
type
PTEST = ^TEST
TEST = packed record
Index : Ingeger;
NEXT : PTEST;
end;
TFunc = function(Output:PTEST):Integer; stdcall;
var
H : Handle;
TEST_F:TFunc;
Output : PTEST;
begin
H := LoadLibrary('TEST.DLL');
@TEST_F := GetProcAddress(H, 'TEST_OUT');
New(Output);
Result:=TEST_F(Output);
while(Output <> nil) do
begin
{ 막상돌리면 여기에 값이 없음...}
nIndex := Output^.Index;
Output := Output^.NEXT;
end;
end;
//////////////////////////////////////////////////////
// c++ source
typedef struct TEST
{
int Index;
TEST* NEXT;
}
TEST* head, *New,*current = NULL;
int WINAPI EXPORT TEST_OUT(TEST* pTest)
{
pTest = NULL;
head = NULL;
New = NULL;
current = NULL;
New = (PTEST*)malloc(sizeof(PTEST));
New->pNext = head;
head = New;
New->Index = 1;
New = (PTEST*)malloc(sizeof(PTEST));
New->pNext = head;
head = New;
New->Index = 2;
New = (PTEST*)malloc(sizeof(PTEST));
New->pNext = head;
head = New;
New->Index = 3;
pTest = head;
return 0;
}
|