Dzwebs.Net

撰写电脑技术杂文十余年

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

Admin | 2009-5-5 13:06:31 | 被阅次数 | 8737

温馨提示!

如果未能解决您的问题,请点击搜索;登陆可复制文章,点击登陆

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


该杂文来自: 网站开发杂文

上一篇:详细介绍VB各种对话框的参数、分类及定制

下一篇:VB调用“打开文件”对话框的代码

网站备案号:

网站备案号:滇ICP备11001339号-7

版权属性:

Copyright 2007-2021-forever Inc. all Rights Reserved.

联系方式:

Email:dzwebs@126.com QQ:83539231 访问统计