using System;
using System.Collections.Generic;
using System.Text;using System.Runtime.InteropServices;
using System.Reflection;using System.Security;
using System.Security.Cryptography;
using System.IO;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GetDiskID();
} [DllImport("DiskID32.dll")]
public static extern long DiskID32(ref byte DiskModel, ref byte DiskID); public static string GetDiskID()
{ byte[] DiskModel = new byte[31];
byte[] DiskID = new byte[31];
int i;
string Model = "";
string ID = ""; if (DiskID32(ref DiskModel[0], ref DiskID[0]) != 1)
{ for (i = 0; i < 31; i++)
{ if (Convert.ToChar(DiskID[i]) != Convert.ToChar(0))
{
ID = ID + Convert.ToChar(DiskID[i]);
}
}
ID = ID.Trim();
}
else
{
Console.WriteLine("获取硬盘序列号出错");
}
return ID;
}
}
}运行到 if (DiskID32(ref DiskModel[0], ref DiskID[0]) != 1)
出现错误:无法加载 DLL“DiskID32.dll”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。
using System.Collections.Generic;
using System.Text;using System.Runtime.InteropServices;
using System.Reflection;using System.Security;
using System.Security.Cryptography;
using System.IO;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GetDiskID();
} [DllImport("DiskID32.dll")]
public static extern long DiskID32(ref byte DiskModel, ref byte DiskID); public static string GetDiskID()
{ byte[] DiskModel = new byte[31];
byte[] DiskID = new byte[31];
int i;
string Model = "";
string ID = ""; if (DiskID32(ref DiskModel[0], ref DiskID[0]) != 1)
{ for (i = 0; i < 31; i++)
{ if (Convert.ToChar(DiskID[i]) != Convert.ToChar(0))
{
ID = ID + Convert.ToChar(DiskID[i]);
}
}
ID = ID.Trim();
}
else
{
Console.WriteLine("获取硬盘序列号出错");
}
return ID;
}
}
}运行到 if (DiskID32(ref DiskModel[0], ref DiskID[0]) != 1)
出现错误:无法加载 DLL“DiskID32.dll”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货