Home > Software engineering >  Pipeline failure, created in the ocx creatfile return values of 5, access failure. How to solve?
Pipeline failure, created in the ocx creatfile return values of 5, access failure. How to solve?

Time:09-23

Using MFC to do a demo first I create a named pipe is possible, code migration into the ActiveX made ocx is out of the question,
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 win10

CodePudding user response:

You need administrator rights set?

CodePudding user response:

Browser to use? To the administrator to run

CodePudding user response:

reference zhao4zhong1 reply: 3/f
Settings need administrator privileges?


What do you mean ie use administrator privileges to open? Or ocx generated by administrator privileges to run?

CodePudding user response:

reference 4 floor WLDRZX response:
browser with? To the administrator to run


To, call it is loaded in the HTML page with the administrator to run you said is ie with administrators run? Was generated ocx is generated by administrator privileges?

CodePudding user response:

Administrator to run Internet explorer, I recently just made similar, controls cannot generate log, administrators have log, after running IE (WIN10

CodePudding user response:

refer to 7th floor WLDRZX response:
administrator run Internet explorer, I just made similar earlier, controls cannot generate log, administrators have log, after running IE (WIN10

I also am win10, did I use the open Internet explorer can open pipes with administrator privileges, but it's not convenient ah, ie rarely opened by the administrator, go to the path of ie application to open the ie, so is not enough permissions, is it possible to increase by ocx permissions to solve this problem? How to ask right? I before you are not the several of right way,

CodePudding user response:

DACL opened by agent process piping, pipe is set to the low level of integration process can also visit
Refer to
https://blogs.msdn.microsoft.com/ieinternals/2009/11/30/understanding-the-protected-mode-elevation-dialog/
https://stackoverflow.com/questions/18982221/is-there-a-way-to-create-a-named-pipe-from-an-appcontainer-bho-on-ie11
  • Related