惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
H
Help Net Security
F
Fortinet All Blogs
MyScale Blog
MyScale Blog
宝玉的分享
宝玉的分享
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 司徒正美
量子位
N
Netflix TechBlog - Medium
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
Recorded Future
Recorded Future
博客园 - 三生石上(FineUI控件)
Vercel News
Vercel News
aimingoo的专栏
aimingoo的专栏
I
InfoQ
Microsoft Security Blog
Microsoft Security Blog
Scott Helme
Scott Helme
The Last Watchdog
The Last Watchdog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
IT之家
IT之家
AI
AI
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Google Online Security Blog
Google Online Security Blog
U
Unit 42
V2EX - 技术
V2EX - 技术
MongoDB | Blog
MongoDB | Blog
Schneier on Security
Schneier on Security
博客园 - Franky
H
Heimdal Security Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Jina AI
Jina AI
W
WeLiveSecurity
P
Privacy & Cybersecurity Law Blog
Cloudbric
Cloudbric
B
Blog RSS Feed
N
News | PayPal Newsroom
S
Securelist
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
I
Intezer
Hacker News - Newest:
Hacker News - Newest: "LLM"
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
博客园_首页
罗磊的独立博客
H
Hackread – Cybersecurity News, Data Breaches, AI and More
雷峰网
雷峰网

博客园 - 李帅斌-Memory

快速导出CSV log4net使用详解 . C# 格式化字符串 web.config中特殊字符的转译 transactionscope的使用 一些概念需要明确的解释一下 还原已清空的回收站 安装卸载Windows服务 Jquery 文章积累 Spring.NET学习——控制反转(基础篇) SqlServer2005导出数据到SqlServer2000步骤! - 李帅斌-Memory - 博客园 MSSQL2005:SQL Server 2005安装图解 网站优化-Gzip压缩 Asp.Net读取excel文件的时候 出错提示:外部表不是预期的格式 解决方案 js触发回车事件 - 李帅斌-Memory - 博客园 在Div中包含的元素移动时,触发div的onmouseout事件.解决方案! - 李帅斌-Memory - 博客园 VisualStudio用IE8调试时遇到的问题 JQuery+Ajax实现无刷新数据查询 Asp.net页面执行两遍Page_Load的解决方案
C#取硬盘序列号(-备忘-)
李帅斌-Memory · 2009-02-21 · via 博客园 - 李帅斌-Memory

using System;

using System.IO;

using System.Runtime.InteropServices;

using System.Text;

using Microsoft.Win32;

/// <summary> 
/// HardDiskVal 的摘要说明。 
/// 读取指定盘符的硬盘序列号 
/// 功能:读取指定盘符的硬盘序列号 
/// </summary> 
public class HardDiskVal
{
    [DllImport(
"kernel32.dll")]
    
private static extern int GetVolumeInformation(string lpRootPathName,string lpVolumeNameBuffer,int nVolumeNameSize,ref int lpVolumeSerialNumber,int lpMaximumComponentLength,int lpFileSystemFlags,string lpFileSystemNameBuffer,int nFileSystemNameSize

    );

/// <summary> /// 获得盘符为drvID的硬盘序列号,缺省为C /// </summary> /// <param name="drvID"></param> /// <returns></returns> 

    
public string HDVal(string drvID)
    {
const int MAX_FILENAME_LEN = 256;int retVal = 0;int a = 0;int b = 0;string str1 = null;string str2 = null;int i = GetVolumeInformation(

        drvID 

+ @":\",

        str1,

        MAX_FILENAME_LEN,

ref retVal,

        a,

        b,

        str2,

        MAX_FILENAME_LEN

        );

return retVal.ToString();

    }

public string HDVal()
    {
const int MAX_FILENAME_LEN = 256;int retVal = 0;int a = 0;int b = 0;string str1 = null;string str2 = null;int i = GetVolumeInformation("c:\\",

        str1,

        MAX_FILENAME_LEN,

ref retVal,

        a,

        b,

        str2,

        MAX_FILENAME_LEN

        );

return retVal.ToString();

    }

}