S.l.e!ep.¢%

像打了激速一样,以四倍的速度运转,开心的工作
简单、开放、平等的公司文化;尊重个性、自由与个人价值;
posts - 1098, comments - 335, trackbacks - 0, articles - 1
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

Call API in InstallShield 2009

Posted on 2009-03-24 08:50 S.l.e!ep.¢% 阅读(1679) 评论(0)  编辑 收藏 引用 所属分类: InstallShield
Data Type in InstallShield   And Win32API Data Type

BOOL TRUE or FALSE
CHAR 8-bit 有符号字符
DWORD 同NUMBER
HWND 窗口句柄(内部类型是NUMBER)
INT 同NUMBER
LIST 指向InstallShield list的指针(内部类型是NUMBER)
LONG 同NUMBER
LPSTR 同POINTER
NUMBER 有符号4字节整数
POINTER 指向数据的指针(如int i;p=&i)
SHORT 同NUMBER
STRING 字符串

Call API  For Example

prototype KERNEL32.GetVolumeInformation(BYREF STRING, BYREF STRING, NUMBER, BYREF NUMBER, BYREF NUMBER, BYREF NUMBER, BYREF STRING, NUMBER); 

附加一篇不错的文章

installshield安装程序,包括Mysql初始化、安装jre、配置环境变量、简单注册码生成

C代码 复制代码
  1. 曾经使用installshield制作的安装程序,包括Mysql初始化、安装jre、配置环境变量、简单注册码生成。  
C代码 复制代码
  1. ////////////////////////////////////////////////////////////////////////////////   
  2. //                                                                              
  3. //  File Name: Setup.rul                                                     
  4. //                                                                              
  5. //  Description: InstallShield script                                          
  6. //                                                                              
  7. //  Comments: This script was generated based on the selections you made in   
  8. //            the Project Wizard.  Refer to the help topic entitled "Modify        
  9. //            the script that the Project Wizard generates" for information   
  10. //    on possible next steps.   
  11. //   
  12. /////////////////////////////////////////////an///////////////////////////////////   
  13.   
  14. // Include header files   
  15.       
  16. #include "ifx.h"   
  17.       
  18. ////////////////////// string defines ////////////////////////////   
  19. //////////////////// installation declarations ///////////////////   
  20. // ----- DLL function prototypes -----   
  21.   
  22.     // your DLL function prototypes   
  23.   
  24. // ---- script function prototypes -----   
  25.   
  26.     // your script function prototypes   
  27.     // your global variables   
  28.     
  29. NUMBER volumeNum;   
  30. //Before using the GetVolumeInformation API you will need to prototype it   
  31. prototype KERNEL32.GetVolumeInformation(BYREF STRING, BYREF STRING, NUMBER, BYREF NUMBER, BYREF NUMBER, BYREF NUMBER, BYREF STRING, NUMBER);   
  32. //prototype for the custom InstallScript function   
  33. prototype GetVolumeSerial();   
  34. //function definition   
  35. function GetVolumeSerial()   
  36. STRING lpRootPathName;   
  37. STRING lpVolumeNameBuffer;   
  38. NUMBER nVolumeNameSize;   
  39. NUMBER lpVolumeSerialNumber;   
  40. NUMBER lpMaximumComponentLength;   
  41. NUMBER lpFileSystemFlags;   
  42. STRING lpFileSystemNameBuffer;   
  43. NUMBER nFileSystemNameSize;   
  44. BOOL APIReturn;   
  45. begin   
  46.   lpRootPathName="d:\\";   
  47.   nVolumeNameSize=60;   
  48.   nFileSystemNameSize=60;   
  49.   //APIReturn=GetVolumeInformation(lpRootPathName, lpVolumeNameBuffer, nVolumeNameSize,   lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize);   
  50.   APIReturn=GetVolumeInformation(lpRootPathName, lpVolumeNameBuffer, nVolumeNameSize,   lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer, nFileSystemNameSize);   
  51.     
  52.     
  53.   if (APIReturn) then           
  54.     
  55.    volumeNum = lpVolumeSerialNumber ;    
  56.    if (volumeNum < 0) then   
  57.     volumeNum = 0 - volumeNum;   
  58.    endif;        
  59.    //NumToStr(volumeNum,lpVolumeSerialNumber);   
  60.     //SprintfBox(INFORMATION, "", "Volume= %s\nVolume Serial= %d", lpRootPathName, lpVolumeSerialNumber);   
  61.    if (volumeNum > 2139999999 - 135792468) then          
  62.     
  63.     //volumeNum = 123456789;   
  64.     volumeNum = volumeNum - volumeNum/100000000*100000000;   
  65.    endif;        
  66.       
  67.   else                       
  68.     
  69.      volumeNum = 123456789;   
  70.     //MessageBox("Failure.",0);   
  71.   endif;   
  72. end ;   
  73. prototype getNumString();   
  74. function getNumString()   
  75.   number numSpace;   
  76.   number numMen;   
  77.   string tmpString;   
  78. begin                                           
  79.      //tmpNum = GetWindowHandle(HWND_INSTALL);  //安装主窗口的句柄    
  80.      //numSpace = GetDiskSpace("c:\\"); //指定驱动器上的空闲磁盘空间    
  81.      numSpace = GetDiskSpaceEx("c:\\",KBYTES); //指定驱动器上的空闲磁盘空间        BYTES    
  82.      //numMen = GetMemFree();  //运行在Microsoft Windows下的一个应用程序可用的内存大小       
  83.      numMen = GetDiskSpaceEx("d:\\",KBYTES);   
  84.      if numSpace < 10000 then   
  85.         numSpace = 11360000;   
  86.      else  
  87.       numSpace = (numSpace - numSpace/10000*10000)*10000;   
  88.      endif;   
  89.      if numMen < 10000 then   
  90.         numMen = 7521;     
  91.      else  
  92.       numMen = numMen - numMen/10000*10000;   
  93.      endif;                                                     
  94.      volumeNum = 100000000 + numSpace + numMen;    
  95.        
  96.      //NumToStr(tmpString,volumeNum);        
  97.     // MessageBox(tmpString,0);                               
  98. end;     
  99.     
  100.     
  101.     
  102. //////////////////////////////////////////////////////////////////////////////   
  103. //                                                                             
  104. //  FUNCTION:   OnFirstUIBefore                                              
  105. //                                                                             
  106. //  EVENT:      FirstUIBefore event is sent when installation is run for the first   
  107. //              time on given machine. In the handler installation usually displays   
  108. //              UI allowing end user to specify installation parameters. After this   
  109. //              function returns, ComponentTransferData is called to perform file   
  110. //              transfer.   
  111. //                                                                             
  112. ///////////////////////////////////////////////////////////////////////////////   
  113. function OnFirstUIBefore()   
  114.     number  nResult,nSetupType;   
  115.     string  szTitle, szMsg;   
  116.     string  szLicenseFile, szQuestion;   
  117.     string  szName, szCompany, szSerial;   
  118.     string  szFile;   
  119.     string  szTargetPath;   
  120.     string  szDir;   
  121.     string  szfolder;   
  122.     string  szComponents, szTargetdir;   
  123.     number  nLevel;   
  124.     LIST    listStartCopy;   
  125.     LIST    list;   
  126.     number  nvSize;       
  127.       
  128.     string szField1, svEdit1,szField2, svEdit2;   
  129.                         
  130.     string localNum;     
  131.     number tmpNum;        
  132.     string tmpCheckString;   
  133.     string checkString;   
  134. begin    
  135.     // TO DO: if you want to enable background, window title, and caption bar title                                                                       
  136.     // SetTitle( @TITLE_MAIN, 24, WHITE );                                          
  137.     // SetTitle( @TITLE_CAPTIONBAR, 0, BACKGROUNDCAPTION );                       
  138.     // Enable( FULLWINDOWMODE );           
  139.     // Enable( BACKGROUND );           
  140.     // SetColor(BACKGROUND,RGB (0, 128, 128));          
  141.              
  142.     GetVolumeSerial();                       
  143.     //getNumString();   
  144.       
  145.     tmpNum =  volumeNum;                
  146.     tmpNum = tmpNum - tmpNum / 100 * 100;     
  147.     NumToStr(tmpCheckString,tmpNum);       
  148.     if (tmpCheckString == "0") then   
  149.       tmpCheckString = "0X";   
  150.     endif;   
  151.     checkString = "B" + tmpCheckString + "_";        
  152.       
  153.     tmpNum =  volumeNum / 100;                
  154.     tmpNum = tmpNum - tmpNum / 100 * 100;     
  155.     NumToStr(tmpCheckString,tmpNum);      
  156.     if (tmpCheckString == "0") then   
  157.       tmpCheckString = "0X";   
  158.     endif;   
  159.     checkString = checkString + "K" + tmpCheckString + "_";   
  160.       
  161.     tmpNum =  volumeNum / 10000;                
  162.     tmpNum = tmpNum - tmpNum / 100 * 100;     
  163.     NumToStr(tmpCheckString,tmpNum);     
  164.     if (tmpCheckString == "0") then   
  165.       tmpCheckString = "0X";   
  166.     endif;   
  167.     checkString = checkString + "X" + tmpCheckString + "_";   
  168.       
  169.     tmpNum =  volumeNum / 1000000;                
  170.     tmpNum = tmpNum - tmpNum / 100 * 100;     
  171.     NumToStr(tmpCheckString,tmpNum);   
  172.     if (tmpCheckString == "0") then   
  173.       tmpCheckString = "0X";   
  174.     endif;    
  175.     checkString = checkString + "T" + tmpCheckString;   
  176.                                                       
  177.     //MessageBox(checkString,INFORMATION);    
  178.          
  179.     //变换volumeNum的值   
  180.     //B3242_K423_X342_T3423      
  181.     volumeNum = volumeNum + 135792468;              
  182.     NumToStr(localNum,volumeNum);                                                      
  183.     //MessageBox(localNum,INFORMATION);   
  184.       
  185.                            
  186.     //copy images                                                                                                                                    
  187.    nResult = XCopyFile(SRCDIR ^ "xxx\\icons\\media\\*.gif""c:\\xxx\\icons\\media\\",EXCLUDE_SUBDIR);                                                                                                    
  188.    nResult = XCopyFile(SRCDIR ^ "xxx\\icons\\teacher\\*.jpg""c:\\xxx\\icons\\teacher\\",EXCLUDE_SUBDIR);      
  189.    CreateDir("c:\\xxx\\resc\\");                         
  190.            
  191.    if (nResult != 0) then          
  192.          MessageBox ("图片拷贝出错!", SEVERE);   
  193.    endif;   
  194.       
  195.           
  196.           
  197.           
  198.           
  199.          
  200.          
  201.          
  202.     nSetupType = TYPICAL;    
  203.     TARGETDIR = PROGRAMFILES ^@COMPANY_NAME ^@PRODUCT_NAME;    
  204.     szDir = TARGETDIR;   
  205.     SHELL_OBJECT_FOLDER = @FOLDER_NAME;   
  206.     szName    = "";   
  207.     szCompany = "";   
  208.     szSerial = "";   
  209. Dlg_Start:   
  210.     // beginning of dialogs label   
  211. Dlg_SdWelcome:   
  212.     szTitle = "xxxx系统";   
  213.     szMsg   = "  确定是否继续安装?继续请按【下一步(next)】";   
  214.     nResult = SdWelcome( szTitle, szMsg );   
  215.     if (nResult = BACK) goto Dlg_Start;   
  216. //Dlg_SdLicense:   
  217. //    szLicenseFile = SUPPORTDIR ^ "license.txt";   
  218. //    szTitle    = "xxxx系统";   
  219. //    szMsg      = "许可协议";   
  220. //    szQuestion = "您是否接受该协议?接受请按【是(Yes)】。继续安装必须接受该协议。";   
  221. //    nResult    = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile );   
  222. //    if (nResult = BACK) goto Dlg_SdWelcome;   
  223. Dlg_SdShowInfoList:        
  224.     //szFile = SUPPORTDIR ^ "infolist.txt";   
  225.     //list = ListCreate( STRINGLIST );   
  226.     //ListReadFromFile( list, szFile );   
  227.     szTitle = "系统本地编号";   
  228.     szMsg    = "将下面的本地编号发送给权限授予机构,在接收到相应的注册码后,您将进行继续注册!";        
  229.     szField1 = "编号";   
  230.     svEdit1 = localNum;   
  231.     //nResult  = SdShowInfoList( szTitle, szMsg, list );    
  232.     //ListDestroy( list );       
  233.     nResult = SdShowDlgEdit1(szTitle, szMsg,szField1, svEdit1);          
  234.     //if (nResult = BACK) goto Dlg_SdLicense;   
  235.     if (nResult = BACK) goto Dlg_SdWelcome;   
  236. Dlg_SdRegisterUserEx:   
  237.     szMsg   = "请输入:用户名、公司名和注册号";   
  238.     szTitle = "xxxx系统";         
  239.     nResult = SdRegisterUserEx( szTitle, szMsg, szName, szCompany, szSerial );   
  240.     if (nResult = BACK) goto Dlg_SdShowInfoList;   
  241.     if (szSerial != checkString)  then        
  242.         MessageBox( "注册码输入错误!", SEVERE);   
  243.        goto Dlg_SdRegisterUserEx;       
  244.     endif;   
  245.                          
  246. Dlg_SdShowDlgEdit2:   
  247.     szTitle = "数据库信息";   
  248.     szMsg    = "请输入数据库用户名和数据库密码:";         
  249.     szField1 = "用户名";   
  250.     szField2 = "密码";   
  251.     svEdit1 = "root";   
  252.     svEdit2 = "password";        
  253.     nResult = SdShowDlgEdit2(szTitle, szMsg,szField1,szField2, svEdit1,svEdit2);    
  254.     if (nResult = BACK) goto Dlg_SdRegisterUserEx;   
  255.  //SdShowMsg ("下面进行数据库初始化操作,请勿手动关闭弹出窗口!", TRUE);   
  256.  //Delay(2);   
  257.     
  258.       
  259.    //启动mysql                                    
  260.    LaunchAppAndWait("net","start mysql",WAIT);   
  261.    //LaunchAppAndWait("net","stop mysql",WAIT);    
  262.    //LaunchAppAndWait("C:\\Program Files\\MySQL\\MySQL Server 4.1\\bin\\mysql.exe"," -uroot -ppassword<" + SRCDIR ^ "test.sql",NOWAIT);   
  263.   // LaunchAppAndWait("C:\\Program Files\\MySQL\\MySQL Server 4.1\\bin\\mysql.exe"," -h localhost  -u root   -p password<" + SRCDIR ^ "test.sql",WAIT) ;   
  264.    //LaunchApp(WINDIR ^ "Notepad.exe",SRCDIR ^ "init.sql");    
  265.    //LaunchAppAndWait(SRCDIR ^ "sql.bat"," root password ",WAIT);    
  266.    ///LaunchAppAndWait("C:\\Program Files\\MySQL\\MySQL Server 4.1\\bin\\mysql.exe ","mysql  -uroot -ppassword<" + SRCDIR ^ "test.sql",NOWAIT);   
  267.                                                                               
  268.     nResult = XCopyFile(SRCDIR + "\\sql.bat","c:\\xxx\\",EXCLUDE_SUBDIR);      
  269.     nResult = XCopyFile(SRCDIR + "\\init.sql","c:\\xxx\\",EXCLUDE_SUBDIR);       
  270.  //if (LaunchAppAndWait(SRCDIR + "\\sql.bat", " root password",WAIT) < 0) then   
  271.   //MessageBox ("数据库创建失败!请确您的系统中已安装MySQL 4.1.19.\n如仍无法解决,请联系系统供应商!",SEVERE);   
  272.  //endif;             
  273.                                              
  274.  //NumToStr(tmpCheckString,LaunchAppAndWait("c:\\xxx\\sql.bat", " root password",WAIT));                                                               
  275.  //MessageBox(tmpCheckString,SEVERE);       
  276.     
  277.  if (LaunchAppAndWait("c:\\xxx\\sql.bat"" " + svEdit1 + " " + svEdit2 + " ",WAIT) < 0) then   
  278.   MessageBox ("数据库创建失败!请确您的系统中已安装MySQL 4.1.19.\n如仍无法解决,请联系系统供应商!",SEVERE);   
  279.  endif;     
  280.     //DeleteDir("c:\\xxx\\",ALLCONTENTS); //删除这个临时目录            
  281.     DeleteFile("c:\\xxx\\sql.bat");   
  282.     DeleteFile("c:\\xxx\\init.sql");   
  283.       
  284.       
  285.       
  286. Dlg_SdAskDestPath:   
  287.     szTitle = "xxxx系统";   
  288.     szMsg   = "请选择安装目录";   
  289.     nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );   
  290.     TARGETDIR = szDir;                                   
  291.     //if (nResult = BACK) goto Dlg_SdRegisterUserEx;   
  292.     if (nResult = BACK) goto Dlg_SdShowDlgEdit2;   
  293.     
  294. Dlg_SetupType:     
  295.     szTitle    = "xxxx系统";   
  296.     szMsg      =  "请选择安装类型";   
  297.     nResult = SetupType ( szTitle , szMsg , "" , nSetupType , 0 );   
  298.     if (nResult = BACK) then   
  299.         goto Dlg_SdAskDestPath;   
  300.     else  
  301.         nSetupType = nResult;   
  302.         if (nSetupType != CUSTOM) then   
  303.         szTargetPath = TARGETDIR;   
  304.         nvSize = 0;   
  305.         ComponentCompareSizeRequired(MEDIA,szTargetPath,nvSize);   
  306.         if (nvSize != 0) then        
  307.                 MessageBox( szSdStr_NotEnoughSpace, WARNING );   
  308.             goto Dlg_SetupType;   
  309.             endif;   
  310.         endif;     
  311.     endif;   
  312. Dlg_SdComponentTree:   
  313.     if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SetupType;   
  314.     szTitle    = "xxxx系统";   
  315.     szMsg      = "";   
  316.     szTargetdir = TARGETDIR;   
  317.     szComponents = "";   
  318.     nLevel = 2;   
  319.     if (nSetupType = CUSTOM) then   
  320.       nResult = SdComponentTree(szTitle, szMsg, szTargetdir, szComponents, nLevel);   
  321.       if (nResult = BACK) goto Dlg_SetupType;    
  322.     endif;   
  323. Dlg_ObjDialogs:   
  324.     nResult = ShowObjWizardPages(nResult);   
  325.     if (nResult = BACK) goto Dlg_SdComponentTree;   
  326.       
  327. Dlg_SdSelectFolder:   
  328.     szfolder = SHELL_OBJECT_FOLDER;   
  329.     szTitle    = "xxxx系统";   
  330.     szMsg      = "";   
  331.     nResult    = SdSelectFolder( szTitle, szMsg, szfolder );   
  332.     SHELL_OBJECT_FOLDER = szfolder;   
  333.     if (nResult = BACK) goto Dlg_ObjDialogs;   
  334.     
  335. Dlg_SdStartCopy:   
  336.     szTitle = "xxxx系统";   
  337.     szMsg   = "安装信息收集完毕,并且获得安装权限,下一步将进行文件拷贝。";   
  338.     listStartCopy = ListCreate( STRINGLIST );   
  339.     //The following is an example of how to add a string(szName) to a list(listStartCopy).   
  340.     //eg. ListAddString(listStartCopy,szName,AFTER);   
  341.     nResult = SdStartCopy( szTitle, szMsg, listStartCopy );    
  342.     ListDestroy(listStartCopy);   
  343.     if (nResult = BACK) goto Dlg_SdSelectFolder;   
  344.     // setup default status   
  345.     SetStatusWindow(0, "");   
  346.     Enable(STATUSEX);   
  347.     StatusUpdate(ON, 100);   
  348.     return 0;   
  349. end;   
  350. ///////////////////////////////////////////////////////////////////////////////   
  351. //   
  352. //  FUNCTION:   OnMoving   
  353. //   
  354. //  EVENT:      Moving event is sent when file transfer is started as a result of   
  355. //              ComponentTransferData call, before any file transfer operations   
  356. //              are performed.   
  357. //   
  358. ///////////////////////////////////////////////////////////////////////////////   
  359. function OnMoving()   
  360.     string szAppPath;   
  361. begin   
  362.     // Set LOGO Compliance Application Path   
  363.     // TO DO : if your application .exe is in a subfolder of TARGETDIR then add subfolder   
  364.     szAppPath = TARGETDIR;   
  365.     RegDBSetItem(REGDB_APPPATH, szAppPath);   
  366.     RegDBSetItem(REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY);   
  367. end;   
  368. // --- include script file section ---   
  369. function OnEnd()                                       
  370. // //string  java_home, catalina_home, szKey, szEnv;   
  371. // string  szKey, szEnv, svClassPath;         
  372. // string icon_dir, xml_dir,output_dir;   
  373. // number nRegSize;   
  374. // pointer pEnv;   
  375. begin                 
  376. //          
  377. //   //catalina_home=TARGETDIR + "\\tomcat5.0.30";   
  378. //   //java_home=TARGETDIR + "\\j2sdk1.4.2_10";      
  379. //   szKey="Environment";   
  380. //   RegDBSetDefaultRoot(HKEY_CURRENT_USER);      
  381. //   //RegDBSetKeyValueEx(szKey,"JAVA_HOME",REGDB_STRING,java_home,-1);   
  382. //   //RegDBSetKeyValueEx(szKey,"CATALINA_HOME",REGDB_STRING,catalina_home,-1);   
  383. //     
  384. //   //RegDBSetKeyValueEx(szKey,"CLASSPATH",REGDB_STRING,svClassPath,nRegSize);      
  385. //   GetEnvVar ("CLASSPATH", svClassPath);   
  386. //   //MessageBox(svClassPath,0);   
  387. //   svClassPath = svClassPath + "; " + "c:\\xxx\\resc";       
  388. //   //MessageBox(svClassPath,0);   
  389. //   RegDBSetKeyValueEx(szKey,"CLASSPATH",REGDB_STRING,svClassPath,-1)   ;   
  390. //   szEnv = "Environment";   
  391. //   pEnv = &szEnv;    
  392. //   //pEnv = AddressString(szEnv);     
  393. //   SendMessage(0xffff, 0x001A , 0, pEnv );   
  394. //     
  395. //   //MessageBox("sssss",0);     
  396.   
  397.                                                   
  398.    XCopyFile(SRCDIR ^ "xxx\\icons\\media\\*.gif",TARGETDIR,EXCLUDE_SUBDIR);    
  399.    XCopyFile(SRCDIR ^ "xxx\\icons\\teacher\\*.jpg",TARGETDIR,EXCLUDE_SUBDIR);     
  400.    CreateDir(TARGETDIR ^ "resc\\");      
  401. end;   
  402.     
  403.     
  404.     
  405.     
  406.     
  407.     
  408.     
  409. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   
  410. ////////////////////////////////////////////////////////////////下面是一些设定tomcat或者jdk的环境变量的代码/////////////非本系统/////////////////   
  411. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   
  412. function OnEnd()       
  413. string  java_home, catalina_home, szKey, szEnv;         
  414. string icon_dir, xml_dir,output_dir;   
  415. POINTER pEnv;   
  416. begin                 
  417.   catalina_home=TARGETDIR + "\\tomcat5.0.30";   
  418.   java_home=TARGETDIR + "\\j2sdk1.4.2_10";      
  419.   szKey="Environment";   
  420.   RegDBSetDefaultRoot(HKEY_CURRENT_USER);      
  421.   RegDBSetKeyValueEx(szKey,"JAVA_HOME",REGDB_STRING,java_home,-1);   
  422.   RegDBSetKeyValueEx(szKey,"CATALINA_HOME",REGDB_STRING,catalina_home,-1);   
  423.   szEnv = "Environment";   
  424.   pEnv = &szEnv;   
  425.   SendMessage (0xffff, 0x001A , 0, pEnv );   
  426.     
  427.     
  428.     
  429.    

 

 

 对应的 vb 注册码解码的核心程序(KeyGen.frm)如下:

 

 

