Link to home
Start Free TrialLog in
Avatar of thordk
thordk

asked on

Named Pipes in Windows Service ?!

Can anybody show me how to do a named pipe server / client in a windows service ? i have a pipeserver in an app running on XPSP2 and Win2K / 2003 that works fine as an application, but as soon as i encapsulate it in a service the client dont seem to be able to write to it anymore ??

Really hope someone can help, its urgent. Thanks
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thordk
thordk

ASKER

Hi jkr !

Thanks for answering - i havent used the SD at all in my applications, but then i read somewhere that it was important if they were running as a service (can you confirm that ?). What i tried to put into as a service was:

SECURITY_ATTRIBUTES sa;
SECURITY_DESCRIPTOR sd;

InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd,TRUE,NULL,FALSE);
SetSecurityDescriptorGroup(&sd,NULL, FALSE );
SetSecurityDescriptorSacl(&sd, FALSE, NULL, FALSE );

sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.lpSecurityDescriptor = &sd;
sa.bInheritHandle = TRUE;
PipeHandle = CreateNamedPipe(PipeUNCname, PIPE_ACCESS_INBOUND, PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE, PIPE_UNLIMITED_INSTANCES, 0, 0, PIPE_BUFSIZE, &sa ));

- But do i have to something both on serverside and clientside ? some of the clients will run as services too.
Yes, you should try that for both ends of the pipe.
Avatar of thordk

ASKER

Okay just to get it right; ill use the exact same SD in both end right ? i will try to make a test and return back to you, thanks alot.
Avatar of thordk

ASKER

That appeared to have solved my problem ! thanks alot.