var
  ResourceLocation: HRSRC;
  ResourceSize: LongWord;
  ResourceHandle: THandle;
  ResourcePointer: Pointer;
----------------------------
  ResourceLocation := FindResource(HInstance, 'TXTFILE', RT_RCDATA);
  if ResourceLocation <> 0 then
  begin
    ResourceSize := SizeofResource(HInstance, ResourceLocation);
    if ResourceSize <> 0 then
    begin
      ResourceHandle := LoadResource(HInstance, ResourceLocation);
      if ResourceHandle <> 0 then
      begin
        ResourcePointer := LockResource(ResourceHandle);
        if ResourcePointer <> nil then
        begin
          我想在这里对ResourcePointer指向的里面长度为ResourceSize的内容加密
          请问我该如何做?
          能直接对ResourcePointer的内容进行操作嘛?
        end;
      end;
    end;
  end;

解决方案 »

  1.   

    指针中的内容应该是用^获得吧
    ResourcePointer^即ResourcePointer指针所指的内容
      

  2.   

    再定义一个指针数组:
    type
     TByteArray=array[0..0] of Byte;
     PByteArray=^TByteArray;然后将ResourcePointer的类型由Pointer改为PByteArray,这样就能直接这样访问数据了:ResourcePointer[xxx]
      

  3.   

    非常简单因为你取的地址是Resource段,而此段是只读段。当然无法写。想写的话,
    用VirtualProtect改段保护属性。所以,楼上的,统统拖出去打PP