⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ba64.htm

📁 VB教程
💻 HTM
字号:
<HTML>
<HEAD>
<TITLE>用VB给商品软件加密的方法</TITLE>
 
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
 
</head>
<p align="center"><script src="../../1.js"></script></a>
<BODY topMargin=4 vLink=#0000ff>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
  <TBODY>
  <TR>
    <TD height="52"> 
      <DIV align=center>
      <CENTER>
          <table border=0 cellpadding=0 cellspacing=0 width=679 align="center">
            <tbody> 
            <tr> 
              <td width=200 height="59"> 
                 
    </TD></TR><!--msnavigation--></TBODY></TABLE>
<table border=0 cellpadding=0 cellspacing=0 width="100%">
  <tbody> 
  <tr><!--msnavigation--><td valign=top height="123"> 
      <div align=center> 
        <table border=1 bordercolor=#b9d9ff cellpadding=0 cellspacing=0 
      class=table width=755>
          <center>
            <tr> 
               
              <td width="100%" height="3">
                <div align="center"> <strong><b>用VB给商品软件加密的方法</b> </strong></span></div>
              </td>
            </tr>
            <tr> 
              <td 
            width="100%" class="unnamed1" height="124"> 
                <div align="left">
                  <p align="center">&nbsp;</p>
                  <p align="center">   <font size="-1">近几年来,笔者参与了几个商品软件的开发设计,其中如何加密软件确是个值得研究的课题,而对于小软件来说,采用加密狗进行加密是很不经济的。为此,笔者想出一妙法,在程序里完成对软件加密,这样既方便又经济,现介绍如下,望能与大家一起分享。 
                    </font></font></p>
                  <p>   <b>设计原理:</b> </font></p>
                  <p>   软件加密的目的是为了防止盗用者拷贝软件,一般拷贝软件时,只会拷贝程序所在的目录的内容,根本不会想到其他目录里还会有与程序有关的文件,特别是文件放在\WINDOWS\SYSTEM目录里,更是无从下手。这样,我们设计了两个文件,一明一暗,明的放在程序所在的目录,命名为mscredit.ini,其内容为: 
                    </font></p>
                  <p>   @-version=2.0-1999-copyright-@ 
                    </font></p>
                  <p>   安装软件时,应先删除mscredit.ini左边的“@”,程序自动创建c:\windows\system\dbcredit.ini文件,并在mscredit.ini里再写入左边的“@”符号,以后每次使用软件时,检查隐藏的c:\windows\system\dbcredit.ini文件是否存在,只有此文件存在时软件才能正常运行。此设计关键在于,这一明一暗两个文件同时存在,程序才能正常运行。 
                    </font></p>
                  <p>   <b>主程序</b> </font></p>
                  <p> <br>
                    Private Sub Form_Load()<br>
                    Dim kk, ms As String, vt As Integer<br>
                    ’若mscredit.ini因误操作删除,则软件不能正常运行<br>
                    If Dir(App.Path &amp; &quot;\mscredit.ini&quot;) = &quot;&quot; 
                    Then<br>
                    kk = MsgBox(&quot;本软件已不能正常运行,<br>
                    请检查软件的合法性!&quot;, vbInformation, &quot; 提示&quot;)<br>
                    Exit Sub<br>
                    End If<br>
                    ’若mscredit.ini因误操作删除其内容,<br>
                    则软件不能正常运行<br>
                    Open App.Path &amp; &quot;\mscredit.ini&quot; For Input As 
                    #1<br>
                    Input #1, ms<br>
                    Close #1<br>
                    ms = Trim(ms)<br>
                    If ms = &quot;&quot; Then<br>
                    kk = MsgBox(&quot;本软件已不能正常运行,<br>
                    请检查软件的合法性!&quot;, vbInformation, &quot;提示&quot;)<br>
                    Exit Sub<br>
                    End If<br>
                    If Left(ms, 1) &lt; &gt; &quot;@&quot; Then<br>
                    ’安装使用本软件,自动创建dbcredit.ini文件,<br>
                    并在mscredit.ini里写入“@”符号<br>
                    vt = write_sys_init(&quot;CopyRight&quot;, &quot;Version&quot;, 
                    &quot;2.0&quot;)<br>
                    Open App.Path &amp; &quot;\mscredit.ini&quot; For Output As 
                    #1<br>
                    ms = &quot;@&quot; &amp; ms<br>
                    Print #1, ms<br>
                    Close #1<br>
                    Else<br>
                    ’使用本软件,若dbcredit.ini因误操作<br>
                    删除其内容,则软件不能正常运行<br>
                    If Dir(&quot;c:\windows\system\dbcredit.ini&quot;) = &quot;&quot; 
                    Then<br>
                    kk = MsgBox(&quot;本软件已不能正常运行,<br>
                    请检查软件的合法性!&quot;, vbInformation, &quot;提示&quot;)<br>
                    On Error Resume Next<br>
                    Kill App.EXEName<br>
                    On Error GoTo 0<br>
                    Exit Sub<br>
                    End If<br>
                    End If<br>
                    End Sub<br>
                    <br>
                    调用函数<br>
                    Public Function write_sys_init<br>
                    (gs As String, ss As String, sval As String) <br>
                    As Integer<br>
                    Dim retv as String<br>
                    write_sys_init = 0<br>
                    On Error Resume Next<br>
                    retv=OSWritePrivateProfileString<br>
                    (gs,ss,sval,&quot;c:\windows\system\mscredit.ini&quot;)<br>
                    If Err Then<br>
                    Err = 0<br>
                    write_sys_ini = -1<br>
                    End If<br>
                    On Error GoTo 0<br>
                    End Function<br>
                    </font></p>
                  <p>   本程序在VB5.0、WIN95下调试通过。 </font></p>
                      </div>
              </td>
            </tr>
          </center>
          <tr> 
            <td width="100%" class="unnamed1"> 
              <p align=right><a href="ba63.htm">(上一页)</a>---<a href="ba65.htm">(下一页)</a></p>
            </td>
          </tr>
          <tr> 
            <td width="100%" class="unnamed1"> 
               
    </div>
      </td>
  </tr>
  <!--msnavigation--></tbody>
</table>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -