PDA

View Full Version : کد سریال نامبرهای قطعات خاص هر سیستم



man_iran
چهارشنبه 09 مرداد 1387, 10:12 صبح
سلام
اول اگه می شه بگید چه سریال نامبرهایی هستند که توی یک سیستم جا دارند و متعلق فقط به آن سیستم هستند؟ (فکر کنم سریال نامبر سیپیو، هارد و چند تای دیگه) البته اگر اشتباه نکنم!

حالا کدهای خوندن این سریال نامبرها توی سی شارپ چیه؟
مرسی

Xcalivorse
چهارشنبه 09 مرداد 1387, 10:25 صبح
با سلام. دوست عزیز شما میتونید با جستجو در سایت یا مراجعه به تاپیک 1001 نکته در #C خیلی زود جوابتون رو بگیرید. لینک زیر جواب سؤالتونه و در تاپیک 1001 نکته در #C هستش.
http://barnamenevis.org/forum/showpost.php?p=472611

man_iran
چهارشنبه 09 مرداد 1387, 11:59 صبح
با سلام. دوست عزیز شما میتونید با جستجو در سایت یا مراجعه به تاپیک 1001 نکته در #C خیلی زود جوابتون رو بگیرید. لینک زیر جواب سؤالتونه و در تاپیک 1001 نکته در #C هستش.
http://barnamenevis.org/forum/showpost.php?p=472611

من این قسمت را دیده بودم.
ولی این فقط مشخصات سی پیو است. من دیگر مشخصات را هم می خواستم.
ضمنا پرسیده بودم که کدام مشخصات، مشخصات خاص یک سیستم است؟ یعنی توی سیستم های دیگه فرق می کنه

SalarSoft
چهارشنبه 09 مرداد 1387, 13:04 عصر
سایر مخصات با استفاده از WMI

مشخصات ProcessorId ، Product ، Manufacturer ، Signature ، VideoController و غیره رو می تونی خودت به صورت تابع دربیاری

using System;
using System.Collections.Generic;
using System.Text;
using System.Management;

namespace System
{
static class SystemInfo
{
#region -> Private Variables

public static bool UseProcessorID;
public static bool UseBaseBoardProduct;
public static bool UseBaseBoardManufacturer;
public static bool UseDiskDriveSignature;
public static bool UseVideoControllerCaption;
public static bool UsePhysicalMediaSerialNumber;
public static bool UseBiosVersion;
public static bool UseBiosManufacturer;
public static bool UseWindowsSerialNumber;

#endregion

public static string GetSystemInfo(string SoftwareName)
{
if (UseProcessorID == true)
SoftwareName += RunQuery("Processor", "ProcessorId");

if (UseBaseBoardProduct == true)
SoftwareName += RunQuery("BaseBoard", "Product");

if (UseBaseBoardManufacturer == true)
SoftwareName += RunQuery("BaseBoard", "Manufacturer");

if (UseDiskDriveSignature == true)
SoftwareName += RunQuery("DiskDrive", "Signature");

if (UseVideoControllerCaption == true)
SoftwareName += RunQuery("VideoController", "Caption");

if (UsePhysicalMediaSerialNumber == true)
SoftwareName += RunQuery("PhysicalMedia", "SerialNumber");

if (UseBiosVersion == true)
SoftwareName += RunQuery("BIOS", "Version");

if (UseWindowsSerialNumber == true)
SoftwareName += RunQuery("OperatingSystem", "SerialNumber");

SoftwareName = RemoveUseLess(SoftwareName);

if (SoftwareName.Length < 25)
return GetSystemInfo(SoftwareName);

return SoftwareName.Substring(0, 25).ToUpper();
}

private static string RemoveUseLess(string st)
{
char ch;
for (int i = st.Length - 1; i >= 0; i--)
{
ch = char.ToUpper(st[i]);

if ((ch < 'A' || ch > 'Z') &&
(ch < '0' || ch > '9'))
{
st = st.Remove(i, 1);
}
}
return st;
}

private static string RunQuery(string TableName, string MethodName)
{
ManagementObjectSearcher MOS = new ManagementObjectSearcher("Select * from Win32_" + TableName);
foreach (ManagementObject MO in MOS.Get())
{
try
{
return MO[MethodName].ToString();
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.Message);
}
}
return "";
}
}
}

