我用NetShareAdd但是不能設置文件夾為只讀共享方式,SHARE_INFO_2 的參數已經設為
ACCESS_READ.那位大蝦指點指點.

解决方案 »

  1.   

    #define UNICODE
    #include <windows.h>
    #include <stdio.h>
    #include <lm.h>void wmain( int argc, TCHAR *argv[ ])
    {
       NET_API_STATUS res;
       SHARE_INFO_2 p;
       DWORD parm_err = 0;   if(argc<2)
          printf("Usage: NetShareAdd server\n");
       else
       {
          //
          // Fill in the SHARE_INFO_2 structure.
          //
          p.shi2_netname = TEXT("TESTSHARE");    
          p.shi2_type = STYPE_DISKTREE; // disk drive
          p.shi2_re = TEXT("TESTSHARE to test NetShareAdd");
          p.shi2_permissions = 0;    
          p.shi2_max_uses = 4;
          p.shi2_current_uses = 0;    
          p.shi2_path = TEXT("C:\\");
          p.shi2_passwd = NULL; // no password
          //
          // Call the NetShareAdd function,
          //  specifying level 2.
          //
          res=NetShareAdd(argv[1], 2, (LPBYTE) &p, &parm_err);
          //
          // If the call succeeds, inform the user.
          //
          if(res==0)
             printf("Share created.\n");
          
          // Otherwise, print an error,
          //  and identify the parameter in error.
          //
          else
             printf("Error: %u\tparmerr=%u\n", res, parm_err);
       }
       return;
    }