Serialnumber generation

This is a discussion on Serialnumber generation within the C++ Programming forums, part of the General Programming Boards category; Hi, for a plugin I'm doing I need to come up with the best way to generate a unique requestnumber ...

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    158

    Serialnumber generation

    Hi, for a plugin I'm doing I need to come up with the best way to generate a unique requestnumber that in turn will generate a serialnumber, which will activate the product.

    I have been looking around a bit and found an option to use the MAC Adress of the Network card which is supposed to be unique for every computer. Is that a good way to handle such a thing? I'm not sure if every computer even has a network card...like laptops and such. What I need is some sort of Machine ID that is unique for each computer.

    Keep in mind that I am fairly new to c++ so you will have to explain it to me as if I am a complete idiot.

    cheers,
    Carl-Mikael

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,496
    http://clusty.com/search?query=uuid+...Mozilla-search
    Some systems have an API call to make this for you.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    158
    Hmm, that might be something like what I want but isn't a UUID different everytime it is retrieved, like random generated? I need some value that is the same everytime on a specific computer.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,496
    Generate it once, then save it somewhere for later retrieval ?

    What if the user changes their network card, and you're relying on the MAC staying constant?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    158
    I do not want a specfic copy of the program to be linked to a specific value. The program can be freely downloaded and used in demo mode but needs to bind itself to a specific computer when activated. Is using the MAC adress a good way in that case or is there something better?

    Changing network card is not too common I think and if they do (or change computer)they will be able to contact support for such an issue.

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,496
    Sounds like you've settled on the MAC address then.

    > I do not want a specfic copy of the program to be linked to a specific value.
    But it (the UUID) is generated on the local machine the first time you run it, and thereafter remains constant.

    Whatever you choose which is bound to physical hardware (MAC address, HD serial number, whatever), you're going to get complaints from people whenever they upgrade. Prepare an extensive FAQ for support.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Oct 2007
    Posts
    158
    Well I already do hehe. Right now the activation is tied to an ID that is specific for the program that the plugin is for so whenever they reinstall or upgrade that program I have that issue. If it can be tied to the computer instead it would be a load lifted of me and better for the users. The plugin is currently maxscript based and I am converting it to c++.

    So...is it correct that I can assume that every computer will have a MAC adress? (I will only deal with windows based computers)

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,496
    Since you're assuming the delivery mechanism is to download it, then it's pretty safe to assume that there is a MAC address of some sort (I think).

    But then again I tend to think that far too much effort is put into over elaborate, and ultimately ineffective protection mechanisms, where such effort would be better directed at improving the product in the first place.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Is using the MAC adress a good way in that case or is there something better?
    AFAIK MAC addresses are no longer burnt into the hardware. Modern network cards just send everything to the OS for it to deal with. This means that its quite easy to change your MAC address if you want to. One of my teachers showed me how to do it in linux.

  10. #10
    Registered User
    Join Date
    Oct 2007
    Posts
    158
    Salem - It will also need to work on a computer without internet connection. About the need for protection, well nobody is willing to pay for a free program are they? My program is quite extensive and I would not put as much effort into it if it was sharewere. I just need something simple though.

    mike_g - Ok so it might not be such a good idea then.

    I found this in another thread here. Do you think it is a good idea to use something like this? Supposedly the volume serialnumber is possible to change but I don't think that is a thing you generally do. The code:
    Code:
    #include <windows.h>
    
    int GetVolumeSerial()
    {
        DWORD dwVolSerial;
        BOOL bIsRetrieved;
        bIsRetrieved = GetVolumeInformation("C:\\",NULL,NULL,&dwVolSerial,NULL,NULL,NULL,NULL);
        if (bIsRetrieved) 
        {
            int serial = (int)dwVolSerial;
            return serial;
        } 
        return 0;
    }
    This is modified form a sample found here:
    http://cboard.cprogramming.com/c-programming/60299-hd-serial-number-post427642.html

  11. #11
    Registered User
    Join Date
    Oct 2007
    Posts
    158
    See in my example that typecast the dwVolSerial to an int...is that a safe thing to do? The dwVolSerial can as an example be D403B623. What happens when I type cast that to an int?

  12. #12
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    That data as a string is more than an int can store. If its eight ASCII characters it could be casted as a 'long long'.

  13. #13
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    Quote Originally Posted by Salem View Post
    But then again I tend to think that far too much effort is put into over elaborate, and ultimately ineffective protection mechanisms, where such effort would be better directed at improving the product in the first place.
    MAC-locking is reasonably simple to do and stops casual or accidental piracy. Shrug.

    Once you start actively considering "Now, if I do this, and then THEY do THIS, then I'll do THIS, etc etc etc..." Then you've gone into pointless-land.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adventures in labyrinth generation.
    By guesst in forum Game Programming
    Replies: 8
    Last Post: 10-12-2008, 01:30 PM
  2. Labyrinth generation
    By guesst in forum Game Programming
    Replies: 16
    Last Post: 10-09-2008, 06:02 PM
  3. Diablo's random level generation
    By glo in forum Game Programming
    Replies: 7
    Last Post: 07-19-2008, 03:04 AM
  4. C Program with Tone Generation. HELP
    By LaVieEnRose in forum C Programming
    Replies: 1
    Last Post: 11-22-2007, 07:37 PM
  5. Grid generation from scattered points?
    By canada-paul in forum C Programming
    Replies: 6
    Last Post: 12-12-2003, 04:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21