Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Generate Serial Number for my Program

Posted on 2012-04-05
2
Medium Priority
?
554 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

963 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