Академический Документы
Профессиональный Документы
Культура Документы
home
articles
quick answers
discussions
features
community
help
Next
Article Browse Code Stats Revisions (4) Alternatives Comments & Discussions (207)
About Article
A library to easily create a trial version of your application Type Licence Article CPOL 6 Sep 2006 276,905 63,128 385 times
Download source files - 72 Kb Download Example files - 70 Kb Download Serial Maker files - 46 Kb Download SerialBox Control files - 34 Kb Download FilterTextBox Control files - 19 Kb
Introduction
Windows Dev , +
It's very common to want a trial version of your application. For example, you need your application to only run for 30 days, or the user can only run your application 200 times. You can do this kind of task with this library. If someone wants to buy your application, he must call you and read his computer ID. Then you will use the Serial Maker to make a serial key (password). After entering the password, the application always runs as the full version. If the trial period is finished, reinstalling the application won't let user run it. The computer ID is a 25 character string that came from hardware information. Processor ID, main board manufacturer, VGA name, hard disk serial number, etc. You can choose what hardware items you want to use to make the computer ID. When you give the password to a customer, his password won't change until he changes his hardware.
Top News
Microsoft bets on Windows XP disaster
Get the Insider News free each morning.
Computer ID
To make a Computer ID, you must indicate the name of your application. That's because if you have used Trial Maker to make a trial for more than one application, each application will have it's own Computer ID. In the source, Computer ID = "BaseString" Trial Maker uses management objects to get hardware information.
www.codeproject.com/Articles/15496/Application-Trial-Maker
1/6
12/24/13
Serial
The password will be produced by changing the Computer ID. To make a password, you must have your own identifier. This identifier is a 3 character string. None of characters must be zero.
Related Videos
Files
There are two files to work with in this class. The first file is used to save computer information and remaining days of the trial period. This file must be in a secure place, and the user must not find it (R e g F i l e ). It's not a bad idea to save this file in application startup directory The second file will be used if the user registers the software. It will contain the serial that the user entered (H i d e F i l e ). You can save HideFile in, for example, C:\Windows\system32\tmtst.dfg. I mean some obscure path. Both files will be encrypted using Triple DES algorithm. The key of encryption is custom. It's better you choose your own key for encryption.
Related Articles
Creating Secure Trial Versions for .NET Applications - A Tutorial Implementing a Rudimentary Count Based Trial Version Plugin for Windows Applications What Goes Into the Ultimate User Interface? Molecular Clinical Trials: MCT Understanding the Why, What, and How of Reporting Solutions: Reporting 101 Asynchronous Progress Using Microsoft.DirectX.AudioVideoPlayback in C# Understanding the Sea of Data: Infragistics Helps Developers Visualize Data ImageList Wizard Title: 5 Lessons Learned Extending On-Premise Software to The Cloud From .NET Reporting to Business Intelligence: How software developers today are unleashing critical business efficiencies across the board LyricsFetcher - The Easiest Way to Find Lyrics for your Songs Demonstration of selectOneMenu tag in JSF Shareware registration dialog Controlling Demo-Version Crack and Software Piracy Issue for Beginners - Part 1 Snow Ninja 7 Questions You Always Wanted to Ask about Content Management Systems Visualizing the Windows Mobile Virtual Memory Monster How to integrate Usercontrols in LightSwitch Application? XSL Transform for ToDoList Use Rules In Your Applications
How it works
Getting System Information
S y s t e m I n f oclass is for getting system information. It contains the G e t S y s t e m I n f o function. This function takes the
application name and appends to it the Processor ID, main board product, etc.
Collapse | Copy Code
p u b l i cs t a t i cs t r i n gG e t S y s t e m I n f o ( s t r i n gS o f t w a r e N a m e ) { i f( U s e P r o c e s s o r I D= =t r u e ) S o f t w a r e N a m e+ =R u n Q u e r y ( " P r o c e s s o r " ," P r o c e s s o r I d " ) ; i f( U s e B a s e B o a r d P r o d u c t= =t r u e ) S o f t w a r e N a m e+ =R u n Q u e r y ( " B a s e B o a r d " ," P r o d u c t " ) ; i f( U s e B a s e B o a r d M a n u f a c t u r e r= =t r u e ) S o f t w a r e N a m e+ =R u n Q u e r y ( " B a s e B o a r d " ," M a n u f a c t u r e r " ) ; / /S e em o r ei ns o u r c ec o d e S o f t w a r e N a m e=R e m o v e U s e L e s s ( S o f t w a r e N a m e ) ; i f( S o f t w a r e N a m e . L e n g t h<2 5 ) r e t u r nG e t S y s t e m I n f o ( S o f t w a r e N a m e ) ; r e t u r nS o f t w a r e N a m e . S u b s t r i n g ( 0 ,2 5 ) . T o U p p e r ( ) ;
Then it removes unused characters from the string. Any characters outside the range A to Z and 0 to 9 are unused characters. If the string isn't long enough, call G e t S y s t e m I n f o A g a i nto make it longer.
R u n Q u e r yfunction takes object name (T a b l e N a m e ) and method name and returns defined method of first object
Collapse | Copy Code
Related Research
p r i v a t ev o i dM a k e B a s e S t r i n g ( ) { _ B a s e S t r i n g= E n c r y p t i o n . B o r i n g ( E n c r y p t i o n . I n v e r s e B y B a s e ( S y s t e m I n f o . G e t S y s t e m I n f o ( _ S o f t N a m e ) , 1 0 ) ) ; }
www.codeproject.com/Articles/15496/Application-Trial-Maker
2/6
12/24/13
Insider Secrets for Avoiding a Malware Breach: Best Practices for Securing Your Private Keys and Code Signing Certificates
s t a t i cp u b l i cs t r i n gM a k e P a s s w o r d ( s t r i n gs t ,s t r i n gI d e n t i f i e r ) { i f( I d e n t i f i e r . L e n g t h! =3 ) t h r o wn e wA r g u m e n t E x c e p t i o n ( " I d e n t i f i e rm u s tb e3c h a r a c t e rl e n g t h " ) ; i n t [ ]n u m=n e wi n t [ 3 ] ; n u m [ 0 ]=C o n v e r t . T o I n t 3 2 ( I d e n t i f i e r [ 0 ] . T o S t r i n g ( ) ,1 0 ) ; n u m [ 1 ]=C o n v e r t . T o I n t 3 2 ( I d e n t i f i e r [ 1 ] . T o S t r i n g ( ) ,1 0 ) ; n u m [ 2 ]=C o n v e r t . T o I n t 3 2 ( I d e n t i f i e r [ 2 ] . T o S t r i n g ( ) ,1 0 ) ; s t=B o r i n g ( s t ) ; s t=I n v e r s e B y B a s e ( s t ,n u m [ 0 ] ) ; s t=I n v e r s e B y B a s e ( s t ,n u m [ 1 ] ) ; s t=I n v e r s e B y B a s e ( s t ,n u m [ 2 ] ) ; S t r i n g B u i l d e rS B=n e wS t r i n g B u i l d e r ( ) ; f o r e a c h( c h a rc hi ns t ) { S B . A p p e n d ( C h a n g e C h a r ( c h ,n u m ) ) ; } r e t u r nS B . T o S t r i n g ( ) ;
Check Password
After making B a s e S t r i n gand password, check if the user already registered the software. To do this, use C h e c k R e g i s t e rFunction. It will return true if registered before and false if not. If C h e c k R e g i s t e r returns false, open a registration dialog for the user to enter the password.
Show Dialog
Create new f r m D i a l o g and show it to the user. If the dialog result is O K , it means software is registered successfully, and if it is R e t r y , it means it is in trial mode. Any other D i a l o g R e s u l tmeans cancel. The Dialog class takes BaseString, Password, days to end and Run times to end as arguments.
F i l e R e a d W r i t e . W r i t e F i l etake a 2 strings. The first one is the file path and the second one is the data to write.
After writing all data it write byte 0 as finish. It will use for reading
Collapse | Copy Code
The key for writing and reading is the same one, it's custom and you can change it.
How To Use
Where to use
The best place that you can check for registration is before showing the main dialog. When you have created a Windows application project, first you must add SoftwareLocker.dll as reference
www.codeproject.com/Articles/15496/Application-Trial-Maker
3/6
12/24/13
u s i n gS o f t w a r e L o c k e r ;
Collapse | Copy Code
[ S T A T h r e a d ] s t a t i cv o i dM a i n ( ) { A p p l i c a t i o n . E n a b l e V i s u a l S t y l e s ( ) ; A p p l i c a t i o n . S e t C o m p a t i b l e T e x t R e n d e r i n g D e f a u l t ( f a l s e ) ; T r i a l M a k e rt=n e wT r i a l M a k e r ( " T M T e s t 1 " , A p p l i c a t i o n . S t a r t u p P a t h+" \ \ R e g F i l e . r e g " , E n v i r o n m e n t . G e t F o l d e r P a t h ( E n v i r o n m e n t . S p e c i a l F o l d e r . S y s t e m )+ " \ \ T M S e t p . d b f " , " P h o n e :+ 9 82 18 8 2 8 1 5 3 6 \ n M o b i l e :+ 9 89 1 22 8 8 1 8 6 0 " , 5 ,1 0 ," 7 4 5 " ) ; b y t e [ ]M y O w n K e y={9 7 ,2 5 0 , 1 , 5 , 8 4 ,2 1 , 7 ,6 3 , 4 , 5 4 ,8 7 ,5 6 ,1 2 3 ,1 0 , 3 ,6 2 , 7 , 9 ,2 0 ,3 6 , 3 7 ,2 1 ,1 0 1 ,5 7 } ; t . T r i p l e D E S K e y=M y O w n K e y ; / /i fy o ud o n ' tc a l lt h i sp a r tt h ep r o g r a mw i l l / / u s ed e f a u l tk e yt oe n c r y p t i o n T r i a l M a k e r . R u n T y p e sR T=t . S h o w D i a l o g ( ) ; b o o li s _ t r i a l ; i f( R T! =T r i a l M a k e r . R u n T y p e s . E x p i r e d ) { i f( R T= =T r i a l M a k e r . R u n T y p e s . F u l l ) i s _ t r i a l=f a l s e ; e l s e i s _ t r i a l=t r u e ; } A p p l i c a t i o n . R u n ( n e wF o r m 1 ( i s _ t r i a l ) ) ;
Constructor
S o f t w a r e N a m e : Your software's name, this will be used to make ComputerID R e g F i l e P a t h : The file path that, if the user entered the registration code, will save it and check on every run. H i d d e n F i l e P a t h : This file will be used to save system information, days to finish trial mode, how many other
times user can run application and current date. T e x t : It will show below the OK button on the Registration Dialog. Use this text for your phone number, etc. D e f a u l t D a y s : How many days the user can run in trial mode. D e f a u l t T i m e s : How many times user can run the application. I d e n t i f i e r : Three character string for making password. It's the password making identifier
t . U s e B i o s V e r s i o n=f a l s e/ /=t r u e ;
You can do this with any t . U s e X x x Don't disable all of them or none of them, enabling 3 or 4 of them is the best choice. Or you can leave it as its default.
Serial Maker
Serial maker is another application that uses the Encryption class. It takes your identifier and generate a password (serial key) Doesn't contain anything special.
www.codeproject.com/Articles/15496/Application-Trial-Maker
4/6
12/24/13
Other Controls
In the registration dialog, I have used a S e r i a l B o xcontrol. It's only 5 text boxes that you can write your serial in.
S e r i a l B o xuses F i l t e r T e x t B o x itself.
Both of these controls are available to download.
Notes
All codes are written in Visual Studio 2005 Serial Maker uses Encryption class from Trial Maker as a file link Writing with one encryption key and reading with another will cause an exception FilterTextBox Control is not the same that I wrote before in my articles Always Secure your identifiers and don't lose them
License
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Hamed J.I
Web Developer Iran (Islamic Republic Of) I began programming with C/C++ when i was 15. Then try to learn VC++ but at the middle of my reading .NET came. I began to read C# and VB.NET and also began designing basic websites by FrontPage and developed some websites for our school and some other companis. Later learn Microcontroller and design some digital circuits with PIC microcontrollers for a industrial controller company. As I learned SQL and ASP.NET developed some website such as news portals that are active now. Now i'm a software student and teach programming in computer institues. And have my own job by getting projects from companies. Article Top
www.codeproject.com/Articles/15496/Application-Trial-Maker
5/6
12/24/13
any solution to work in windows 7 ? Re: any solution to work in windows 7 ? A simple Dll question Getting a bad data error frmDialog text Renew Trial Maker time Re: Renew Trial Maker time W8 issue Re: W8 issue Re: W8 issue Re: W8 issue My vote of 4
How to make serial maker Working ,to solve Encryption.cs problem in Serial Maker and Object reference not set to instance of object Wrong password error Many thanks, good work Key changes after re-installing Windows good work ... but fatel error Re: good work ... but fatel error Object reference not set to an instance of an object Re: Object reference not set to an instance of an object
devduttbhatt J.Becker Naresh Dhakecha Member 9910233 Praveen21212 Member 10063932 chandan0285
12-Aug-13 18:48 10-Aug-13 13:45 1-Aug-13 7:56 4-Jun-13 0:43 25-Jul-13 19:32 23-May-13 21:47 21-Aug-13 0:40
Encryption.cs not found Question: what about hiden file"TMSetp.dbf" been found and deleted? My vote of 1 serial maker is not working Re: serial maker is not working
Last Visit: 23-Dec-13 17:54 General News Last Update: 23-Dec-13 21:31 Suggestion Question Bug Answer
1 2 3 4 5 6 7 8 9 Next Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.
Permalink | Advertise | Privacy | Mobile Web04 | 2.7.131219.1 | Last Updated 17 Feb 2009
Article Copyright 2006 by Hamed J.I Everything else Copyright CodeProject, 1999-2013 Terms of Use
www.codeproject.com/Articles/15496/Application-Trial-Maker
6/6