求教tthread里面使用tstrings的问题,附有代码片段

radarhp radarhp 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区


TMyThread = class(TThread)
private
{ Private declarations }

FList: TStrings;
procedure GetAllData;

protected
procedure Execute; override;

public
constructor Create(CreateSuspended: Boolean);
destructor Destroy; override;
end;

implementation

constructor TMyThread.Create(CreateSuspended: Boolean);
begin
inherited Create(CreateSuspended);
FList:= TStringList.Create;
end;


destructor TMyThread.Destroy;
begin
FList.Free;
inherited;
end;

procedure TMyThread.Execute;
var
...

begin

...

GetAllData;// 后面的procedure

...

end;



procedure TMyThread.GetAllData;
var
...
begin

.....

if FBoxList.Count > 0 then
OutputDebugString( PChar(IntToStr(FBoxList.Count)) );
....

//*************** 到OutputDebugString这里 watch显示 Flist 依然可以访问 *************//
OutputDebugString( PChar('GetAllData') );

//执行了ReadProcessMemory后,FList就是Inaccessible value
if not ReadProcessMemory(PHandle,Pointer(p),@Tmp1,32 ,ReadByte) then
begin
OutputDebugString('GetAllData --- ReadProcessMemory fail');
end;
if Tmp1 = 123 then
begin
FList.add('123'); //********************* access vioate 错误了 ********************//
end

......

end;




前面还判断了FList的count
在delphi的watch里一直查看着这个FList,执行了ReadProcessMemory就开始无法访问了


为什么一ReadProcessMemory其他进程的数据,FList就无法访问了,我加个123的字符串都报错

麻烦大家指点下,谢谢

...全文
评论 4
收藏 已收藏
分享
返回顶部