delphi - 共享内存 - 访问冲突
问题描述
请告诉我,我想将 json 写入共享内存。如果文本超过 2047 个字符,则 StrPCopy 错误“0x004074ba 处的访问冲突:地址条目 0x00381000”。我没有找到有关限制的信息。也许还有另一种写json的方法?
var
SecurityAttr: TSecurityAttributes;
SecurityDescr: TSecurityDescriptor;
begin
InitializeSecurityDescriptor(@SecurityDescr,SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(@SecurityDescr,True,nil,False);
SecurityAttr.nLength:=SizeOf(TSecurityAttributes);
SecurityAttr.lpSecurityDescriptor:=@SecurityDescr;
SecurityAttr.bInheritHandle:=True;
SendMMF := CreateFileMapping($FFFFFFFF, @SecurityAttr, PAGE_READWRITE, 0, 32,PChar('Global\Test'));
if (SendMMF = 0) then
Exit;
SendData := MapViewOfFile(SendMMF, FILE_MAP_WRITE, 0, 0, 0);
if SendData = nil then
Exit;
StrPCopy(SendData, GetJson);
if Assigned(SendData) then
Exit;
if SendMMF.Size > 0 then
Exit;
UnmapViewOfFile(SendData);
SendData := nil;
CloseHandle(SendMMF);
end;
解决方案
推荐阅读
- ios - 在删除帐户之前发出“你确定吗”警报
- android - 如何隐式更新 Android Firebase 中的节点
- julia - 在 Gadfly 中处理统计数据
- sql-server - 在步骤“设置值”上将参数从 SQL Server 代理作业传递到 SSIS 包
- python-3.x - python中的NoSuchElementException xPath错误
- haskell - 结合 Haskell 代码的片段以获得更大的图景
- python - Python:在文本文件和标题中添加序列号
- google-apps-script - 尝试从共享工作表运行函数时出现 next() 函数错误
- null - event.target.getAttribute("name") 有时为空?
- android - 收到后台通知时不显示直接回复(推送通知)