컴퓨터 UUID 얻어오기.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. wmic csproduct get UUID
  2. using System;
  3. using System.Management;
  4. class Program
  5. {
  6. static void Main()
  7. {
  8. // WMI를 사용하여 컴퓨터의 고유 식별자 가져오기
  9. ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystemProduct");
  10. foreach (ManagementObject obj in searcher.Get())
  11. {
  12. string uniqueId = obj["UUID"].ToString();
  13. Console.WriteLine($"유일한 식별자 (UUID): {uniqueId}");
  14. }
  15. }
  16. }
  17. import java.io.BufferedReader;
  18. import java.io.IOException;
  19. import java.io.InputStreamReader;
  20. public class UniqueIdentifierExample {
  21. public static void main(String[] args) {
  22. try {
  23. Process process = Runtime.getRuntime().exec("wmic csproduct get UUID");
  24. BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
  25. String line;
  26. while ((line = reader.readLine()) != null) {
  27. if (!line.trim().isEmpty()) {
  28. System.out.println("유일한 식별자 (UUID): " + line.trim());
  29. }
  30. }
  31. } catch (IOException e) {
  32. e.printStackTrace();
  33. }
  34. }
  35. }
  36. #include <iostream>
  37. #include <windows.h>
  38. #include <intrin.h>
  39. #include <iphlpapi.h>
  40. // CPU의 시리얼 번호를 얻는 함수
  41. void getCPUSerialNumber(std::string& serialNumber)
  42. {
  43. int cpuInfo[4] = { 0 };
  44. __cpuid(cpuInfo, 1);
  45. serialNumber = std::to_string(cpuInfo[3]) + std::to_string(cpuInfo[0]);
  46. }
  47. // MAC 주소를 얻는 함수
  48. void getMACAddress(std::string& macAddress)
  49. {
  50. IP_ADAPTER_INFO adapterInfo[32];
  51. DWORD bufferSize = sizeof(adapterInfo);
  52. DWORD status = GetAdaptersInfo(adapterInfo, &bufferSize);
  53. if (status == ERROR_SUCCESS)
  54. {
  55. macAddress = adapterInfo[0].Address;
  56. }
  57. }
  58. int main()
  59. {
  60. std::string cpuSerialNumber;
  61. getCPUSerialNumber(cpuSerialNumber);
  62. std::cout << "CPU 시리얼 번호: " << cpuSerialNumber << std::endl;
  63. std::string macAddress;
  64. getMACAddress(macAddress);
  65. std::cout << "MAC 주소: " << macAddress << std::endl;
  66. return 0;
  67. }
  68. #include <vcl.h>
  69. #pragma hdrstop
  70. #include <tchar.h>
  71. #include <System.SysUtils.hpp>
  72. #include <System.Classes.hpp>
  73. #include <Vcl.Forms.hpp>
  74. #include <Vcl.Dialogs.hpp>
  75. #pragma argsused
  76. int _tmain(int argc, _TCHAR* argv[])
  77. {
  78. try
  79. {
  80. // WMI를 사용하여 컴퓨터의 고유 식별자 가져오기
  81. TVarRec args[1];
  82. args[0] = Variant(L"UUID");
  83. Variant result = ExecCmdProcess(L"wmic", L"csproduct get %s", args, 1);
  84. ShowMessage(L"유일한 식별자 (UUID): " + result);
  85. }
  86. catch (Exception &exception)
  87. {
  88. Application->ShowException(&exception);
  89. }
  90. return 0;
  91. }
  92. #include <vcl.h>
  93. #include <iostream>
  94. #include <string>
  95. #pragma hdrstop
  96. // 윈도우 컴퓨터의 고유 식별자를 가져오는 함수
  97. std::string getComputerUUID()
  98. {
  99. TGUID guid;
  100. guid = System::Sysutils::CreateGUID();
  101. std::wstring uuid = System::Sysutils::GUIDToString(guid).c_bstr();
  102. return std::string(uuid.begin(), uuid.end());
  103. }
  104. int main()
  105. {
  106. try
  107. {
  108. std::string uuid = getComputerUUID();
  109. std::cout << "유일한 식별자 (UUID): " << uuid << std::endl;
  110. }
  111. catch (Exception &exception)
  112. {
  113. Application->ShowException(&exception);
  114. }
  115. return 0;
  116. }
  117. ManagementObjectSearcher theSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE InterfaceType='USB'");
  118. foreach (ManagementObject currentObject in theSearcher.Get())
  119. {
  120. ManagementObject theSerialNumberObjectQuery = new ManagementObject("Win32_PhysicalMedia.Tag='" + currentObject["DeviceID"] + "'");
  121. MessageBox.Show(theSerialNumberObjectQuery["SerialNumber"].ToString());
  122. }