我的故事是,我正在设计一个必须与
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;
解决方法
原文地址:https://www.jb51.cc/delphi/101400.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。