带有冒号/scope的c#dll导入入口点

本文关键字:c#dll 导入 入口 scope | 更新日期: 2023-09-27 18:00:20

正在查找从vssapi.dll、导入dll

看看GetSnapshotDeviceName函数,DLL导出查看器给了我:

protected: long __cdecl CVssWriter::GetSnapshotDeviceName(unsigned short const * __ptr64,unsigned short const * __ptr64 * __ptr64)const __ptr64
protected: long __cdecl CVssJetWriter::GetSnapshotDeviceName(unsigned short const * __ptr64,unsigned short const * __ptr64 * __ptr64)const __ptr64

假设我想要第一个,我如何声明dll导入,例如:

[DllImport("vssapi.dll", EntryPoint = "CVssWriter::GetSnapshotDeviceName", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]
private static extern uint GetSnapshotDeviceName(string wszOriginalVolume, out string ppwszSnapshotDevice);

[有没有ExactSpelling]总是给我

找不到名为的入口点DLL"vssapi.DLL "中的"CVssWriter::GetSnapshotDeviceName"

错误。冒号的变化(删除等)和名称的颠倒(作为装饰版本)也没有给我带来任何乐趣。

我知道它可以使用修饰名称或序数,但我希望代码具有合理的可移植性(decls依赖于编译器,我从未见过任何东西表明序数在更新中也会保持不变)。

是的,我已经知道这个dll不会移植到Vista之前。。。我可以和他一起生活
也听说过AlphaVSS,但我需要的是使用航空母舰在湖上钓鱼(-他们真的需要让它使用起来如此笨拙吗?)

带有冒号/scope的c#dll导入入口点

这些是C++实例方法,即成员函数。因此,不能使用p/invoke导入它们。您尝试使用的VSS的此API可用作C++类或通过COM.

如果您需要的功能可以通过COM接口获得,那么这将是您进行操作的最简单方法。否则,您将需要以某种方式包装C++类。当然,最简单的方法是使用混合模式的C++/CLI程序集。

不管怎样,p/invoke在这里都帮不了你。