delphi - How to sent text string to service? -
i have desktop application , service. how can send string desktop application service , handle in service?
i don't want use sockets because may blocked windows firewall.
if don't want use network transport simplest way cross-session ipc use named pipe. main thing take care on need supply security attributes when creating named pipe. without doing won't succeed in cross-session communications. code looks this:
var sa: tsecurityattributes; .... sa.nlength := sizeof(sa); sa.binherithandle := true; convertstringsecuritydescriptortosecuritydescriptor( 'd:(a;oici;grgw;;;au)',//discretionary acl allow read/write access authenticated users sddl_revision_1, sa.lpsecuritydescriptor, nil ); fpipe := createnamedpipe( '\\.\pipe\mypipename', pipe_access_duplex, pipe_type_message or pipe_readmode_message or pipe_wait, pipe_unlimited_instances, 0,//don't care buffer sizes, let system decide 0,//don't care buffer sizes, let system decide 100,//timout (ms), used clients, needs cover time between disconnectnamedpipe , connectnamedpipe @sa ); localfree(hlocal(sa.lpsecuritydescriptor)); if fpipe=error_invalid_handle begin ;//deal error end;
Comments
Post a Comment