C#验证程序是否有strong name (P/Invoke)

c#
2015-08-20 0 604
C#验证程序是否有strong name (P/Invoke)

比如在程序中,为了验证程序集是否有签名,可调用如下方法

[DllImport("mscoree.dll", CharSet=CharSet.Unicode)]
static extern bool StrongNameSignatureVerificationEx(string wszFilePath, bool fForceVerification, ref bool pfWasVerified);

bool notForced = false;
bool verified = StrongNameSignatureVerificationEx(assembly, false, ref notForced);
Console.WriteLine("Verified: {0}\nForced: {1}", verified, !notForced);

这个功能常用在软件保护方法,可用来验证签名的组件。即使你的签名被人去掉,或是所有程序集的签名都被去除,只要程序中有这一项调用代码,则可以停止程序运行。

遇见资源网 c# C#验证程序是否有strong name (P/Invoke) http://www.ox520.com/12950.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务