Adds a rule that prevents a process from accessing the virtual drive.
int AddDeniedProcess(const char* lpszProcessFileName, int iProcessId, int bChildProcesses, int iDesiredAccess);
INT AddDeniedProcess(LPCWSTR lpszProcessFileName, INT iProcessId, BOOL bChildProcesses, INT iDesiredAccess);
When the ProcessRestrictionsEnabled property is enabled, this method can be used to add an access rule that denies the process specified by ProcessFileName or ProcessId the access right specified by DesiredAccess.
Processes that are already running can be specified by passing their process Id (PID) for the ProcessId parameter (in which case ProcessFileName should be empty). Processes that have not yet started can be specified by passing the full filename of the process's executable file for ProcessFileName (in which case ProcessId should be set to 0). If ProcessName is empty, and ProcessId is -1, the new rule will apply to all processes.
ChildProcesses controls whether the rule also applies to children of the target process.
DesiredAccess specifies the access right to deny; valid values are:
|STG_DACCESS_READ||0x00000001||Grant/deny read access.|
|STG_DACCESS_WRITE||0x00000002||Grant/deny write access.|
|STG_DACCESS_READWRITE||0x00000003||Grant/deny read and write access.|
To remove the process access rule later, pass the same ProcessFileName and ProcessId values to the RemoveDeniedProcess method.
Note: This method can only be called when Active is true, and cannot be called within events.
The methods and properties related to process access lists are not intended to be used from multiple threads at once. Applications that wish to use said methods and properties from multiple threads are responsible for employing proper thread synchronization techniques to ensure that manipulation and enumeration of process access information occurs in a thread-safe manner.
Error Handling (C++)
This method returns a result code; 0 indicates success, while a non-zero error code indicates that this method encountered an error during its execution. If an error occurs, the GetLastError() method can be called to retrieve the associated error message. (Note: This method's result code can also be obtained by calling the GetLastErrorCode() method after it returns.)