man_iran
چهارشنبه 09 مرداد 1387, 13:43 عصر
سایر مخصات با استفاده از WMI

مشخصات ProcessorId ، Product ، Manufacturer ، Signature ، VideoController و غیره رو می تونی خودت به صورت تابع دربیاری


مرسی
ولی کدام ها کدهای خاص هستند؟ یعنی توی هر سیستم ثابت هستند و توی سیستم های دیگه حتما فرق می کنند.
همشون!؟

sa_ostad
چهارشنبه 09 مرداد 1387, 14:15 عصر
اینم کد هر قطعه ای که میخوای :



/// <summary>
/// method to retrieve the selected HDD's serial number
/// </summary>
/// <param name="strDriveLetter">Drive letter to retrieve serial number for</param>
/// <returns>the HDD's serial number</returns>
public string GetHDDSerialNumber(string drive)
{
//check to see if the user provided a drive letter
//if not default it to "C"
if (drive == "" || drive == null)
{
drive = "C";
}
//create our ManagementObject, passing it the drive letter to the
//DevideID using WQL
ManagementObject disk = new ManagementObject("Win32_LogicalDisk.DeviceID=\"" + drive + ":\"");
//bind our management object
disk.Get();
//return the serial number
return disk["VolumeSerialNumber"].ToString();
}

--------------------------------------------------------
/// method to retrieve the HDD's freespace
/// </summary>
/// <param name="drive">Drive letter to get free space from (optional)</param>
/// <returns>The free space of the selected HDD</returns>
public double GetHDDFreeSpace(string drive)
{
//check to see if the user provided a drive letter
//if not default it to "C"
if (drive == "" || drive == null)
{
drive = "C";
}
//create our ManagementObject, passing it the drive letter to the
//DevideID using WQL
ManagementObject disk = new ManagementObject("Win32_LogicalDisk.DeviceID=\"" + drive + ":\"");
//bind our management object
disk.Get();
//return the free space amount
return Convert.ToDouble(disk["FreeSpace"]);
}

---------------------------------------------------------------

/// <summary>
/// method to retrieve the HDD's size
/// </summary>
/// <param name="drive">Drive letter to get free space from (optional)</param>
/// <returns>The free space of the selected HDD</returns>
public double getHDDSize(string drive)
{
//check to see if the user provided a drive letter
//if not default it to "C"
if (drive == "" || drive == null)
{
drive = "C";
}
//create our ManagementObject, passing it the drive letter to the
//DevideID using WQL
ManagementObject disk = new ManagementObject("Win32_LogicalDisk.DeviceID=\"" + drive + ":\"");
//bind our management object
disk.Get();
//return the HDD's initial size
return Convert.ToDouble(disk["Size"]);
}

---------------------------------

/// <summary>
/// Returns MAC Address from first Network Card in Computer
/// </summary>
/// <returns>MAC Address in string format</returns>
public string FindMACAddress()
{
//create out management class object using the
//Win32_NetworkAdapterConfiguration class to get the attributes
//of the network adapter
ManagementClass mgmt = new ManagementClass("Win32_NetworkAdapterConfiguration");
//create our ManagementObjectCollection to get the attributes with
ManagementObjectCollection objCol = mgmt.GetInstances();
string address = String.Empty;
//loop through all the objects we find
foreach (ManagementObject obj in objCol)
{
if (address == String.Empty) // only return MAC Address from first card
{
//grab the value from the first network adapter we find
//you can change the string to an array and get all
//network adapters found as well
//check to see if the adapter's IPEnabled
//equals true
if ((bool)obj["IPEnabled"] == true)
{
address = obj["MacAddress"].ToString();
}
}
//dispose of our object
obj.Dispose();
}
//replace the ":" with an empty space, this could also
//be removed if you wish
address = address.Replace(":", "");
//return the mac address
return address;
}

--------------------------------------------------------------

