Click here to Skip to main content
Licence 
First Posted 26 Dec 2001
Views 168,265
Bookmarked 35 times

Checking the serial Number of a CD

By | 26 Dec 2001 | Article
This program pops up a message box if the installation CD is not in the CD Drive by checking the serial number of the CD.

Introduction

This program checks the serial number of a CD-ROM and refuses to work if the installation CD is not in the CD Drive. This program assumes that at the Time of installation the serial number of the installation CD is stored at the registry location HKEY_LOCAL_MACHINE\Software\CDsoft\Cds. We can achieve this by adding the below code to our installation program.

GetVolumeInformation(drive,
                     vol,
                     sizeof(vol),
                     &sno,
                     &mf,
                     &sf,
                     NULL,NULL);
RegCreateKeyEx (HKEY_LOCAL_MACHINE, "Software\\CDsoft", 0, 
                NULL,REG_OPTION_NON_VOLATILE, KEY_CREATE_SUB_KEY | KEY_ALL_ACCESS, 
                NULL, &childkey, &dispos) ;
RegSetValueEx ( childkey, "Cds", 0, REG_DWORD, ( const BYTE* )(LPDWORD) &sno, size) ;
RegCloseKey ( childkey );

In the OnInitDialog function ,we read the serial number of installation CD from registry by using the code below. And we also start a timer.

    HKEY hkeyresult ;
    DWORD size=sizeof(DWORD) ;
    DWORD type;
    BYTE  sno[100];
    
    RegOpenKey ( HKEY_LOCAL_MACHINE, ( LPCTSTR ) "Software\\CDsoft", &hkeyresult );
    RegQueryValueEx ( hkeyresult, ( LPCTSTR )"Cds" , 0,&type, sno,&size);
    RegCloseKey ( hkeyresult );
    serialnoCD=*(DWORD *)sno;

    SetTimer(NULL,1000,NULL);

In this program OnTimer calls the function check every second. If the CD is not present in the Drive, this function displays a MessageBox. The function for checking the serial number of a CD-ROM is given below...

void CCDcheckDlg::Check() 
{
    char dbits[100],drive[100];
    int i=0;
    
    DWORD d=GetLogicalDriveStrings(100, dbits);
    strncpy(drive,dbits+i,4);
    
    for (int nDrives = 0; nDrives < 26; nDrives ++)
    {
        if(GetDriveType(drive)==DRIVE_CDROM)
            break;    
        i+=4;
        strncpy(drive,dbits+i,4);
    }

    char vol[40];        
    DWORD mf;            
    DWORD sf,sno;    
    GetVolumeInformation(drive,
                         vol,
                         sizeof(vol),
                         &sno,
                         &mf,
                         &sf,
                         NULL,NULL);

    int ret;
    
    //serialnoCD is the serial number of installation CD..
    if (sno!=serialnoCD){
        ret=MessageBox("To use this software CD Must be in the drive",
                       "Sorry", MB_RETRYCANCEL|MB_ICONERROR|MB_APPLMODAL);    
    }
}

This is only an idea and I don't know much about pirating software. I heard that the serial number is unique for all CD's and it can't be changed but I don't know that is true or false. Anyway I think this method can be useful to reduce or lower piracy. What do you think?

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

H. Joseph



United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralChecking the serial Number of a CD PinmemberBabita Shivade1:49 17 Mar '09  
GeneralRe: Checking the serial Number of a CD Pinmembermbaocha19:10 27 Apr '09  
GeneralFailing to read the serial number PinmemberJorgeAxel9:46 26 Jan '09  
GeneralI CAN STOP THE PIRACY IF I get the solution preventing serail No to be copeid. Pinmemberprashant Shukla7:46 25 Aug '06  
GeneralRe: I CAN STOP THE PIRACY IF I get the solution preventing serail No to be copeid. Pinmembertamuz10:09 23 Jul '07  
QuestionHow to Protect the content on CD PinmemberPraveen Reddy R18:40 7 Dec '05  
GeneralI can break any Copy Protected CD PinsussEngr. ‘Wale (Nigeria, West Africa)9:42 13 Jun '05  
I am Engr. ‘Wale, from Nigeria, West Africa. I specialized in C/C++ and Assembler.
 
It is easy as unwrapping a Candy. There are different ways in doing it; I will mention 3 out of 100!
 
1: Make a clone of the original CD with Freeware or Shareware CD copy software (many of them is available on the Net); the Serial Number will be the same.
 
2: You can attack the Installation Exec Code with Hexa-debug in C/C++ or assembler and bypass the Serial Number Detecting Code. Generate a new installation Exec file, and burn it with other files to create a new CD.
 
3: If the CD proves stubborn, like Hexalock or Starforce that uses micro fingerprinting, get a Spy (Not Microsoft Spy!, I once wrote one and many is on the Net). Run the Spy to be active, then run the installation software on the original CD while the Spy watches. At the end of installation, use the Spy to create Dummy compressed installation files, and burn it on another CD. Pronto!
 
If all the above failed which I doubt send it to me, let me have a look at it.
I hate Piracy Anyway. I believe in cheap/shareware software.
Please remember some people in Africa can’t afford a PC not to talk of Software, while some people waste money building nuclear missiles!

GeneralHow to make Copy Protected CD PinmemberPraveen Reddy R18:08 7 Dec '05  
GeneralRe: How to make Copy Protected CD Pinmembertamuz9:56 23 Jul '07  
GeneralI can break any Copy Protected CD PinsussEngr. ‘Wale9:41 13 Jun '05  
GeneralRe: I can break any Copy Protected CD [modified] Pinmemberprashant Shukla7:35 25 Aug '06  
GeneralRe: I can break any Copy Protected CD Pinmembertamuz10:20 23 Jul '07  
AnswerRe: I can break any Copy Protected CD [modified] PinmemberWale Kassim7:05 2 Sep '07  
GeneralDoes not really work PinmemberAnonymous22:57 10 Jun '02  
GeneralSorry Doesnt Work PinmemberAnonymous15:00 12 Apr '02  
GeneralRe: Sorry Doesnt Work PinsussAnonymous2:00 13 Jul '03  
GeneralNaive coders create rich lawyers PinmemberAnonymous19:45 22 Feb '02  
GeneralRe: Naive coders create rich lawyers PinmemberNish [BusterBoy]20:27 22 Feb '02  
GeneralRe: Naive coders create rich lawyers PinmemberHirosh Joseph7:17 23 Feb '02  
AnswerRe: Naive coders create rich lawyers Pinmembertamuz10:32 23 Jul '07  
GeneralHelpfull but question PinmemberAMW7:46 27 Jan '02  
QuestionWhat about backup CD copies? PinmemberPP3:39 2 Jan '02  
AnswerRe: What about backup CD copies? Pinmemberhirosh22:14 2 Jan '02  
GeneralRe: What about backup CD copies? PinsussAnonymous2:07 13 Jul '03  
AnswerRe: What about backup CD copies? PinmemberHAHAHA_NEXT9:58 28 Apr '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120528.1 | Last Updated 27 Dec 2001
Article Copyright 2001 by H. Joseph
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid