Last Modified October 2, 2026

TurnKey Activation - Code Sample

This Code Sample is not a complete coding example, but serves to illustrate the key steps for implemeting the TurnKey Activation method. For the complete code example, download the Code Samples from the DNA Control Panel.

Highlighted lines indicate where additional code is required or needs to be modified.

                	

                        // definition of constants unShuffledMD5 and DNA_product_key
                        
                        // 64-bit DLL MD5 - use the correct MD5 for the DNA Library used
                        //
                        #define unShuffledMD5 "5a304c147fca8fd97d41cfdd149b92c7" 
                        
                        // the DNA_Product_Key is emailed to you when you initially create a DNA Product
                        // You can have it resent to you from the DNA Control Panel
                        //    
                        #define DNA_product_key ""
                        
                        
                        // at start-up of the application
                        //
                        // authenticate the DNA.DLL MD5
                        //
                        // declare variables used in MD5 check
                        
                        char* MD5DigestHex;
                        MD5 md5 ;
                        
                        MD5DigestHex = md5.digestFile( "DNA.DLL" );	
                        
                        if (strcmp((const char *)MD5DigestHex,unShuffledMD5)!=0)
                            {
                        
                            	// invalid MD5 
                        		// - quit the application
                        		// - show error message (optional)
                        
                            }
                        
                        // 
                        // load the dynamic DNA Library (applies to C, C++, Objective C)
                        //
                        
                        errNo = LoadDNA("dna.dll");       
                        
                        // 
                        // set the location of the CDM License File
                        // CDMPathName MUST be encoded in UTF-8
                        // This example shows the recommended location for a Windows OS Application
                        
                        char* CDMPathName = "C:\\Users\\Public\\HelloWorld\\HelloWorld.CDM";
                        
                        errNo = DNA_SetProperties("CDMPATHNAME",CDMPathName); 
                         
                        
                        //
                        // call the DNA_ProtectionOK() API
                        //
                        // this example allows user to "Request Evaluation Code" (2nd parameter) and 
                        // screen requests using the <machineID> (3rd parameter)
                        
                        errNo = DNA_ProtectionOK(DNA_product_key,1,0);
                        
                        if (errNo <= 0)
                        
                            {
                                // valid license exists or activation was OK, run the application
                                
                            }
                        else
                            {
                                // error occurred, quit the application
                                
                                // optionally, you can display an error message
                                // you can use DNA_ERROR() which translate the errNo into a more
                                // user-friendly description, or use your own descriptions
                                
                                DNA_Error(errNo,buffer,sizeof(buffer));
                                
                                // display error explanation
                                // quit the application
                            }
                        
                        
                        //
                        // For Licenses that require De-Activation, the following code should be included
                        // in the response to a "De-Activate" button click or menu selection 
                        //
                        
                        // License De-Activation requires a <password> parameter that must be 
                        // captured from the User
                        // here we use the build-in De-Activation function from the DNA_ProtectionOK() API call
                        
                        errNo = DNA_ProtectionOK(DNA_product_key,3,0);
                        
                        if (errNo == 0)
                        
                            {
                                // deactivation was OK, exit the application
                                
                            }
                        else
                            {
                                // error occurred, quit the application
                                
                                // optionally, you can display an error message
                                // you can use DNA_ERROR() which translate the errNo into a more
                                // user-friendly description, or use your own descriptions
                                
                                            DNA_Error(errNo,buffer,sizeof(buffer));
                                
                                // display error explanation
                                // quit the application
  							}