namespace Vanara.PInvoke;
public static partial class Shell32
{
/// Values that specify the folder being acted on by methods of the ISharingConfigurationManager interface.
///
///
/// In Windows Vista, an Server Message Block (SMB) share is created for both the Users and Public folders. As of
/// Windows 7, the Public share is accessed through the Users share, so only Users is given an SMB share.
///
///
/// When methods are called with the DEFSHAREID_PUBLIC value, the restrictions specified by the SHARE_ROLE value in that call
/// apply to the Everyone access control entry (ACE).
///
///
/// When methods are called with the DEFSHAREID_USERS value, the restrictions specified by the SHARE_ROLE value in that call
/// apply to the Authenticated Users ACE.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-def_share_id typedef enum DEF_SHARE_ID {
// DEFSHAREID_USERS, DEFSHAREID_PUBLIC } ;
[PInvokeData("shobjidl_core.h", MSDNShortId = "NE:shobjidl_core.DEF_SHARE_ID")]
public enum DEF_SHARE_ID
{
/// The Users folder (FOLDERID_UserProfiles). This folder is usually found at C:\Users.
DEFSHAREID_USERS = 1,
/// The Public folder (FOLDERID_Public). This folder is usually found at C:\Users\Public.
DEFSHAREID_PUBLIC,
}
/// Specifies the access permissions assigned to the Users or Public folder. Used in CreateShare and GetSharePermissions.
///
/// ISharingConfigurationManager::CreateShare accepts only SHARE_ROLE_READER and SHARE_ROLE_CO_OWNER. All other values
/// are seen only in the results of ISharingConfigurationManager::GetSharePermissions.
///
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-share_role typedef enum SHARE_ROLE {
// SHARE_ROLE_INVALID, SHARE_ROLE_READER, SHARE_ROLE_CONTRIBUTOR, SHARE_ROLE_CO_OWNER, SHARE_ROLE_OWNER, SHARE_ROLE_CUSTOM,
// SHARE_ROLE_MIXED } ;
[PInvokeData("shobjidl_core.h", MSDNShortId = "NE:shobjidl_core.SHARE_ROLE")]
// public enum SHARE_ROLE{SHARE_ROLE_INVALID, SHARE_ROLE_READER, SHARE_ROLE_CONTRIBUTOR, SHARE_ROLE_CO_OWNER, SHARE_ROLE_OWNER,
// SHARE_ROLE_CUSTOM, SHARE_ROLE_MIXED, }
public enum SHARE_ROLE
{
/// The folder is not shared.
SHARE_ROLE_INVALID = -1,
/// The contents of the folder can be read, but not altered or added to.
SHARE_ROLE_READER,
///
/// The contents of the folder can be read and altered. New items can be added, however items can be deleted only by the user
/// that contributed them.
///
SHARE_ROLE_CONTRIBUTOR,
/// The contents of the folder can be read, changed, or added to.
SHARE_ROLE_CO_OWNER,
/// Not normally used in the context of this interface.
SHARE_ROLE_OWNER,
/// The folder is shared, but the share role is neither SHARE_ROLE_READER, SHARE_ROLE_CONTRIBUTOR, or SHARE_ROLE_CO_OWNER.
SHARE_ROLE_CUSTOM,
/// Not used in the context of this interface.
SHARE_ROLE_MIXED,
}
///
/// Exposes methods that set and retrieve information about a computer's default sharing settings for the Users () or
/// Public () folder. Also exposes a set of methods that allow control of printer sharing.
///
///
/// When to Implement
///
/// An implementation of this interface is included in the CSharingConfiguration class. Third parties do not provide their
/// own implementation.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nn-shobjidl_core-isharingconfigurationmanager
[PInvokeData("shobjidl_core.h", MSDNShortId = "NN:shobjidl_core.ISharingConfigurationManager")]
[ComImport, Guid("B4CD448A-9C86-4466-9201-2E62105B87AE"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), CoClass(typeof(SharingConfigurationManager))]
public interface ISharingConfigurationManager
{
///
/// Shares the Users or Public folder. If the folder is already shared, this method updates its sharing status.
///
///
/// Type: DEF_SHARE_ID
/// One of the DEF_SHARE_ID values that indicates the folder to share or update.
///
///
/// Type: SHARE_ROLE
///
/// One of the following SHARE_ROLE values that sets the access permissions of the share for the Everyone ACE.
/// CreateShare accepts only these values.
///
/// SHARE_ROLE_READER (0)
/// Read-only. The contents of the folder can be read, but not altered or added to.
/// SHARE_ROLE_CO_OWNER (2)
/// Read/Write. The contents of the folder can be read, changed, or added to.
///
///
/// Running this method requires an Administrator privilege level.
///
/// If the folder named in dsid is not shared, this method shares the folder using the permission level provided in the role parameter.
///
///
/// If the folder named in dsid is already shared, this method updates the permissions on the share with the value provided in
/// the role parameter.
///
///
/// Because as of Windows 7 the Public folder is shared through Users rather than directly, creating a share on
/// Public causes an Server Message Block (SMB) share to be created on Users.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-isharingconfigurationmanager-createshare
// HRESULT CreateShare( DEF_SHARE_ID dsid, SHARE_ROLE role );
void CreateShare(DEF_SHARE_ID dsid, SHARE_ROLE role);
/// Removes sharing from either the Users or Public folder.
///
/// Type: DEF_SHARE_ID
/// One of the DEF_SHARE_ID values that specifies the folder to no longer share.
///
/// Running this method requires an Administrator privilege level.
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-isharingconfigurationmanager-deleteshare
// HRESULT DeleteShare( DEF_SHARE_ID dsid );
void DeleteShare(DEF_SHARE_ID dsid);
/// Queries whether the Users or Public folder is shared.
///
/// Type: DEF_SHARE_ID
/// One of the DEF_SHARE_ID values that indicates the folder whose sharing state is being checked.
///
///
/// Type: HRESULT
/// S_OK if the folder is shared; otherwise, S_FALSE.
///
///
/// Because as of Windows 7 Public is shared in-place through Users, callers should always check for the Users
/// share first. If a share is found to exist on Users, then it follows that a share exists on Public as well.
///
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-isharingconfigurationmanager-shareexists
// HRESULT ShareExists( DEF_SHARE_ID dsid );
[PreserveSig]
HRESULT ShareExists(DEF_SHARE_ID dsid);
///
/// Gets the access permissions currently associated with the User or Public folder for the Everyone access
/// control entry (ACE).
///
///
/// Type: DEF_SHARE_ID
/// One of the DEF_SHARE_ID values that specifies the folder.
///
///
/// Type: SHARE_ROLE*
///
/// A pointer to a value that, when this method returns successfully, receives one of the SHARE_ROLE values that indicate the
/// sharing permissions set for the folder specified in the dsid parameter.
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-isharingconfigurationmanager-getsharepermissions
// HRESULT GetSharePermissions( DEF_SHARE_ID dsid, SHARE_ROLE *pRole );
SHARE_ROLE GetSharePermissions(DEF_SHARE_ID dsid);
///
/// Shares all local printers connected to a computer, enabling them to be discovered by other computers on the network.
///
/// Running this method requires an Administrator privilege level.
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-isharingconfigurationmanager-shareprinters
// HRESULT SharePrinters();
void SharePrinters();
/// Stops sharing all local, shared printers connected to a computer.
/// Running this method requires an Administrator privilege level.
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-isharingconfigurationmanager-stopsharingprinters
// HRESULT StopSharingPrinters();
void StopSharingPrinters();
/// Determines whether any printers connected to this computer are shared.
///
/// Type: HRESULT
/// Returns standard HRESULT values, including the following:
///
///
/// Return code
/// Description
///
/// -
/// S_OK
/// Shared printers were detected.
///
/// -
/// S_FALSE
/// No shared printers were found.
///
/// -
/// ERROR_FILE_NOT_FOUND
/// No printers capable of being shared were found.
///
///
///
// https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-isharingconfigurationmanager-areprintersshared
// HRESULT ArePrintersShared();
[PreserveSig]
HRESULT ArePrintersShared();
}
/// CLSID_SharingConfigurationManager
[PInvokeData("shobjidl_core.h", MSDNShortId = "NN:shobjidl_core.ISharingConfigurationManager")]
[ComImport, Guid("49F371E1-8C5C-4d9c-9A3B-54A6827F513C"), ClassInterface(ClassInterfaceType.None)]
public class SharingConfigurationManager { }
}