C#C
C#12mo ago
elisoli

Named Pipes Connection

Hey everybody! I'm trying to support Windows in a project and I'm trying to connected to the Discord named pipe (an IPC server) that runs on Windows when the Discord client is open.

So far I did this (and a bit more but this is not the point):
var pipe = new NamedPipeClientStream(
    @"\\.\pipe\discord-ipc-0",
    @"discord-ipc-0",
    PipeDirection.InOut,
    PipeOptions.None,
    TokenImpersonationLevel.Impersonation
);

Console.WriteLine("Connecting...");
try { pipe.Connect(); }
catch (Exception e) {
    Console.WriteLine("Not connected");
    return (false, e.Message);
}

Console.WriteLine("Connected");


My issue is first two params of NamedPipeClientStream, I haven't find what I should put there or show it should look, the .Net documentation about this class is not very explanatory. So in this state it catches The specified path is invalid but if I change the first param to @".\pipe" the program gets stuck in pipe.Connect() (but it is still possible to quit with ^C).

If anybody knows how to do this please help :) I'm a Linux femboy, not a windows pro
Was this page helpful?