473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Shadow Copy Wrapper?

CMM
I've been scouring the net for the last few days looking for a way to copy a
locked file (create a shadow volume, expose it... that's it) from within my
program. I'm aware of the kludgy vshadow.exe commandline tool, but what I
really need is to be able to do it in managed code or via API's. I'm also
aware of the VSS SDK so I don't need a pointer to them.... just wondering if
anyone has had experience with this.

Nov 14 '07 #1
9 2407
Hello CMM,

if u aware about VSS SDK, u should noted that there is a sample of using it

did u check how that sample meets your needs?

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
CI've been scouring the net for the last few days looking for a way to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>
Nov 14 '07 #2
"CMM" <cm*@nospam.comwrote in message
news:19**********************************@microsof t.com...
I've been scouring the net for the last few days looking for a way to copy
a locked file (create a shadow volume, expose it... that's it) from within
my program. I'm aware of the kludgy vshadow.exe commandline tool, but what
I really need is to be able to do it in managed code or via API's. I'm
also aware of the VSS SDK so I don't need a pointer to them.... just
wondering if anyone has had experience with this.

The VSS API's are a set of COM and C++ interfaces, none of them are directly
accessible from C#, so you'll have to write a wrapper in C++/CLI to be able
to access them from pure managed code.
Note however that using VSS only because you need to copy a locked file is
overkill, you can achieve the same functionality by using PInvoke to call
some Win32 API's.

First you need to open the file using Win32 "CreateFile" API with:
dwDesiredACcess = 0
dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE
and dwFlagsAndAttributes = FILE_FLAG_BACKUP_SEMANTICS set.
The file handle returned can be used to call the "Kernel32" Backup API's
like "BackupRead", "BackupSeek" etc....
Note that this all requires the right privileges (SeBackupPrivilege) for the
caller!

Willy.

Nov 14 '07 #3
CMM
I was under the impression that the samples are C++ and not exactly portable
to the managed world. It's a shame too... because VShadow.exe... with a
little effort on the VSS team could probably be retooled into a useful
class.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microsoft .com...
Hello CMM,

if u aware about VSS SDK, u should noted that there is a sample of using
it

did u check how that sample meets your needs?

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

CI've been scouring the net for the last few days looking for a way to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>
Nov 14 '07 #4
The VSS team is not owning the SDK and it's samples, nor do they care about
managed code, the API is exposed through COM and C++ interfaces just like
the VSS Service. Writing a managed wrapper in C++/CLI isn't that hard
anyway. Note that as I said in another reply, you don't need VSS for this at
all.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:8E**********************************@microsof t.com...
>I was under the impression that the samples are C++ and not exactly
portable to the managed world. It's a shame too... because VShadow.exe...
with a little effort on the VSS team could probably be retooled into a
useful class.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microsoft .com...
>Hello CMM,

if u aware about VSS SDK, u should noted that there is a sample of using
it

did u check how that sample meets your needs?

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and
we miss it, but that it is too low and we reach it" (c) Michelangelo

CI've been scouring the net for the last few days looking for a way to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>

Nov 14 '07 #5
CMM
I don't need VSS at all? So BackupRead will alert the file's owner to flush
the file like VSS does? What if the actual copying is being done by code
other than mine? Ideally, I want to create the snapshot, pass the exposed
volume to the component to handle the rest, etc. Anyway, I was looking for a
simple solution. Looks like calling vshadow.exe and scripting it will end up
being the way to go. Shame.

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
The VSS team is not owning the SDK and it's samples, nor do they care
about managed code, the API is exposed through COM and C++ interfaces just
like the VSS Service. Writing a managed wrapper in C++/CLI isn't that hard
anyway. Note that as I said in another reply, you don't need VSS for this
at all.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:8E**********************************@microsof t.com...
>>I was under the impression that the samples are C++ and not exactly
portable to the managed world. It's a shame too... because VShadow.exe...
with a little effort on the VSS team could probably be retooled into a
useful class.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microsof t.com...
>>Hello CMM,

if u aware about VSS SDK, u should noted that there is a sample of using
it

did u check how that sample meets your needs?

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and
we miss it, but that it is too low and we reach it" (c) Michelangelo

CI've been scouring the net for the last few days looking for a way to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>

Nov 14 '07 #6
"CMM" <cm*@nospam.comwrote in message
news:80**********************************@microsof t.com...
>I don't need VSS at all? So BackupRead will alert the file's owner to flush
the file like VSS does? What if the actual copying is being done by code
other than mine? Ideally, I want to create the snapshot, pass the exposed
volume to the component to handle the rest, etc. Anyway, I was looking for
a simple solution. Looks like calling vshadow.exe and scripting it will end
up being the way to go. Shame.

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
>The VSS team is not owning the SDK and it's samples, nor do they care
about managed code, the API is exposed through COM and C++ interfaces
just like the VSS Service. Writing a managed wrapper in C++/CLI isn't
that hard anyway. Note that as I said in another reply, you don't need
VSS for this at all.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:8E**********************************@microso ft.com...
>>>I was under the impression that the samples are C++ and not exactly
portable to the managed world. It's a shame too... because VShadow.exe...
with a little effort on the VSS team could probably be retooled into a
useful class.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microso ft.com...
Hello CMM,

if u aware about VSS SDK, u should noted that there is a sample of
using it

did u check how that sample meets your needs?

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and
we miss it, but that it is too low and we reach it" (c) Michelangelo

CI've been scouring the net for the last few days looking for a way
to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>



Nov 14 '07 #7
VSS can't alert the owning program unless this one implements the VSWriter
interfaces. That means that the application needs to be modified for this.
When the application does not implement VSWriter, the File System will
simply be "alerted" to flush the FS buffers, but this is no guaranteed to be
free of incomplete I/Writer operations and data corruption, the shadow image
is said to be in a "Crash-Consistent state". If you need application
recovery state, you have to implement a writer in the application owning the
file(s).

Willy.
"CMM" <cm*@nospam.comwrote in message
news:80**********************************@microsof t.com...
>I don't need VSS at all? So BackupRead will alert the file's owner to flush
the file like VSS does? What if the actual copying is being done by code
other than mine? Ideally, I want to create the snapshot, pass the exposed
volume to the component to handle the rest, etc. Anyway, I was looking for
a simple solution. Looks like calling vshadow.exe and scripting it will end
up being the way to go. Shame.

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
>The VSS team is not owning the SDK and it's samples, nor do they care
about managed code, the API is exposed through COM and C++ interfaces
just like the VSS Service. Writing a managed wrapper in C++/CLI isn't
that hard anyway. Note that as I said in another reply, you don't need
VSS for this at all.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:8E**********************************@microso ft.com...
>>>I was under the impression that the samples are C++ and not exactly
portable to the managed world. It's a shame too... because VShadow.exe...
with a little effort on the VSS team could probably be retooled into a
useful class.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.microso ft.com...
Hello CMM,

if u aware about VSS SDK, u should noted that there is a sample of
using it

did u check how that sample meets your needs?

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and
we miss it, but that it is too low and we reach it" (c) Michelangelo

CI've been scouring the net for the last few days looking for a way
to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>



Nov 14 '07 #8
CMM
Yes, I'm aware of that. The question remains: there is no way, no working
examples, and no experience with using C# or VB.NET to create and expose a
shadow snapshot of a volume, right?

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:eM*************@TK2MSFTNGP06.phx.gbl...
VSS can't alert the owning program unless this one implements the VSWriter
interfaces. That means that the application needs to be modified for this.
When the application does not implement VSWriter, the File System will
simply be "alerted" to flush the FS buffers, but this is no guaranteed to
be free of incomplete I/Writer operations and data corruption, the shadow
image is said to be in a "Crash-Consistent state". If you need application
recovery state, you have to implement a writer in the application owning
the file(s).

Willy.
"CMM" <cm*@nospam.comwrote in message
news:80**********************************@microsof t.com...
>>I don't need VSS at all? So BackupRead will alert the file's owner to
flush the file like VSS does? What if the actual copying is being done by
code other than mine? Ideally, I want to create the snapshot, pass the
exposed volume to the component to handle the rest, etc. Anyway, I was
looking for a simple solution. Looks like calling vshadow.exe and
scripting it will end up being the way to go. Shame.

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
>>The VSS team is not owning the SDK and it's samples, nor do they care
about managed code, the API is exposed through COM and C++ interfaces
just like the VSS Service. Writing a managed wrapper in C++/CLI isn't
that hard anyway. Note that as I said in another reply, you don't need
VSS for this at all.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:8E**********************************@micros oft.com...
I was under the impression that the samples are C++ and not exactly
portable to the managed world. It's a shame too... because
VShadow.exe... with a little effort on the VSS team could probably be
retooled into a useful class.
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.micros oft.com...
Hello CMM,
>
if u aware about VSS SDK, u should noted that there is a sample of
using it
>
did u check how that sample meets your needs?
>
---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high
and we miss it, but that it is too low and we reach it" (c)
Michelangelo
>
CI've been scouring the net for the last few days looking for a way
to
Ccopy a locked file (create a shadow volume, expose it... that's it)
Cfrom within my program. I'm aware of the kludgy vshadow.exe
Ccommandline tool, but what I really need is to be able to do it in
Cmanaged code or via API's. I'm also aware of the VSS SDK so I don't
Cneed a pointer to them.... just wondering if anyone has had
Cexperience with this.
C>
>

Nov 14 '07 #9
That's right because like I have said, the VSS interfaces are not directly
usable from "pure" managed code, you have to write a wrapper in C++/CLI
(mixed managed unmanaged code) for this.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:90**********************************@microsof t.com...
Yes, I'm aware of that. The question remains: there is no way, no working
examples, and no experience with using C# or VB.NET to create and expose a
shadow snapshot of a volume, right?
"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:eM*************@TK2MSFTNGP06.phx.gbl...
>VSS can't alert the owning program unless this one implements the
VSWriter interfaces. That means that the application needs to be modified
for this. When the application does not implement VSWriter, the File
System will simply be "alerted" to flush the FS buffers, but this is no
guaranteed to be free of incomplete I/Writer operations and data
corruption, the shadow image is said to be in a "Crash-Consistent state".
If you need application recovery state, you have to implement a writer in
the application owning the file(s).

Willy.
"CMM" <cm*@nospam.comwrote in message
news:80**********************************@microso ft.com...
>>>I don't need VSS at all? So BackupRead will alert the file's owner to
flush the file like VSS does? What if the actual copying is being done by
code other than mine? Ideally, I want to create the snapshot, pass the
exposed volume to the component to handle the rest, etc. Anyway, I was
looking for a simple solution. Looks like calling vshadow.exe and
scripting it will end up being the way to go. Shame.

"Willy Denoyette [MVP]" <wi*************@telenet.bewrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
The VSS team is not owning the SDK and it's samples, nor do they care
about managed code, the API is exposed through COM and C++ interfaces
just like the VSS Service. Writing a managed wrapper in C++/CLI isn't
that hard anyway. Note that as I said in another reply, you don't need
VSS for this at all.

Willy.

"CMM" <cm*@nospam.comwrote in message
news:8E**********************************@micro soft.com...
>I was under the impression that the samples are C++ and not exactly
>portable to the managed world. It's a shame too... because
>VShadow.exe... with a little effort on the VSS team could probably be
>retooled into a useful class.
>
>
"Michael Nemtsev [MVP]" <ne*****@msn.comwrote in message
news:3d**************************@msnews.micro soft.com...
>Hello CMM,
>>
>if u aware about VSS SDK, u should noted that there is a sample of
>using it
>>
>did u check how that sample meets your needs?
>>
>---
>WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
>http://spaces.live.com/laflour
>"The greatest danger for most of us is not that our aim is too high
>and we miss it, but that it is too low and we reach it" (c)
>Michelangelo
>>
>CI've been scouring the net for the last few days looking for a way
>to
>Ccopy a locked file (create a shadow volume, expose it... that's
>it)
>Cfrom within my program. I'm aware of the kludgy vshadow.exe
>Ccommandline tool, but what I really need is to be able to do it in
>Cmanaged code or via API's. I'm also aware of the VSS SDK so I
>don't
>Cneed a pointer to them.... just wondering if anyone has had
>Cexperience with this.
>C>
>>
>


Nov 14 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Nik Thomas | last post by:
I'm beginning to redesign my site to move away from table-based layouts, and to incorporate a decent amount of cross-browser reliability, graceful degradation and standards compliance. I have...
3
by: surajitkhan | last post by:
Hi Can anyone tell me how to make a drop shadow for a table or td through css. I dont want to use any image. I want it done through background color. Thanks Surajit
4
by: Barry Kelly | last post by:
I'm designing an application framework which will, amongst other things, live in an assembly hosted in the ASP.NET worker process, servicing webservice requests. Here's the scenario: APPFX is...
0
by: Damien Anselmi | last post by:
I am using the CompileAssemblyFromSource method of an ICodeCompiler instance to dynamically compile an assembly used by a Web Application. The assembly may be recompiled any number of times during...
1
by: supriya | last post by:
Hi, I found vshadow sdk in MSDN.I am unable to use the shadow copy for backup and restore because it is creating only non persistent shadow copy in winxp.How can i create persistent shadow copy...
2
by: Diffident | last post by:
Hello All, I just finished reading an interesting article by Scott about App Domains: http://odetocode.com/Articles/305.aspx Scott, I have a question about the section "Shadow Copies and...
0
by: Patrick F | last post by:
I keep getting this error message and i don't know whats the problem is and how to solve it. I have a webproject with 2 components (dll) added to it. One is called PhotoGallery and one is called...
1
by: Patrick F | last post by:
I keep getting this error message and i don't know whats the problem is and how to solve it. I have a webproject with 2 components (dll) added to it. One is called PhotoGallery and one is called...
9
by: CMM | last post by:
I've been scouring the net for the last few days looking for a way to copy a locked file (create a shadow volume, expose it... that's it) from within my program. I'm aware of the kludgy vshadow.exe...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.