protect application & hardware serial number

Posted on 2009-02-22
Last Modified: 2012-05-06

i have developed an application in c# - .net 2.0 and i have two questions:
       * to protect my application i am using disk serial number (not volume number, since it changes after format) and create a key using this value. is there any security problems in this approch? (like rewriting disk serial number by crackers etc...) in fact i need a unique value to generate key, it may be mac id, cpu id, disk id etc... which one is more secure?

      *(main question) i am using this code but it works only win xp, not 2000 and 2000 server etc... how can i get this value in other platforms.
         it give this error: System.Management.ManagementException: Invalid class

thanks in advence...

                  searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");

                  int i = 0;
                  foreach(ManagementObject wmi_HD in searcher.Get()) {

                        // get the hard drive from collection
                        // using index
                        HardDrive hd = (HardDrive)hdCollection[i];

                        // get the hardware serial no.
                if (wmi_HD["SerialNumber"] == null) {

                    hd.SerialNo = "None";
                else {

                    hd.SerialNo = wmi_HD["SerialNumber"].ToString();
                    serialNo = hd.SerialNo;
Question by:komputer
    LVL 16

    Expert Comment

    I'm no software developer but it strikes me that whatever you come up with, it will be no big deal for a cracker to disable whatever antipiracy checks you put in your software, irrespective of the complexity of the ID you're generating.

    The Windows SDK shows that the Win32_PhysicalMedia class requires Windows XP or newer - that is why you are getting an error on Windows 2000.
    LVL 16

    Accepted Solution

    Does this help you get that serial without using the WMI Class?
    LVL 26

    Expert Comment

    by:Anurag Thakur
    in my suggestion make a id comprising of mac address, disk id and cpu id and dont save them in sequence
    and either in the beginning or at the end save what is the sequence that you have used..... at least in that case it will be difficult for the hackers to crack the codes
    LVL 69

    Expert Comment

    by:Éric Moreau
    you could use the MotherBoard ID and/or the Processor ID as shown at
    LVL 12

    Expert Comment


    Apply this one:

    Get the real HD serial number, not the volume serial number.

    Frankly, I've hack some software that's using volume serial number for protection, but never been hack a real HD serial number.


    Author Comment

    thank guys, cantoris solution works fine.
    i am creating my native exe via xenocode. it works fine on my local but when i moved to any machine which .net framework is not installed, it gives this error although the dll in the same folde
     System.Runtime.InteropServices.COMException (0x800736B1)

    i tried to register
    >regsvr32 DriveInfoEx.dll
    it gives this error;
    DriveInfoEx.dll was loaded, but the DllRegisterServer entry point was not found.

    do i need to open a new question?
    LVL 16

    Expert Comment

    That page I pointed you to does say "it's mandatory to use .net 2.0".
    Maybe that's the problem?

    Author Comment

    i think i am using .net 2.0 by creating native code (i suppose xenocode moves all need .net2.0 files into native exe since 500 kb file increases up to 20 mb)
    LVL 16

    Expert Comment

    I can't help you there - I'm not a developer.  Maybe you need to ask a fresh question to find someone who knows about xenocode since this is a different subject to before.  Otherwise you end up with two complete questions asked and potentially two sets of solutions in one thread!
    I'm not all that versed with the netiquette of this site either yet to know for sure - perhaps someone else will chip in on this?

    Author Closing Comment


    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    How to install USMT 11 30
    Xamarin 10 20
    dispose of a DataTable created in another class 4 14
    The Using statement in C# 5 19
    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
    Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now