本文整理自网络,侵删。
//搜索内存偏移函数
//来源C++代码,翻译的
//Code By htrlq
//参数说明
//第一个参数:
//要搜索的内存地址
//第二个参数:
//搜索的字符串
//第三个参数:
//内存大小
//第四个参数:
//搜索的字符串长度
function MemFindStr(strMem,strSub:PChar;iSizeMem,isizeSub:LongWord):Integer;
var
da,i,j:Integer;
tmp,tmp2:Char;
begin
Result:=0;
if isizeSub = 0 then
da:=lstrlen(strSub)
else
da:=isizeSub-1;
for i:=0 to iSizeMem-1 do
begin
for j:=0 to da do
begin
tmp2:=strSub[j];
tmp:=strMem[i+j];
if tmp <> tmp2 then
Break;
if j = da then
begin
Result:=i;
Exit;
end;
end;
end;
end;
相关阅读 >>
Delphi if语法,弹出提示框,不等于写法,判断是否为空
Delphi屏蔽win、ctrl_esc、alt_tab、alt_f4等键(windows xp、windows 2003 server下测试通过)
Delphi 怎么将一个流转换成字符串?或者将字符串转出一个流
Delphi 判断时间是否是下午 dateutils.ispm
更多相关阅读请进入《Delphi》频道 >>