How to create read-only network share programmatically?

前端 未结 2 1843
没有蜡笔的小新
没有蜡笔的小新 2021-01-15 04:23

How does one create an administrative network share [1] with read-only permissions from C/C++ or Python under Windows XP?

[1] Necessary in order to access C:\\Progra

相关标签:
2条回答
  • 2021-01-15 05:08

    Take a look at NetShareAdd() for C/C++ (the MSDN includes an example program at the end of the page).

    0 讨论(0)
  • 2021-01-15 05:18

    First create the share with NetShareAdd(). This will share the directory with a null ACL, which is equavalent to allowing everyone full access. It is not possible to configure permissions with NetShareAdd on Windows.

    Once the share has been created, get the security descriptor for the share by calling GetNamedSecurityInfoW() passing in the share name, SE_LMSHARE as the ObjectType, and DACL_SECURITY_INFORMATION as the SecurityInfo. Once you have the descriptor, use the normal Windows security calls to configure the ACL.

    0 讨论(0)
提交回复
热议问题