现在我做了一个插件,主要采用管道的方式来与本地的一个service进行通信,但是在win7上面,打开UAC之后,是用createFile来创建管道的写入句柄的时候出现问题,GetLastError看了一下返回的是5,权限不足,关闭UAC之后就正常了。
在VS里面设置了requireAdministrator也不行(Windows8.1上面测试 打开UAC也没问题)有问题的代码如下:_hWritePipe = CreateFile( 
CommonFunc::s2ws(serverName).c_str(),                 
GENERIC_WRITE,
FILE_SHARE_WRITE,             
NULL,                        
OPEN_EXISTING,               
FILE_ATTRIBUTE_NORMAL,
NULL                     
);请问各位有什么解决办法吗

解决方案 »

  1.   

    When an application creates a file across a network, it is better to use GENERIC_READ | GENERIC_WRITE for dwDesiredAccess than to use GENERIC_WRITE alone. The resulting code is faster, because the redirector can use the cache manager and send fewer SMBs with more data. This combination also avoids an issue where writing to a file across a network can occasionally return ERROR_ACCESS_DENIED.好像是建议你搭配使用 GENERIC_READ | GENERIC_WRITE 
      

  2.   

    创建命名管道的时候用一个security descptor指明允许某个桌面用户访问