C
C#4w ago
Eli Soli

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");
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
7 Replies
Sehra
Sehra4w ago
does it connect if you fix the typo of the pipe name?
Eli Soli
Eli SoliOP4w ago
what do you mean by "typo of the pipe name"`
Sehra
Sehra4w ago
iscord -> discord
Eli Soli
Eli SoliOP4w ago
no. Still The specified path is invalid
Eli Soli
Eli SoliOP4w ago
And I am sure this is the pipe's name
No description
Sehra
Sehra4w ago
try with server name "." and pipe name "discord-ipc-0"
Eli Soli
Eli SoliOP4w ago
Wow it works. I think I already tried it before, but now it works :) I didn't know the first param was for server name Thank you

Did you find this page helpful?