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

前端之家收集整理的这篇文章主要介绍了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文件识别安全属性,是否有人能帮助我在这里?

谢谢!

@H_301_8@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.f2er.com/delphi/101400.html

猜你在找的Delphi相关文章