gpt4 book ai didi

multithreading - CreateNamedPipe ERROR_INVALID_NAME

转载 作者:行者123 更新时间:2023-12-03 22:44:26 29 4
gpt4 key购买 nike

程式码片段:

void RunThread(void* unused_args)
{
PSECURITY_DESCRIPTOR sdsc;
ULONG size;
ConvertStringSecurityDescriptorToSecurityDescriptor("S:(ML;;NW;;;LW)", SDDL_REVISION_1, &sdsc, &size);
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(sa);
sa.bInheritHandle = false;
sa.lpSecurityDescriptor = sdsc;
HANDLE pipe = CreateNamedPipe("\\.\pipe\mmaivpc_test_pipe", PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE, 255, 1024, 1024, 0, &sa);
DWORD error = GetLastError();
}

如果您尚未从函数名称中弄清楚,那么 _beginthread会调用此函数。 GetLastError()返回 ERROR_INVALID_NAME,我不知道为什么。

最佳答案

您需要在用于管道名称的字符串文字中转义反斜杠:

HANDLE pipe = CreateNamedPipe("\\\\.\\pipe\\mmaivpc_test_pipe",
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_BYTE, 255, 1024, 1024, 0, &sa);

关于multithreading - CreateNamedPipe ERROR_INVALID_NAME,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15454578/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com