大众计算机学习网欢迎诸位!收藏本站注 册登 陆
常用教程:基础知识网络知识操作系统WPS网页制作数据库算法网页成功之路网络安全最新技术古典mid流行midmid背景下载中心
您现在的位置:首页 > 教程 > 文章页

VB代码之禁止使用Alt+F4关闭窗口及软件的使用限制(次数、天数)

Admin | 2009-5-5 13:06:31 | ReadNums | 5650 | 标签 asp.net | 打印本页
     

  一、禁止使用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


问题未解决:在线咨询

网友评论

(访客)
内容实用原创,讲得很好。
20xx年x月x日
(站长)
有问题请在线咨询。
20xx年x月x日