获取CPU或主板序列号?

5 投票
5 回答
8949 浏览
提问于 2025-04-16 07:16

我想用 CPython 获取 CPU序列号主板序列号,这是为了许可证的需要。这样做可以吗?

我正在使用 Linux 系统。

5 个回答

3

你可以获取到CPUID(处理器的身份识别码)。 也许可以用Linux命令'dmidecode'来帮你。 你可以执行这个命令,或者查看“dmidecode”的源代码。 接下来是执行“dmidecode -t processor”命令后的输出:

>dmidecode -t processor
# dmidecode 2.7
SMBIOS 2.2 present.

Handle 0x0004, DMI type 4, 32 bytes.
Processor Information
        Socket Designation: Socket 478
        Type: Central Processor
        Family: Pentium 4
        Manufacturer: Intel
        ID: 27 0F 00 00 FF FB EB BF
        Signature: Type 0, Family 15, Model 2, Stepping 7
        Flags:
                FPU (Floating-point unit on-chip)
                VME (Virtual mode extension)
                DE (Debugging extension)
                PSE (Page size extension)
                TSC (Time stamp counter)
                MSR (Model specific registers)
                PAE (Physical address extension)
                MCE (Machine check exception)
                CX8 (CMPXCHG8 instruction supported)
                APIC (On-chip APIC hardware supported)
                SEP (Fast system call)
                MTRR (Memory type range registers)
                PGE (Page global enable)
                MCA (Machine check architecture)
                CMOV (Conditional move instruction supported)
                PAT (Page attribute table)
                PSE-36 (36-bit page size extension)
                CLFSH (CLFLUSH instruction supported)
                DS (Debug store)
                ACPI (ACPI supported)
                MMX (MMX technology supported)
                FXSR (Fast floating-point save and restore)
                SSE (Streaming SIMD extensions)
                SSE2 (Streaming SIMD extensions 2)
                SS (Self-snoop)
                HTT (Hyper-threading technology)
                TM (Thermal monitor supported)
                PBE (Pending break enabled)
        Version: Intel(R) Pentium(R) 4 CPU
        Voltage: 1.5 V
        External Clock: 133 MHz
        Max Speed: 3066 MHz
        Current Speed: 2800 MHz
        Status: Populated, Enabled
        Upgrade: ZIF Socket
        L1 Cache Handle: 0x0008
        L2 Cache Handle: 0x0009
        L3 Cache Handle: No L3 Cache
7

在Linux系统下,你可以使用命令“lshw -quiet -xml”,然后解析它的输出结果。通过这个命令,你可以找到很多系统信息,比如处理器的ID、主板的ID等等,信息非常丰富。

4

你需要使用CPUID指令。

CPUID

大多数C语言编译器都支持内联汇编,但你需要知道自己在做什么。

撰写回答