Microsoft provides the source code of vshadow to manipulate VSS (Volume Shadow Service [shadow copy]), and I've modified it a bit but I want to make it into a dll so I can use it in my C# projects. I don't know exactly how to go about doing that, the source code is fairly simple, and it shouldn't be too hard, but I don't really know where to get started. How should I go about converting it to a usable dll instead of compiling to a executable?
Microsoft提供vshadow的源代码来操作VSS(卷影服务[卷影复制]),我对它进行了一些修改,但我想把它变成一个dll,所以我可以在我的C#项目中使用它。我不知道该怎么做,源代码相当简单,它应该不会太难,但我真的不知道从哪里开始。我应该如何将其转换为可用的dll而不是编译为可执行文件?
Update: Someone has already done this: http://www.alphaleonis.com/2008/08/alphavss-bringing-windows-shadow-copy-service-vss-to-net/
更新:有人已经这样做了:http://www.alphaleonis.com/2008/08/alphavss-bringing-windows-shadow-copy-service-vss-to-net/
2 个解决方案
#1
You will need to change your project settings in Visual Studio to create a DLL. In addition you will need to define dll entry points.
您需要在Visual Studio中更改项目设置以创建DLL。此外,您还需要定义dll入口点。
However, the VSS is a set of COM API's, so you can call them directly from C# with pinvoke, instead of using this wrapper C++ executable.
但是,VSS是一组COM API,因此您可以使用pinvoke直接从C#调用它们,而不是使用此包装器C ++可执行文件。
Since the SDK only contains libs, not DLL's you'll have to create a dll project to use it.
由于SDK只包含libs而不是DLL,因此您必须创建一个dll项目才能使用它。
This is a good blog-how-to.
这是一篇很好的博客文章。
You'll need to download the VSS SDK (if you haven't already).
您需要下载VSS SDK(如果您还没有)。
关于pinvoke的体面文章。
Hope this helps.
希望这可以帮助。
#2
Such a task can range from trivial to extremely complex. In your case, the issue probably leans towards the complex end.
这样的任务可以从微不足道到极其复杂。在您的情况下,问题可能倾向于复杂的结束。
The reason for this is because you need to replace the existing interface with a new set of functions that you can use. These functions will then need to be exported, so you can import them in dotNet.
原因是您需要使用一组可以使用的新函数替换现有接口。然后需要导出这些函数,以便您可以在dotNet中导入它们。
#1
You will need to change your project settings in Visual Studio to create a DLL. In addition you will need to define dll entry points.
您需要在Visual Studio中更改项目设置以创建DLL。此外,您还需要定义dll入口点。
However, the VSS is a set of COM API's, so you can call them directly from C# with pinvoke, instead of using this wrapper C++ executable.
但是,VSS是一组COM API,因此您可以使用pinvoke直接从C#调用它们,而不是使用此包装器C ++可执行文件。
Since the SDK only contains libs, not DLL's you'll have to create a dll project to use it.
由于SDK只包含libs而不是DLL,因此您必须创建一个dll项目才能使用它。
This is a good blog-how-to.
这是一篇很好的博客文章。
You'll need to download the VSS SDK (if you haven't already).
您需要下载VSS SDK(如果您还没有)。
关于pinvoke的体面文章。
Hope this helps.
希望这可以帮助。
#2
Such a task can range from trivial to extremely complex. In your case, the issue probably leans towards the complex end.
这样的任务可以从微不足道到极其复杂。在您的情况下,问题可能倾向于复杂的结束。
The reason for this is because you need to replace the existing interface with a new set of functions that you can use. These functions will then need to be exported, so you can import them in dotNet.
原因是您需要使用一组可以使用的新函数替换现有接口。然后需要导出这些函数,以便您可以在dotNet中导入它们。