Click here to Skip to main content
12,070,171 members (29,739 online)
Click here to Skip to main content
Add your own
alternative version

Stats

190.4K views
2K downloads
35 bookmarked
Posted

Checking the serial Number of a CD

, 26 Dec 2001
Rate this:
Please Sign up or sign in to vote.
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.
<!-- Download Links --> <!-- Add the rest of your HTML here -->

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

Share

About the Author

H. Joseph
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralChecking the serial Number of a CD Pin
Babita Shivade17-Mar-09 2:49
memberBabita Shivade17-Mar-09 2:49 
GeneralRe: Checking the serial Number of a CD Pin
mbaocha27-Apr-09 20:10
membermbaocha27-Apr-09 20:10 
GeneralFailing to read the serial number Pin
JorgeAxel26-Jan-09 10:46
memberJorgeAxel26-Jan-09 10:46 
GeneralI CAN STOP THE PIRACY IF I get the solution preventing serail No to be copeid. Pin
prashant Shukla25-Aug-06 8:46
memberprashant Shukla25-Aug-06 8:46 
GeneralRe: I CAN STOP THE PIRACY IF I get the solution preventing serail No to be copeid. Pin
tamuz23-Jul-07 11:09
membertamuz23-Jul-07 11:09 
QuestionHow to Protect the content on CD Pin
Praveen Reddy R7-Dec-05 19:40
memberPraveen Reddy R7-Dec-05 19:40 
GeneralI can break any Copy Protected CD Pin
Engr. ‘Wale (Nigeria, West Africa)13-Jun-05 10:42
sussEngr. ‘Wale (Nigeria, West Africa)13-Jun-05 10:42 
GeneralHow to make Copy Protected CD Pin
Praveen Reddy R7-Dec-05 19:08
memberPraveen Reddy R7-Dec-05 19:08 
GeneralRe: How to make Copy Protected CD Pin
tamuz23-Jul-07 10:56
membertamuz23-Jul-07 10:56 
GeneralI can break any Copy Protected CD Pin
Engr. ‘Wale13-Jun-05 10:41
sussEngr. ‘Wale13-Jun-05 10:41 
GeneralRe: I can break any Copy Protected CD [modified] Pin
prashant Shukla25-Aug-06 8:35
memberprashant Shukla25-Aug-06 8:35 
GeneralRe: I can break any Copy Protected CD Pin
tamuz23-Jul-07 11:20
membertamuz23-Jul-07 11:20 
AnswerRe: I can break any Copy Protected CD [modified] Pin
Wale Kassim2-Sep-07 8:05
memberWale Kassim2-Sep-07 8:05 
GeneralDoes not really work Pin
Anonymous10-Jun-02 23:57
memberAnonymous10-Jun-02 23:57 
GeneralSorry Doesnt Work Pin
Anonymous12-Apr-02 16:00
memberAnonymous12-Apr-02 16:00 
GeneralRe: Sorry Doesnt Work Pin
Anonymous13-Jul-03 3:00
sussAnonymous13-Jul-03 3:00 
GeneralNaive coders create rich lawyers Pin
Anonymous22-Feb-02 20:45
memberAnonymous22-Feb-02 20:45 
GeneralRe: Naive coders create rich lawyers Pin
Nish [BusterBoy]22-Feb-02 21:27
memberNish [BusterBoy]22-Feb-02 21:27 
GeneralRe: Naive coders create rich lawyers Pin
Hirosh Joseph23-Feb-02 8:17
memberHirosh Joseph23-Feb-02 8:17 
AnswerRe: Naive coders create rich lawyers Pin
tamuz23-Jul-07 11:32
membertamuz23-Jul-07 11:32 
GeneralHelpfull but question Pin
AMW27-Jan-02 8:46
memberAMW27-Jan-02 8:46 
QuestionWhat about backup CD copies? Pin
PP2-Jan-02 4:39
memberPP2-Jan-02 4:39 
AnswerRe: What about backup CD copies? Pin
hirosh2-Jan-02 23:14
memberhirosh2-Jan-02 23:14 
GeneralRe: What about backup CD copies? Pin
Anonymous13-Jul-03 3:07
sussAnonymous13-Jul-03 3:07 
AnswerRe: What about backup CD copies? Pin
HAHAHA_NEXT28-Apr-04 10:58
memberHAHAHA_NEXT28-Apr-04 10:58 
GeneralAll copy protection schemes fail Pin
John Bates1-Jan-02 15:29
memberJohn Bates1-Jan-02 15:29 
GeneralRe: All copy protection schemes fail Pin
Tim Smith1-Jan-02 15:48
memberTim Smith1-Jan-02 15:48 
GeneralRe: All copy protection schemes fail Pin
Andy Metcalfe1-Jan-02 22:48
memberAndy Metcalfe1-Jan-02 22:48 
GeneralSounds easy... Pin
Brian V Shifrin31-Dec-01 23:11
memberBrian V Shifrin31-Dec-01 23:11 
GeneralRe: Sounds easy... Pin
hirosh1-Jan-02 4:56
memberhirosh1-Jan-02 4:56 
GeneralRe: Sounds easy... Pin
Brian V Shifrin2-Jan-02 8:56
memberBrian V Shifrin2-Jan-02 8:56 
GeneralBad News... Pin
Andy Metcalfe31-Dec-01 8:49
memberAndy Metcalfe31-Dec-01 8:49 
GeneralRe: Bad News... Pin
Christian Graus1-Jan-02 16:06
memberChristian Graus1-Jan-02 16:06 
GeneralRe: Bad News... Pin
Andy Metcalfe1-Jan-02 22:46
memberAndy Metcalfe1-Jan-02 22:46 
GeneralProblem with VIRTUAL CDROM Pin
Wizard_0131-Dec-01 7:39
memberWizard_0131-Dec-01 7:39 
GeneralRe: Problem with VIRTUAL CDROM Pin
hirosh31-Dec-01 7:52
memberhirosh31-Dec-01 7:52 
QuestionWhat about two CD-drives Pin
Anonymousw30-Dec-01 3:01
memberAnonymousw30-Dec-01 3:01 
AnswerRe: What about two CD-drives Pin
hirosh31-Dec-01 7:54
memberhirosh31-Dec-01 7:54 
GeneralSolution: Pin
Gilad Novik30-Dec-01 2:13
memberGilad Novik30-Dec-01 2:13 
GeneralRe: Solution: Pin
peterchen2-Jan-02 10:14
memberpeterchen2-Jan-02 10:14 
GeneralJust a few remarks... Pin
Nemanja Trifunovic27-Dec-01 18:24
memberNemanja Trifunovic27-Dec-01 18:24 
GeneralRe: Just a few remarks... Pin
hirosh27-Dec-01 23:42
memberhirosh27-Dec-01 23:42 
GeneralRe: Just a few remarks... Pin
Protoform X28-Dec-01 14:41
memberProtoform X28-Dec-01 14:41 
GeneralRe: Just a REAL few remarks... Pin
JoJoDaCaraKar!29-Dec-01 0:21
memberJoJoDaCaraKar!29-Dec-01 0:21 
GeneralRe: Just a REAL few remarks... Pin
Protoform X2-Jan-02 15:51
memberProtoform X2-Jan-02 15:51 
GeneralRe: Just a few remarks... Pin
Anonymous28-Oct-02 5:03
sussAnonymous28-Oct-02 5:03 

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

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

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