Click here to Skip to main content
16,011,460 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CListCtrl problem Pin
Mark Salsbery12-Sep-07 6:28
Mark Salsbery12-Sep-07 6:28 
AnswerRe: CListCtrl problem Pin
Nelek11-Sep-07 23:05
protectorNelek11-Sep-07 23:05 
QuestionUnable to connect to Named Pipe Pin
nagadravid11-Sep-07 1:44
nagadravid11-Sep-07 1:44 
AnswerRe: Unable to connect to Named Pipe Pin
KarstenK11-Sep-07 1:58
mveKarstenK11-Sep-07 1:58 
GeneralRe: Unable to connect to Named Pipe Pin
nagadravid11-Sep-07 4:19
nagadravid11-Sep-07 4:19 
QuestionRe: Unable to connect to Named Pipe Pin
Mark Salsbery11-Sep-07 7:06
Mark Salsbery11-Sep-07 7:06 
AnswerRe: Unable to connect to Named Pipe Pin
nagadravid11-Sep-07 8:56
nagadravid11-Sep-07 8:56 
GeneralRe: Unable to connect to Named Pipe Pin
carrivick11-Sep-07 10:37
carrivick11-Sep-07 10:37 
Hey weird just solved this problem ! with the help of the really cool tool Process Explorer

Mine was to do with passing events but the same problems occur. It is todo with Security descriptors.

My guess is that you are using CreateNamedPipe

HANDLE WINAPI CreateNamedPipe(
LPCTSTR lpName,
DWORD dwOpenMode,
DWORD dwPipeMode,
DWORD nMaxInstances,
DWORD nOutBufferSize,
DWORD nInBufferSize,
DWORD nDefaultTimeOut,
LPSECURITY_ATTRIBUTES lpSecurityAttributes
);
Now my other guess is that your are passing NULL as lpSecurityAttributes. Refering to MSDN

"If lpSecurityAttributes is NULL, the pipe gets a default security descriptor"

You will not that is doesn't say THE default security descriptor. This is because it creates the pipe with the security descriptor for the user that creates it.

This explains your "It works in user mode command-line" but not as a service because the service will be running as SYSTEM.


FIRST SOLUTION

Pass an empty (DACL) security descriptor which has the behaviour of allowing any user/system process to access your pipe.

SECURITY_ATTRIBUTES sa;
SECURITY_DESCRIPTOR* psd=(SECURITY_DESCRIPTOR*)new unsigned char[SECURITY_DESCRIPTOR_MIN_LENGTH];
InitializeSecurityDescriptor(psd,SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(psd, TRUE,(PACL)NULL,FALSE);
sa.nLength = 0;
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = psd;


Now use "sa" in the call to CreateNamedPipe




SECOND MORE SECURE SOLUTION

pass a fully filled out security descriptor, have a look at MSDN for an example.
GeneralRe: Unable to connect to Named Pipe Pin
nagadravid11-Sep-07 19:02
nagadravid11-Sep-07 19:02 
GeneralRe: Unable to connect to Named Pipe Pin
carrivick12-Sep-07 0:49
carrivick12-Sep-07 0:49 
GeneralRe: Unable to connect to Named Pipe Pin
KarstenK11-Sep-07 20:21
mveKarstenK11-Sep-07 20:21 
Question"Please enter a number" - Dialog Pin
RajiRaghu11-Sep-07 1:43
RajiRaghu11-Sep-07 1:43 
AnswerRe: "Please enter a number" - Dialog Pin
Hamid_RT11-Sep-07 1:54
Hamid_RT11-Sep-07 1:54 
GeneralRe: "Please enter a number" - Dialog Pin
RajiRaghu11-Sep-07 2:21
RajiRaghu11-Sep-07 2:21 
AnswerRe: "Please enter a number" - Dialog Pin
Nishad S11-Sep-07 2:12
Nishad S11-Sep-07 2:12 
GeneralRe: "Please enter a number" - Dialog Pin
RajiRaghu11-Sep-07 2:23
RajiRaghu11-Sep-07 2:23 
GeneralRe: "Please enter a number" - Dialog Pin
Nishad S11-Sep-07 2:39
Nishad S11-Sep-07 2:39 
AnswerRe: "Please enter a number" - Dialog Pin
David Crow11-Sep-07 3:01
David Crow11-Sep-07 3:01 
QuestionHow to prevent copying a file Pin
nps_ltv11-Sep-07 0:22
nps_ltv11-Sep-07 0:22 
QuestionRe: How to prevent copying a file Pin
Maximilien11-Sep-07 2:45
Maximilien11-Sep-07 2:45 
AnswerRe: How to prevent copying a file Pin
David Crow11-Sep-07 3:02
David Crow11-Sep-07 3:02 
GeneralRe: How to prevent copying a file Pin
carrivick11-Sep-07 10:40
carrivick11-Sep-07 10:40 
GeneralRe: How to prevent copying a file Pin
nps_ltv12-Sep-07 22:45
nps_ltv12-Sep-07 22:45 
GeneralRe: How to prevent copying a file Pin
carrivick13-Sep-07 11:03
carrivick13-Sep-07 11:03 
QuestionEvent Log Question Pin
Programm3r10-Sep-07 23:30
Programm3r10-Sep-07 23:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.