Solved

Generate Serial Number for my Program

Posted on 2012-04-05
2
537 Views
Last Modified: 2012-04-05
I am trying to figure out the best way for users to "register" the program I am writing.

Here are my simple guidelines:

1. The program should be able to be registered without an internet connection.

2. The registration dialog box consists of a USERNAME and SERIAL NUMBER edit control.


I would like some high level suggestions on how to make sure the serial number is unique to each user BASED upon their USERNAME.

Of course we have some CONSTANTS I have available to me, for each user, which could be used to generate the final serial number.

a. hard drive serial
b. time info ( day, month, etc )
c. other WIN32 api return values that are consistent....

So, I would like some ideas on a simple algorithm based on the username.

All sincere suggestions will receive points.

I would LOVE a solution (suggestion) that I could actually put into production - not necessarily code, but a detailed suggestion - KEEP IN MIND PLEASE, I am only an intermediate C++ programmer, lol.

THANKS!!
0
Comment
Question by:edvinson
2 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 37814868
If you are after a unique serial number based on the user's machine, try a GUID:

#include <objbase.h>
#include <stdio.h>

#pragma comment(lib,"ole32.lib")

void GenerateGUID(char* pBuf) {

  GUID guid;
  ::CoInitialize(0);
  ::CoCreateGuid(&guid);

  sprintf(pBuf,"{%08lX-%04X-%04x-%02X%02X-%02X%02X%02X%02X%02X%02X}",
        guid.Data1, guid.Data2, guid.Data3,
        guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
        guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]);

  CoUninitialize();
}

Open in new window

0
 
LVL 1

Author Closing Comment

by:edvinson
ID: 37814928
Great solution, JKR. This solution never occurred to me.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

680 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