|
Delphi7 DLL
[CUSTOMDLL.DLL]
---------------------------------------------------------------------------------------------
function GetCFindValue(AResultIndex, AGroup, AElement: Integer): PChar; stdcall;
var
StrTemp : PChar;
begin
StrTemp := Form1.GetFindValue(AResultIndex, AGroup, AElement);
Result := StrTemp;
end;
내용 생략
function TForm1.GetCFindValue(AResultIndex, AGroup, AElement: Integer): PChar; stdcall;
var
...
begin
...
ShowMessage(PChar(str1)); // 1990-01-03 , 메시지 확인
if str1 <> '' then
Result := PChar(str1)
else
Result := nil;
end;
리턴값 --> 1990-01-03
----------------------------------------------------------------------------------------------
C++builder2009
[MyManager.h]
typedef char* (__stdcall * _GetCFindValue)(int AResultIndex, int AGroup,int AElement);
[test.cpp]
#include "MyManager.h"
void __fastcall TForm1::Button1Click(TObject *Sender)
{
String strData;
HINSTANCE hLibrary;
_GetCFindValue GetCFindValue;
hLibrary=LoadLibrary("CUSTOM.dll");
if (hLibrary!=NULL)
{
GetCFindValue=(_GetCFindValue)GetProcAddress(hLibrary,"GetCFindValue");
if (GetCFindValue != NULL)
{
Memo1->Lines->Clear();
for(int i=0; i< n ; i++)
{
strData =GetCFindValue(i, 0x0010, 0x0030); //strData 변수에 깨져서 들어 옵니다.
//디버그확인 "1990-01-\x18"
Memo1->Lines->Add(IntToStr(i) + ">>Birth:" +strData );
}
}
}
FreeLibrary(hLibrary);
}
1.차시도 내용
Memo 마지막 글자가 깨집니다. (쓰레기 글자?)
1990-01-? , 1965-02-$
2. 차 시도
const char * pstrData =GetCFindValue(i, 0x0010, 0x0030);
Memo1->Lines->Add(IntToStr(i) + ">>Birth:" +strData );
동일 증상
1990-01-? , 1965-02-$ , Mark
해결을 어떻게 해야 하나요..
|