Solved

Generate Serial Number for my Program

Posted on 2012-04-05
2
546 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

626 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