注册 登录
编程论坛 VB6论坛

【原创】VB6伪造显示器损坏

yuma 发布于 2023-02-10 10:48, 860 次点击
无聊写了以下程序,有更好的线条画法,请下方留言。

窗体拖入控件:Timer1 执行以下代码:

程序代码:
Option Explicit
'窗体透明,控件不透明
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Const WS_EX_LAYERED = &H80000
Const GWL_EXSTYLE = (-20)
Const LWA_COLORKEY = &H1
'窗体置顶
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)


Private Sub Form_Load()
Dim i As Long, j As Long
If App.PrevInstance = True Then End '如果重复进程,则退出
Form1.AutoRedraw = True
Form1.ScaleMode = vbPixels
Form1.DrawWidth = 1.45

'窗体全屏
Me.BorderStyle = False
Me.Caption = ""
Me.Move 0, 0, Screen.Width, Screen.Height

'窗体透明
BackColor = &HFEFEFE
SetWindowLong hwnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes hwnd, &HFEFEFE, 0, LWA_COLORKEY '这里的 0 表示透明度

'绘制线条
For i = Form1.ScaleWidth / 3 To Form1.ScaleWidth / 3 + 6 Step 2
Form1.Line (Form1.ScaleWidth / 3 + i, 0)-(Form1.ScaleWidth / 3 + i, Form1.Height), Int(16581375 * Rnd + 0)
Next

For j = Form1.ScaleWidth / 3 + 10 To Form1.ScaleWidth / 3 + 16 Step 2
Form1.Line (Form1.ScaleWidth / 3 + j, 0)-(Form1.ScaleWidth / 3 + j, Form1.Height), Int(16581375 * Rnd + 0)
Next

Timer1.Interval = 1000

End Sub
Private Sub Timer1_Timer()
'让窗体在顶层
Dim rtn
rtn = SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
End Sub
0 回复
1