delphi – 从Windows服务到客户端应用程序的命名管道

我的故事是,我正在设计一个必须与 Windows服务通信的新应用程序.经过多次研究,我得出结论,命名管道是推荐的方法( How do I send a string from one instance of my Delphi program to another?),但是,由于安全问题,似乎我无法使用Win7中的SendMessage或命名管道…消息从未到达服务之外应用程序.

我正在使用Russell Libby的名为Pipe的组件,它们在正常的桌面应用程序之间没有任何关系,但Windows服务似乎是在解决方案中投掷扳手.进一步的研究告诉我,有可能开放双方的安全性让他们进行沟通,但是我的知识水平在最低限度上是最低限度的,而且我无法做出可能的API调用的头部或尾部.

基于Delphi组件pipes.pas,需要做什么来打开这个宝宝,以便双方可以开始说话?我确定以下两个函数来自pipes.pas文件识别安全属性,是否有人能帮助我在这里

谢谢!

procedure InitializeSecurity(var SA: TSecurityAttributes);
var
  sd: PSecurityDescriptor;
begin

  // Allocate memory for the security descriptor
  sd := Allocmem(Security_DESCRIPTOR_MIN_LENGTH);

  // Initialize the new security descriptor
  if InitializeSecurityDescriptor(sd,Security_DESCRIPTOR_REVISION) then
  begin
    // Add a NULL descriptor ACL to the security descriptor
    if SetSecurityDescriptorDacl(sd,True,nil,False) then
    begin
      // Set up the security attributes structure
      SA.nLength := SizeOf(TSecurityAttributes);
      SA.lpSecurityDescriptor := sd;
      SA.bInheritHandle := True;
    end
    else
      // Failed to init the sec descriptor
      RaiseWindowsError;
  end
  else
    // Failed to init the sec descriptor
    RaiseWindowsError;

end;

procedure FinalizeSecurity(var SA: TSecurityAttributes);
begin

  // Release memory that was assigned to security descriptor
  if Assigned(SA.lpSecurityDescriptor) then
  begin
    // Reource protection
    try
      // Free memory
      FreeMem(SA.lpSecurityDescriptor);
    finally
      // Clear pointer
      SA.lpSecurityDescriptor := nil;
    end;
  end;

end;

解决方法

相关文章

 从网上看到《Delphi API HOOK完全说明》这篇文章,基本上都...
  从网上看到《Delphi API HOOK完全说明》这篇文章,基本上...
ffmpeg 是一套强大的开源的多媒体库 一般都是用 c/c+&#x...
32位CPU所含有的寄存器有:4个数据寄存器(EAX、EBX、ECX和ED...
1 mov dst, src dst是目的操作数,src是源操作数,指令实现的...