You don't have to open the assembly document to open its parts and sub assemblies. You can use ISldWorks::OpenDoc6 or OpenDoc7 method to open all documents if you already know the path of them. In this case you can set the option to open the parts and sub assemblies in read only mode.
If you have to open the final assembly (may be to select parts and sub assemblies from it), then you can use ISldWorks::ActivateDoc3 method rather than ISldWorks::IGetOpenDocumentByName2. Below is the screenshot from the remarks for 'IGetOpenDocumentByName2' method which indicates that if documents are not opened in its own window then this method may not work as expected.
Once you obtain IModelDoc2 object for each part or assembly, you can set the ready only status by using IModelDoc2::SetReadOnly to true. Do whatever you want to do and the close the document by using QuitDoc or CloseDoc.
You can set the option to discard the changes to read only documents as shown below:
You may have to close final assembly document to discard change to parts and sub assemblies you worked on.
Hi Nilesh, thanks for the response.