Hello.

I read that this is done like this: (Excluding various checks for the absence of an instance, etc.)

char *pipename = "\\\\.\\pipe\\namedpipe"; HANDLE hPipe; hPipe = CreateNamedPipe(pipename,PIPE_ACCESS_DUPLEX,PIPE_TYPE_MESSAGE |PIPE_READMODE_MESSAGE |PIPE_WAIT,PIPE_UNLIMITED_INSTANCES,4096,4096,0,NULL); 

And here, in principle, I was expecting a mistake. The first parameter is the name of the channel, which in my function pipename is listed as LPTWSTR, here is the compiler and writes:

 cannot convert parameter 1 from 'const char [22]' to 'LPCWSTR' 

The question of what to do, specify the name directly, not through a variable also fails.

    1 answer 1

    Try

     wchar_t *pipename = L"\\\\.\\pipe\\namedpipe"; 

    If the ANSI versions of the code are still relevant for you, it might be better to write

     TCHAR *pipename = _T("\\\\.\\pipe\\namedpipe"); 

    But in principle, today it is better not to bother with ANSI versions, and write only on Unicode.

    • Thank you) What type of wchar_t? and why L before quotes? - BlackOverlord
    • one
      wchar_t is a 16-bit Unicode character. L at the beginning of a line means that the string is not from ordinary, but from 16-bit characters. - VladD
    • Thank you) ____ - BlackOverlord
    • @BlackOverlord: Please! - VladD