Is checked the creatfile fails, the return value is 5.
The following is a code, experienced friend to help me see,
ActiveXCtrl. CPP
HANDLE hPipe;
LPTSTR lpszPipename=_T (" \ \ \ \. \ \ pipe \ \ MyPipe ");
While (1)
{
HPipe=CreateFile (
LpszPipename,//pipe name
GENERIC_READ | GENERIC_WRITE,//the read and write access
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,//no sharing
NULL,//the default security attributes
OPEN_EXISTING,//opens existing pipe
0,//the default attributes
NULL);//no template file
//to see the error return value
LPVOID lpMsgBuf;
FormatMessage (
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError (),
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) & amp; LpMsgBuf,
0,
NULL
);
//the return value
Cstrings ii;
Ii. The Format (_T (" % d "), GetLastError ());
AfxMessageBox (ii);
//return code
MessageBox (LPCTSTR lpMsgBuf);
LocalFree (lpMsgBuf);
If (hPipe!=INVALID_HANDLE_VALUE)
break;
//the Exit if an error other than ERROR_PIPE_BUSY occurs.
If (GetLastError ()!=ERROR_PIPE_BUSY)
{
if (! WaitNamedPipe (lpszPipename, 20000))
{
//printf (" Could not open pipe ");
//system (" pause ");
StrResult=_T (" data pipeline crowded open failure ");
Return strResult;
}
}
}
//The pipe connected; Change to the message - the read mode.
DwMode=PIPE_READMODE_MESSAGE;
FSuccess=SetNamedPipeHandleState (
HPipe,//pipe handle
& DwMode,//the new pipe mode
NULL,//don 't set maximum bytes
NULL);//don 't set maximum time
if (! FSuccess)
{
//printf (" SetNamedPipeHandleState failed ");
//system (" pause ");
StrResult=_T (" data parameter transmission failure ");
Return strResult;
}
CodePudding user response:
Compile environment is vs2010 win10CodePudding user response:
You need administrator rights set?CodePudding user response:
Browser to use? To the administrator to runCodePudding user response: