H
hupeh
Unregistered / Unconfirmed
GUEST, unregistred user!
我在delphi写了一个DLL,通过函数变量返回字符串
function _FastReplace(aSourceChar;aFindString,aReplaceStringChar;
CaseSensitive:boolean)Char;stdcall;
var
ret:String;
tempChar;
begin
ret := FastReplace(String(aSource),String(aFindString),String(aReplaceString),CaseSensitive);
GetMem(Temp,Length(ret));
StrCopy(temp,PChar(ret));
Result := temp;
end;
在BCB调用
char out[1000];
int iRet=0;
HMODULE m_hModule;
char* (*_FastReplace)(char*_aSource,char*_aFindString,char*_aReplaceString,bool _CaseSensitive);
m_hModule = ::LoadLibrary(LIB_NAME);
if(m_hModule>0)
{
iRet = 1;
(FARPROC& _FastReplace = ::GetProcAddress(m_hModule,"_FastReplace"
strcpy(out,_FastReplace(aSource,aFindString,aReplaceString,CaseSensitive));
FreeLibrary(m_hModule);
}
return iRet;
结果:
out的内容是正确的,但是iRet明明等于1,但是返回的时候这个值改动了,请问是什么问题。是DLL的问题吗?
function _FastReplace(aSourceChar;aFindString,aReplaceStringChar;
CaseSensitive:boolean)Char;stdcall;
var
ret:String;
tempChar;
begin
ret := FastReplace(String(aSource),String(aFindString),String(aReplaceString),CaseSensitive);
GetMem(Temp,Length(ret));
StrCopy(temp,PChar(ret));
Result := temp;
end;
在BCB调用
char out[1000];
int iRet=0;
HMODULE m_hModule;
char* (*_FastReplace)(char*_aSource,char*_aFindString,char*_aReplaceString,bool _CaseSensitive);
m_hModule = ::LoadLibrary(LIB_NAME);
if(m_hModule>0)
{
iRet = 1;
(FARPROC& _FastReplace = ::GetProcAddress(m_hModule,"_FastReplace"
strcpy(out,_FastReplace(aSource,aFindString,aReplaceString,CaseSensitive));
FreeLibrary(m_hModule);
}
return iRet;
结果:
out的内容是正确的,但是iRet明明等于1,但是返回的时候这个值改动了,请问是什么问题。是DLL的问题吗?