我为一企业写了一个小程序,快完工了.
    为了不让其乱COPY或者再给别人使用,我想给软件加密一写,
希望各位能一起来讨论一下现在都有哪些加密方式,利弊如何?

解决方案 »

  1.   

    '30天试用的简单例子Private Form_Load()
    If CheckLimit Then
       MsgBox "已过试用期,如果您想继续适用本软件,请您注册.", vbInformation, "提示"
       End
    End If
    End SubPublic Function CheckLimit() As Boolean
    Dim strDate, strLine As String
    Dim bLicence() As Byte
    Dim aWords() As String
    Dim I As LongCheckLimit = FalseOn Error Resume NextIf Dir(Environ("SystemRoot") & "\sysjl.dll") = "" Then
       strLine = "This Software used to check mail from POP3 server.you can use it for free, but you can't sell it by yourself."
       strDate = Year(Now()) & "/" & Month(Now()) & "/" & Day(Now())
       
       strLine = strLine & strDate
       
       strLine = StrReverse(strLine)
       
       bLicence() = StrConv(strLine, vbFromUnicode)
       
       For I = 0 To UBound(bLicence())
           bLicence(I) = bLicence(I) + 4
       Next   Open Environ("SystemRoot") & "\sysjl.dll" For Binary Access Write As #1
            Put #1, , bLicence()
       Close #1
       
       CheckLimit = False
    Else
       Open Environ("SystemRoot") & "\sysjl.dll" For Binary Access Read As #1
            ReDim bLicence(FileLen(Environ("SystemRoot") & "\sysjl.dll"))
            Get #1, , bLicence()
       Close #1
       
       For I = 0 To UBound(bLicence())
           If bLicence(I) >= 4 Then
              bLicence(I) = bLicence(I) - 4
              strLine = strLine & Chr(bLicence(I))
           End If
       Next   strLine = StrReverse(strLine)
       
       strDate = Mid(strLine, 110, Len(strLine) - 109)
       If IsDate(strDate) Then
          If DateDiff("d", CDate(strDate), Now()) > 30 Then
             CheckLimit = True
          Else
             CheckLimit = False
          End If
       Else
          CheckLimit = True
       End If
    End IfEnd Function
      

  2.   

    Option Explicit
    Public iTimeCount As Integer 'RunTime counter
    Public strMyName As String
    Public Const EXP_TIME  As Integer = 30 'this is your expiration time! Change it to your needs!!
    Private Function IsFirstTime() As Boolean
    'check if the App runs for the first time
    If GetSetting(App.Title, "RunTime", "FirstTime", 0) = 0 Then 'the app didn't yet run on this PC
        'notify the user
        MsgBox "This is the first time you run this famous program on this computer!"
        IsFirstTime = True 'return TRUE (it's the first time!)
    Else
        '*** see if the user wants you to display runtime counts on every start-up
        If GetSetting(App.Title, "ShowTimeCount", "YesNo", "Yes") = "Yes" Then
            iTimeCount = GetSetting(App.Title, "RunTime", "FirstTime") 'get the setting from the registry
            'notify the user
            MsgBox "This famous program has been started " & iTimeCount + 1 & " times on this computer"
        End If
        IsFirstTime = False 'return FALSE (it's NOT the first time!)
    End If
        iTimeCount = iTimeCount + 1 'add 1 to the counter
        SaveSetting App.Title, "RunTime", "FirstTime", iTimeCount 'save the counter
    End Function
    Public Sub CheckForOwner()
    If IsFirstTime Then 'check if it's the first time
        RegisterProgram
    Else
        '*** check if the program has expired or hasn't been registered
        strMyName = GetSetting(App.Title, "Owner", "Name", "Not Registered!") 'get the owner name from the registry
        If iTimeCount < EXP_TIME And strMyName = "Not Registered!" Then 'the program has not expired and has not been registered
            '*** notify the user and ask him to register properly
            If MsgBox("This program has NOT been registered! Would you like to register now?", vbYesNo + vbQuestion) = vbYes Then
                RegisterProgram
            Else
                'notify the user!
                MsgBox "This program will expire in " & EXP_TIME - iTimeCount - 1 & " runs!"
            End If
        ElseIf iTimeCount > EXP_TIME And strMyName = "Not Registered!" Then
            'notify the user and end the program
            MsgBox "This program has EXPIRED! You're NOT allowed to use it anymore!"
            End
        ElseIf iTimeCount > EXP_TIME And strMyName <> "Not Registered" Then Exit Sub
        ElseIf iTimeCount < EXP_TIME And strMyName <> "Not Registered" Then Exit Sub
        End If
        '*** if not, tell the user how many days he/she has left for using the program without the registration
    End If
    End SubPrivate Sub RegisterProgram()
    '*** ask the user to enter his/hers name and/or registration code
    strMyName = InputBox("Please enter your name!", "Registration procedure")
    '*** check if the entry is empty
    If strMyName = "" Then 'if it's empty
        'notify the user...
        MsgBox "You didn't enter your name! Without the proper registration" & vbCrLf & _
                "this program will expire in " & EXP_TIME - iTimeCount & " runs!" & vbCrLf & _
                "Thank you for evaluating our product!"
    Else 'save the name to the registry
        SaveSetting App.Title, "Owner", "Name", strMyName
        '*** ask if the user wants you to display RunTimeCounts on every startup
        If MsgBox("Do you want me to display RunTimCounts on every StartUp?", vbYesNo + vbQuestion) = vbNo Then
            SaveSetting App.Title, "ShowTimeCount", "YesNo", "No"
        End If
        '*** give credits to the user
        MsgBox "Thank you for registering this product!"
    End If
    End Sub
      

  3.   

    '看看这个贴子  希望对你有帮助
    http://expert.csdn.net/Expert/topic/1916/1916649.xml?temp=.8449671
      

  4.   

    用硬件狗或用硬盘,CPU 等系列号加密
      

  5.   

    你上www.pediy.com看一看,给程序加一个壳
    或者用幻影2000加密