转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> VB.NET程序 >> 正文
小弟为共享软件作者制作的管理软件注册的动态链接库         ★★★★

小弟为共享软件作者制作的管理软件注册的动态链接库

作者:闵涛 文章来源:闵涛的学习笔记 点击数:2689 更新时间:2009/4/23 18:58:51
nbsp;  Set FSOString = FSOFile.OpenAsTextStream(ForWriting, TristateFalse)

  Else

   Set FSOString = FSO.CreateTextFile(App.Path & "Value.dat", True, False)

  End If

 Else

  If FSO.FileExists(App.Path & "\Value.dat") Then

   Set FSOFile = FSO.GetFile(App.Path & "\Value.dat")

   Set FSOString = FSOFile.OpenAsTextStream(ForWriting, TristateFalse)

  Else

   Set FSOString = FSO.CreateTextFile(App.Path & "\Value.dat", True, False)

  End If

 End If

 For nCount = 1 To 1024

  FSOString.Write (Mid(sTarget, Int(56 * Rnd + 1), 1))

 Next

 

 lReturn = RegCloseKey(hEditKey)

 

 Erase baRandom

 

 Set FSO = Nothing

 Set FSOFile = Nothing

 Set FSOString = Nothing

 Close #hFileNumber

 

End Sub

 

 

Private Function KeyCheck(ForCheckName As String, ForCheckPassword As String) As Boolean

''''接收两个从注册表中读出的字符串Name和Password

 

''''如果注册表中没有Name和Password键值则此二值为空,以下检测该字符串第一个字符是否在sTarget中

 If InStr(1, sTarget, Left(ForCheckName, 1), vbTextCompare) = 0 Or InStr(1, sTarget, Left(ForCheckPassword, 1), vbTextCompare) = 0 Then

  KeyCheck = False

  Exit Function

 End If

 

''''调用CalculateNamePassword,返回合法的Name及Password

''''返回值的形式为Name%Password

 

 Dim sTotal As String

 sTotal = CalculateNamePassword

 Dim sCalName As String

 Dim sCalPassword As String

 sCalName = Left(sTotal, 8)

 sCalPassword = Right(sTotal, 25)

 

''''检测是否符合

 For nCount = 1 To 8

  If Mid(ForCheckName, nCount, 1) <> Mid(sCalName, nCount, 1) Then

   KeyCheck = False

   Exit Function

  End If

 Next

 

 For nCount = 1 To 25

  If Mid(ForCheckPassword, nCount, 1) <> Mid(sCalPassword, nCount, 1) Then

   KeyCheck = False

   Exit Function

  End If

 Next

 

 KeyCheck = True

 

End Function

 

Public Property Get Regested() As Variant                  ''''是否注册的只读属性

 Regested = m_Regested

End Property

 

Public Property Get RegestKey() As String                  ''''客户应用程序在注册表中的注册键

 RegestKey = m_RegestKey

End Property

 

Public Property Let RegestKey(ByVal vNewValue As String)

 m_RegestKey = vNewValue

End Property

 

Private Function CalculateNamePassword() As String         ''''用来以Name%Password格式返回

                                                           ''''合法用户名及密码的私有方法

''''如果Value.dat不存在,则立即退出

 Set FSO = CreateObject("Scripting.FileSystemObject")

 If Right(App.Path, 1) = "\" Then

  If FSO.FileExists(App.Path & "Value.dat") = False Then

   CalculateNamePassword = ""

   Set FSO = Nothing

   Exit Function

  End If

 Else

  If FSO.FileExists(App.Path & "\Value.dat") = False Then

   CalculateNamePassword = ""

   Set FSO = Nothing

   Exit Function

  End If

 End If

 

 Dim sCalculateName As String        ''''合法的用户名

 Dim sCalculatePassword As String    ''''合法的密码

 sCalculateName = ""

 sCalculatePassword = ""

 

 Dim hFileNumberKey As Integer       ''''打开两个文件Key.dat和Value.dat

 hFileNumberKey = FreeFile

 If Right(App.Path, 1) = "\" Then

  Open App.Path & "Key.dat" For Binary As hFileNumberKey

 Else

  Open App.Path & "\Key.dat" For Binary As hFileNumberKey

 End If

 Dim hFileNumberValue As Integer

 hFileNumberValue = FreeFile

 If Right(App.Path, 1) = "\" Then

  Open App.Path & "Value.dat" For Binary As hFileNumberValue

 Else

  Open App.Path & "\Value.dat" For Binary As hFileNumberValue

 End If

 

 Dim bFirst As Byte

 Dim bSecond As Byte

 Dim bLength As Byte

 Dim bFF As Byte

 Dim bCode As Byte

 Dim iPasswordStart As Integer

 Dim iLength As Integer

 For nCount = 1 To 24 Step 3

  Get #hFileNumberKey, nCount, bFF

  If bFF <> &HFF Then

   Get #hFileNumberKey, nCount, bFirst

   Get #hFileNumberKey, nCount + 1, bSecond

   Get #hFileNumberKey, nCount + 2, bLength

   For iLength = 1 To CInt(bLength)

    Get #hFileNumberValue, CInt(bFirst) ^ 2 + CInt(bSecond) + iLength - 1, bCode

    sCalculateName = sCalculateName & Chr(bCode)

   Next

  Else

   iPasswordStart = nCount

   Exit For

  End If

 Next

 For nCount = iPasswordStart + 1 To 100 Step 3

  Get #hFileNumberKey, nCount, bFirst

  Get #hFileNumberKey, nCount + 1, bSecond

  Get #hFileNumberKey, nCount + 2, bLength

  For iLength = 1 To CInt(bLength)

   Get #hFileNumberValue, CInt(bFirst) ^ 2 + CInt(bSecond) + iLength - 1, bCode

   sCalculatePassword = sCalculatePassword & Chr(bCode)

   If Len(sCalculatePassword) = 25 Then

    nCount = 100

    Exit For

   End If

  Next

 Next

 

 CalculateNamePassword = sCalculateName & "%" & sCalculatePassword

 

 Set FSO = Nothing

 Close #hFileNumberKey

 Close #hFileNumberValue

 

End Function

 

Public Property Get RegestName() As String         ''''只读用户名属性

 RegestName = m_Name

End Property

 

Public Property Get RegestPassword() As String     ''''只读密码属性

上一页  [1] [2] [3]  下一页


没有相关教程
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · C语言系列  · VB.NET程序
    · JAVA开发  · Delphi程序
    · 脚本语言
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台