C代码 复制代码
  1. VERSION 5.00   
  2. Begin VB.Form keyGen    
  3.    Appearance      =   0  'Flat   
  4.    BackColor       =   &H80000001&   
  5.    BorderStyle     =   5  'Sizable ToolWindow   
  6.    Caption         =   "**系统注册码生成器"  
  7.    ClientHeight    =   1290   
  8.    ClientLeft      =   60   
  9.    ClientTop       =   330   
  10.    ClientWidth     =   4545   
  11.    DrawMode        =   1  'Blackness   
  12.    FillStyle       =   0  'Solid   
  13.    LinkTopic       =   "Form1"  
  14.    MaxButton       =   0   'False   
  15.    MinButton       =   0   'False   
  16.    OLEDropMode     =   1  'Manual   
  17.    ScaleHeight     =   1290   
  18.    ScaleMode       =   0  'User   
  19.    ScaleWidth      =   4545   
  20.    ShowInTaskbar   =   0   'False   
  21.    StartUpPosition =   1  '所有者中心   
  22.    Begin VB.CommandButton genButton    
  23.       Appearance      =   0  'Flat   
  24.       BackColor       =   &H80000001&   
  25.       Caption         =   "生成"  
  26.       Height          =   300   
  27.       Left            =   3480   
  28.       MaskColor       =   &H80000001&   
  29.       Style           =   1  'Graphical   
  30.       TabIndex        =   4   
  31.       Top             =   240   
  32.       UseMaskColor    =   -1  'True   
  33.       Width           =   615   
  34.    End   
  35.    Begin VB.TextBox snText    
  36.       Appearance      =   0  'Flat   
  37.       BackColor       =   &H80000001&   
  38.       Height          =   300   
  39.       Left            =   960   
  40.       Locked          =   -1  'True   
  41.       TabIndex        =   3   
  42.       Top             =   720   
  43.       Width           =   3135   
  44.    End   
  45.    Begin VB.TextBox machineText    
  46.       Appearance      =   0  'Flat   
  47.       BackColor       =   &H80000001&   
  48.       Height          =   300   
  49.       Left            =   960   
  50.       TabIndex        =   2   
  51.       Top             =   240   
  52.       Width           =   2295   
  53.    End   
  54.    Begin VB.Label snLabel    
  55.       Alignment       =   2  'Center   
  56.       Appearance      =   0  'Flat   
  57.       BackColor       =   &H80000001&   
  58.       BackStyle       =   0  'Transparent   
  59.       Caption         =   "注册码"  
  60.       ForeColor       =   &H80000008&   
  61.       Height          =   255   
  62.       Left            =   240   
  63.       TabIndex        =   1   
  64.       Top             =   840   
  65.       Width           =   735   
  66.    End   
  67.    Begin VB.Label machineLabel    
  68.       Alignment       =   2  'Center   
  69.       Appearance      =   0  'Flat   
  70.       BackColor       =   &H80000001&   
  71.       BackStyle       =   0  'Transparent   
  72.       Caption         =   "机器码"  
  73.       ForeColor       =   &H80000008&   
  74.       Height          =   255   
  75.       Left            =   240   
  76.       TabIndex        =   0   
  77.       Top             =   360   
  78.       Width           =   735   
  79.       WordWrap        =   -1  'True   
  80.    End   
  81. End   
  82. Attribute VB_Name = "keyGen"  
  83. Attribute VB_GlobalNameSpace = False   
  84. Attribute VB_Creatable = False   
  85. Attribute VB_PredeclaredId = True   
  86. Attribute VB_Exposed = False   
  87.   
  88.   
  89. Private Sub genButton_Click()   
  90.     Dim distNum As Double   
  91.     Dim intTmp As Double   
  92.     Dim mid As Long   
  93.     Dim strSN As String   
  94.        
  95.        
  96.     If (VBA.Trim(machineText) <> "") Then   
  97.         If (IsNumeric(VBA.Trim(machineText)) And VBA.Trim(machineText) > 135792468 And VBA.Trim(machineText) < 2139999999) Then   
  98.             distNum = machineText   
  99.         Else   
  100.             distNum = 123456789 + 135792468   
  101.         End If   
  102.         distNum = distNum - 135792468   
  103.            
  104.            
  105.         strSN = "B"  
  106.         intTmp = distNum   
  107.         mid = intTmp - Fix(intTmp / 100) * 100   
  108.         If mid = 0 Then   
  109.             strSN = strSN + "0X"  
  110.         Else   
  111.             strSN = strSN + VBA.Trim(Str(mid))   
  112.         End If   
  113.         strSN = strSN + "_"  
  114.            
  115.            
  116.         strSN = strSN + "K"  
  117.         intTmp = Fix(intTmp / 100)   
  118.         mid = intTmp - Fix(intTmp / 100) * 100   
  119.         If mid = 0 Then   
  120.             strSN = strSN + "0X"  
  121.         Else   
  122.             strSN = strSN + VBA.Trim(Str(mid))   
  123.         End If   
  124.         strSN = strSN + "_"  
  125.            
  126.            
  127.         strSN = strSN + "X"  
  128.         intTmp = Fix(intTmp / 100)   
  129.         mid = intTmp - Fix(intTmp / 100) * 100   
  130.         If mid = 0 Then   
  131.             strSN = strSN + "0X"  
  132.         Else   
  133.             strSN = strSN + VBA.Trim(Str(mid))   
  134.         End If   
  135.         strSN = strSN + "_"  
  136.            
  137.            
  138.         strSN = strSN + "T"  
  139.         intTmp = Fix(intTmp / 100)   
  140.         mid = intTmp - Fix(intTmp / 100) * 100   
  141.         If mid = 0 Then   
  142.             strSN = strSN + "0X"  
  143.         Else   
  144.             strSN = strSN + VBA.Trim(Str(mid))   
  145.         End If   
  146.            
  147.         snText = strSN   
  148.            
  149.     End If   
  150. End Sub  

 


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理