求解决之道

解决方案 »

  1.   

    我写了一个服务程序,之前遇到了网络方面的一个问题: http://community.csdn.net/Expert/topic/4340/4340536.xml?temp=.2091638.原因就是localsystem账户没有获得currentuser的配置信息。现在大概遇到了权限问题,因为不作为服务启动时可以创建目录的。         if (_waccess(strLogDir, 0) == -1)
    { BOOL r = CreateDirectoryEx(szFilename,_T("log"),NULL);
    }
      

  2.   

    服务程序的当前路径是Windows\system32,你是不是把"log"目录创建到这个目录下了?
      

  3.   

    我就把LOG目录创建在服务程序的目录中了,不过好像放在哪里都一样,都创建不出来LOG目录.
      

  4.   

    看是不是CreateDirectoryEx需要的default security descriptor不能得到.
    PS. 你上面先是判断strLogDir是否存在,不存在的话就创建,传递的参数完全不一样。GOOD LUCK
      

  5.   

    加入了Everyone的权限也没有用,创建还是失败                  SECURITY_ATTRIBUTES sa;
    SECURITY_DESCRIPTOR sd;
    BYTE aclBuffer[1024];
    PACL pacl = (PACL)&aclBuffer;
    BYTE sidBuffer[100];
    PSID psid = (PSID) &sidBuffer;
    DWORD sidBufferSize = 100;
    TCHAR domainBuffer[80];
    DWORD domainBufferSize = 80;
    SID_NAME_USE snu;


    InitializeAcl( pacl, 1024, ACL_REVISION );
    LookupAccountName(0, _T("Everyone"), psid, &sidBufferSize, domainBuffer, &domainBufferSize, &snu);
    AddAccessAllowedAce(pacl, ACL_REVISION, GENERIC_ALL, psid);

    //初始化
    InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
    SetSecurityDescriptorDacl(&sd, TRUE, pacl, FALSE);

    sa.nLength = sizeof(SECURITY_ATTRIBUTES);
    sa.bInheritHandle = TRUE;
    sa.lpSecurityDescriptor = &sd; BOOL r = CreateDirectoryEx(szFilename,_T("log0000"),&sa);