打印本文 打印本文 关闭窗口 关闭窗口
VB代码之禁止使用Alt+F4关闭窗口及软件的使用限制(次数、天数)
作者:武汉SEO闵涛  文章来源:敏韬学习网  点击数1090  更新时间:2010/6/23 22:57:27  文章录入:mintao  责任编辑:mintao

  一、禁止使用Alt+F4关闭窗口代码

  Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
  Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Const MF_BYPOSITION = &H400&

  Private Sub Form_Load()
  Dim hwndMenu As Long
  Dim c As Long
  hwndMenu = GetSystemMenu(Me.hwnd, 0)

  c = GetMenuItemCount(hwndMenu)

  DeleteMenu hwndMenu, c - 1, MF_BYPOSITION

  c = GetMenuItemCount(hwndMenu)
  DeleteMenu hwndMenu, c - 1, MF_BYPOSITION
  End Sub

  二、限制软件的使用次数

  ①限制使用60次

  Private Sub Form_Load()
  Dim RemainDay As Long
  RemainDay = GetSetting("MyApp", "set", "times", 0)
  If RemainDay = 60 Then
     MsgBox "试用次数已满,请购买正版"
     Unload Me
  End If
  MsgBox "现在剩下:" & 60 - RemainDay & "的试用次数,请阁下珍惜!"
  RemainDay = RemainDay + 1
  SaveSetting "MyApp", "set", "times", RemainDay
  End Sub

  ②限制使用60天

  Private Sub Form_Load()
  Dim RemainDay As Long
  RemainDay = GetSetting("MyApp", "set", "day", 0)
  If RemainDay = 60 Then
      MsgBox "试用期已过,请购买正版"
      Unload Me
  End If
  MsgBox "现在还剩下:" & 60 - RemainDay & "的试用天数,请阁下珍惜!"
  if day(now)-remainday>0 then RemainDay = RemainDay + 1
  SaveSetting "MyApp", "set", "times", RemainDay
  End Sub

打印本文 打印本文 关闭窗口 关闭窗口