0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

cscの作法 その573

Last updated at Posted at 2025-03-12

概要

cscの作法、調べてみた。
練習問題やってみた。

練習問題

C# で USBドライブのシリアルナンバーを判定せよ。

サンプルコード

using System;
using System.Management;

namespace Test
{
	class Program {
		private static void ShowDevices() {
			var mos = new ManagementObjectSearcher("Select * from Win32_DiskDrive where InterfaceType='USB'");
			foreach (var mo in mos.Get())
			{
				var pin = mo["SerialNumber"].ToString();
				Console.WriteLine(pin);
				if (pin == "25C21150000600C1")
				{
					Console.WriteLine("1");
				}
				else
				{
					Console.WriteLine("0");
				}
			}
		}
		static void Main(string[] args) {
			ShowDevices();
		}
	}
}

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?