Hi,
sorry for asking this kind of Question, but asking it on other communities like codeproject and similar places did not lead to a solution, not even a single answer that could be of help.
A week ago, i asked a question about RegSaveKeyEx and got very good answers on the issue that lead to a very quick solution. After some coding (at that moment the RegSaveKeyEx problem was already solved) i came to Volume Sahdow Copy Service and experimented a little on it, mostly with its client applications. But the funny thing was that a few days later i had to find a way to copy a locked file that is held by a process (i dont have source access to the process) implementing a proprietary database. I was asked to write some code periodically backing up the file. At first i thought i could open that file for read access and copy its content in a simple and fast way, but the process holds exclusive nonsharing lock on the database file, so i had to find another way to solve this. Then i decided to use Volume Shadow Copy and this worked very well on Vista and Windows 7. One of my colleagues told me that it also runs on Windows 8. Since i am mostly coding in C# and try to avoid C and C++ as often as i can (its really painless to crosscompile for different platforms if you fully stay on .NET classes and/or “well marshalled” pinvokes), i wrote a service application in C#. To access Volume Shadowy Copy i had to port the IVSBackupComponents Interface and all VSS API exports to C# and all the structs. All worked fine and i was able to snapshot the volume holding the file, creating a temporary snapshot, copy, the file and delete the snapshot. I did that all first on my Windows 7 development system and then i moved to Vista and with slight modifications (mainly memory allocation and pointer stuff) it then also worked perfectly on Vista. Now i had to target Windows XP, because we still have lots of XP clients running the process. There it was: The Interface did not work on Windows XP! At first i thought it was some implementation detail and the interface layout had to be changed and i had to use another interface to be able to use the service. After looking at the header files for the VSS SDK it was clear that the layout of the interface was slightly different for xp, so i wrote another Interface implementation for the XP system, but then i faced another problem. The XP class has no GUID for the interface, but i need a valid GUID to access the Interface on the Backup functions from my C# code. Another thing was, that the exports from vssapi.dll differ in some way. Vista,7/8 do have a “CreateVssBackupComponentsInternal” export and XP has a “?CreateVssBackupComponents@@YGJPAPAVIVssBackupComponents@@@Z” which at first should not be a big thing to call. But the problem is, that the XP variant expects a Interface with a unknown guid. The original VSS SDK headers for xp do not have a uuid attribute for the class, but do inherit from IUnknown and calling the XP function with the Vista Interface implementation returns E_NOTIMPLEMENTED and the CLR Runtime tells me that a QueryInterface on the Interface faild and the calllee returned that it does not implement that interface. So i need a valid guid on the interface implementation to be able to pass it to the XP export,…but WHAT is the guid of that IVSSBackupComponents interface for XP???
This is what it is looking for Vista+:
class __declspec(uuid(“665c1d5f-c218-414d-a05d-7fef5f9d5c86”)) IVssBackupComponents : public IUnknown
{
public:
This is what it looks for XP:
class IVssBackupComponents : public IUnknown
{
public:
The XP class looks like a ordinary C++ class to me, deriving from IUnknown. If this is the case, then it would be clear why the call fails, but why does the XP export return me a E_NOINTERFACE and the CLR runtime tells me that i use a wrong interface and that the guid is not valid for some reason. Do i miss something here and how can i solve this? I dont want to write a pinvoke dll exporting the interface from C/C++ in a C# friendly way to my service. It would be best to be able to access all from one service with no external component. Here is the VSS SDK located:
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=23490
Any help would be great,…
TIA
K.