Click here to Skip to main content
15,910,981 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionUNICODE support suggetions required Pin
krishnakumartm18-Nov-08 19:31
krishnakumartm18-Nov-08 19:31 
AnswerRe: UNICODE support suggetions required Pin
Cedric Moonen18-Nov-08 20:21
Cedric Moonen18-Nov-08 20:21 
AnswerRe: UNICODE support suggetions required Pin
PJ Arends18-Nov-08 21:20
professionalPJ Arends18-Nov-08 21:20 
Questionusing com dll resources in a vc++ application Pin
Taruni18-Nov-08 18:27
Taruni18-Nov-08 18:27 
Questionhow to convert header files in .lib or encrypt them Pin
NitinAP18-Nov-08 18:19
NitinAP18-Nov-08 18:19 
AnswerRe: how to convert header files in .lib or encrypt them Pin
Bram van Kampen19-Nov-08 12:25
Bram van Kampen19-Nov-08 12:25 
QuestionNamed Pipes Pin
Bram van Kampen18-Nov-08 15:42
Bram van Kampen18-Nov-08 15:42 
AnswerRe: Named Pipes Pin
Iain Clarke, Warrior Programmer18-Nov-08 23:15
Iain Clarke, Warrior Programmer18-Nov-08 23:15 
I had to do this a while ago, and here's a snippet of code:

DWORD	CNamedPipeServer::ServerThread ()
{
	// Set up security attributes so anyone can login.
	SECURITY_ATTRIBUTES sa;
	SECURITY_DESCRIPTOR	sd;

	if (!InitializeSecurityDescriptor (&sd, SECURITY_DESCRIPTOR_REVISION))
		return 0; //MSG_PIPE_CREATE_FAILED;
	SetSecurityDescriptorDacl (&sd, TRUE, NULL, FALSE);

	sa.nLength = sizeof (sa);
	sa.bInheritHandle = FALSE;
	sa.lpSecurityDescriptor = &sd;
	BOOL	bLog = FALSE;

	// Create pipe
	char	pipename [512];
	lstrcpy (pipename, "\\\\.\\pipe\\");
	lstrcat (pipename, m_PipeName);

	m_hPipe = ::CreateNamedPipe (pipename,
		PIPE_ACCESS_DUPLEX | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_OVERLAPPED,
		PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT,
		1, 0, 0, 100000, &sa);

	if (m_hPipe == NULL)
	{
		TRACE1("Could not start '%s'\n", pipename);
		return -1;
	}


m_PipeName was the friendly part of the name. I'd use a GUID nowadays, but this was 8-years-ago-Iain. I would also do it unicode too...

To connect, just:
BOOL	CNamedPipe::Open (LPCSTR szName, LPCSTR szMachine)
{
	Close ();

	m_dwError = ERROR_FILE_NOT_FOUND;
	if (szName == NULL)
		return FALSE;

	CString	tmp ("\\\\");
	tmp += (szMachine && lstrlen (szMachine) > 1) ? szMachine : ".";
	tmp += "\\pipe\\";
	tmp += szName;

	m_hPipe = ::CreateFile (tmp, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
	if (m_hPipe == INVALID_HANDLE_VALUE)
	{
		m_dwError = ::GetLastError ();
		return FALSE;
	}


Where szName matches the server name, and szMachine is (oddly enough) the machine address. For initial debugging, maybe try a raw IP address?

My bet is that you'll need the blank security descriptor bit from above.

Iain.
GeneralRe: Named Pipes Pin
Bram van Kampen19-Nov-08 10:43
Bram van Kampen19-Nov-08 10:43 
GeneralRe: Named Pipes Pin
Iain Clarke, Warrior Programmer19-Nov-08 21:41
Iain Clarke, Warrior Programmer19-Nov-08 21:41 
GeneralRe: Named Pipes Pin
Bram van Kampen20-Nov-08 21:17
Bram van Kampen20-Nov-08 21:17 
GeneralRe: Named Pipes Pin
Bram van Kampen11-Dec-08 16:33
Bram van Kampen11-Dec-08 16:33 
QuestionExport data to Outlook Pin
DanYELL18-Nov-08 15:04
DanYELL18-Nov-08 15:04 
AnswerRe: Export data to Outlook Pin
David Crow19-Nov-08 3:34
David Crow19-Nov-08 3:34 
GeneralRe: Export data to Outlook Pin
DanYELL19-Nov-08 9:10
DanYELL19-Nov-08 9:10 
GeneralRe: Export data to Outlook Pin
David Crow19-Nov-08 9:21
David Crow19-Nov-08 9:21 
Question(C++/win32) How to call an external console-mode exe, without showing the console window, and optionally capturing the output? Pin
Petruza18-Nov-08 14:37
Petruza18-Nov-08 14:37 
AnswerRe: (C++/win32) How to call an external console-mode exe, without showing the console window, and optionally capturing the output? Pin
Force Code18-Nov-08 15:55
Force Code18-Nov-08 15:55 
GeneralRe: (C++/win32) How to call an external console-mode exe, without showing the console window, and optionally capturing the output? Pin
Force Code18-Nov-08 16:04
Force Code18-Nov-08 16:04 
QuestionHow can I use CFrameWndEx somewhere else? Pin
lingol18-Nov-08 8:09
lingol18-Nov-08 8:09 
QuestionRe: How can I use CFrameWndEx somewhere else? Pin
led mike18-Nov-08 8:26
led mike18-Nov-08 8:26 
AnswerRe: How can I use CFrameWndEx somewhere else? [modified] Pin
lingol18-Nov-08 13:59
lingol18-Nov-08 13:59 
GeneralRe: How can I use CFrameWndEx somewhere else? Pin
led mike19-Nov-08 4:59
led mike19-Nov-08 4:59 
GeneralRe: How can I use CFrameWndEx somewhere else? Pin
lingol19-Nov-08 7:30
lingol19-Nov-08 7:30 
GeneralRe: How can I use CFrameWndEx somewhere else? Pin
led mike19-Nov-08 8:05
led mike19-Nov-08 8:05 

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.