Kamis, 19 Januari 2012

Membuat Teks di Layar di VB dan VB.NET

Buat Project baru dengan sebuah Form didalamnya, lalu ketikkan kode berikut di bagian '(Declarations)' dari Form :
[ VB 6.0 ]
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long


[ VB .NET ]

Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Integer) As Integer
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Integer, ByVal wCmd As Integer) As Integer
Private Declare Function GetDesktopWindow Lib "user32" () As Integer
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Integer) As Integer
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Integer)
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer, ByVal lpString As String, ByVal nCount As Integer) As Integer


Dan di bagian 'Form_Load' ketikkan :
Const s = "Virus Layar Aneh"
Do
d = GetWindowDC(GetWindow(GetDesktopWindow(), 1))
Randomize
TextOut d, Rnd * GetSystemMetrics(0), Rnd * GetSystemMetrics(1), s, Len(s)
Sleep 300
Loop
Jadikan / compile Project menjadi file *.exe


sumber : link

Tidak ada komentar:

Posting Komentar