def connect_to_pipe(pipe_name):
pipe_handle = windll.kernel32.CreateFileW(<EOL>pipe_name,<EOL>DWORD(GENERIC_READ | GENERIC_WRITE | FILE_WRITE_ATTRIBUTES),<EOL>DWORD(<NUM_LIT:0>),  <EOL>None,  <EOL>DWORD(OPEN_EXISTING),  <EOL>FILE_FLAG_OVERLAPPED,  <EOL>None  <EOL>)<EOL>if pipe_handle == INVALID_HANDLE_VALUE:<EOL><INDENT>raise Exception('<STR_LIT>' % pipe_name)<EOL><DEDENT>dwMode = DWORD(PIPE_READMODE_MESSAGE)<EOL>windll.kernel32.SetNamedPipeHandleState(<EOL>pipe_handle,<EOL>byref(dwMode),<EOL>None,<EOL>None)<EOL>return pipe_handle<EOL>
Connect to a new pipe in message mode.