/// <summary>
/// method to retrieve the network adapters
/// default IP gateway using WMI
/// </summary>
/// <returns>adapters default IP gateway</returns>
public string GetDefaultIPGateway()
{
//create out management class object using the
//Win32_NetworkAdapterConfiguration class to get the attributes
//of the network adapter
ManagementClass mgmt = new ManagementClass("Win32_NetworkAdapterConfiguration");
//create our ManagementObjectCollection to get the attributes with
ManagementObjectCollection objCol = mgmt.GetInstances();
string gateway = String.Empty;
//loop through all the objects we find
foreach (ManagementObject obj in objCol)
{
if (gateway == String.Empty) // only return MAC Address from first card
{
//grab the value from the first network adapter we find
//you can change the string to an array and get all
//network adapters found as well
//check to see if the adapter's IPEnabled
//equals true
if ((bool)obj["IPEnabled"] == true)
{
gateway = obj["DefaultIPGateway"].ToString();
}
}
//dispose of our object
obj.Dispose();
}
//replace the ":" with an empty space, this could also
//be removed if you wish
gateway = gateway.Replace(":", "");
//return the mac address
return gateway;
}

------------------------------------------------------

/// <summary>
/// Return processorId from first CPU in machine
/// </summary>
/// <returns>[string] ProcessorId</returns>
public string GetCPUId()
{
string cpuInfo = String.Empty;
//create an instance of the Managemnet class with the
//Win32_Processor class
ManagementClass mgmt = new ManagementClass("Win32_Processor");
//create a ManagementObjectCollection to loop through
ManagementObjectCollection objCol = mgmt.GetInstances();
//start our loop for all processors found
foreach(ManagementObject obj in objCol)
{
if(cpuInfo == String.Empty)
{
// only return cpuInfo from first CPU
cpuInfo = obj.Properties["ProcessorId"].Value.ToString();
}
}
return cpuInfo;
}

-------------------------------------------------

/// <summary>
/// method for retrieving the CPU Manufacturer
/// using the WMI class
/// </summary>
/// <returns>CPU Manufacturer</returns>
public string GetCPUManufacturer()
{
string cpuMan = String.Empty;
//create an instance of the Managemnet class with the
//Win32_Processor class
ManagementClass mgmt = new ManagementClass("Win32_Processor");
//create a ManagementObjectCollection to loop through
ManagementObjectCollection objCol = mgmt.GetInstances();
//start our loop for all processors found
foreach (ManagementObject obj in objCol)
{
if (cpuMan == String.Empty)
{
// only return manufacturer from first CPU
cpuMan = obj.Properties["Manufacturer"].Value.ToString();
}
}
return cpuMan;
}

-----------------------------------------------

/// <summary>
/// method to retrieve the CPU's current
/// clock speed using the WMI class
/// </summary>
/// <returns>Clock speed</returns>
public int GetCPUCurrentClockSpeed()
{
int cpuClockSpeed = 0;
//create an instance of the Managemnet class with the
//Win32_Processor class
ManagementClass mgmt = new ManagementClass("Win32_Processor");
//create a ManagementObjectCollection to loop through
ManagementObjectCollection objCol = mgmt.GetInstances();
//start our loop for all processors found
foreach (ManagementObject obj in objCol)
{
if (cpuClockSpeed == 0)
{
// only return cpuStatus from first CPU
cpuClockSpeed = Convert.ToInt32(obj.Properties["CurrentClockSpeed"].Value.ToString());
}
}
//return the status
return cpuClockSpeed;
}

-----------------------------------------

man_iran
چهارشنبه 09 مرداد 1387, 14:21 عصر
مرسی ولی :گریه::عصبانی++:
کدام از شماره سریال ها، شماره خاص هستند؟

sa_ostad
چهارشنبه 09 مرداد 1387, 14:27 عصر
تمام سریال ها شماره خاص هستند

Esmail Solhkhah
یک شنبه 17 آذر 1387, 01:28 صبح
دوستان جسارتا بغیر از WMI راه دیگه ای هم برای CPUID هست ؟ البته با سی شارپ