Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Security.Cryptography
- Imports System.IO
- Imports System.Text
- Imports System.Windows.Forms
- Imports System.Drawing
- Imports System.Threading
- Public Class Class1
- Shared Function NameBackWards(ByVal Name As String) As String
- Dim BackWards As String = ""
- For x As Integer = Name.Length - 1 To 0 Step -1
- BackWards = BackWards & Name.Chars(x)
- Next
- Return BackWards
- End Function
- Shared Function ConvertToBinary(ByVal str As String) As String
- Dim converted As New StringBuilder
- For Each b As Byte In ASCIIEncoding.ASCII.GetBytes(str)
- converted.Append(Convert.ToString(b, 2).PadLeft(8, "0"))
- Next
- Return converted.ToString()
- End Function
- Shared Function StringToMD5(ByVal Content As String) As String
- Dim M5 As New Security.Cryptography.MD5CryptoServiceProvider
- Dim ByteString() As Byte = System.Text.Encoding.ASCII.GetBytes(Content)
- ByteString = M5.ComputeHash(ByteString)
- Dim FinalString As String = Nothing
- For Each bt As Byte In ByteString
- FinalString &= bt.ToString("x2")
- Next
- Return FinalString
- End Function
- Shared Function MD5CalcFile(ByVal filepath As String) As String
- Using reader As New System.IO.FileStream(filepath, IO.FileMode.Open, IO.FileAccess.Read)
- Using md5 As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim hash() As Byte = md5.ComputeHash(reader)
- Return ByteArrayToString(hash)
- End Using
- End Using
- End Function
- Shared Function ByteArrayToString(ByVal arrInput() As Byte) As String
- Dim sb As New System.Text.StringBuilder(arrInput.Length * 2)
- For i As Integer = 0 To arrInput.Length - 1
- sb.Append(arrInput(i).ToString("X2"))
- Next
- Return sb.ToString().ToLower
- End Function
- Shared Function AES_Encrypt(ByVal input As String, ByVal pass As String) As String
- Dim AES As New System.Security.Cryptography.RijndaelManaged
- Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim encrypted As String = ""
- Try
- Dim hash(31) As Byte
- Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- Array.Copy(temp, 0, hash, 0, 16)
- Array.Copy(temp, 0, hash, 15, 16)
- AES.Key = hash
- AES.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor
- Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input)
- encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return encrypted
- Catch ex As Exception
- End Try
- End Function
- Shared Function AES_Decrypt(ByVal input As String, ByVal pass As String) As String
- Dim AES As New System.Security.Cryptography.RijndaelManaged
- Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider
- Dim decrypted As String = ""
- Try
- Dim hash(31) As Byte
- Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass))
- Array.Copy(temp, 0, hash, 0, 16)
- Array.Copy(temp, 0, hash, 15, 16)
- AES.Key = hash
- AES.Mode = Security.Cryptography.CipherMode.ECB
- Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateDecryptor
- Dim Buffer As Byte() = Convert.FromBase64String(input)
- decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length))
- Return decrypted
- Catch ex As Exception
- End Try
- End Function
- End Class
- Public Class IR_MessageBox
- #Region " Iridium properties "
- Public Property ForeColor() As Color
- Get
- Return mudtForeColor
- End Get
- Set(ByVal Value As Color)
- mudtForeColor = Value
- End Set
- End Property
- Private mudtForeColor As Color
- Public Property BackColor() As Color
- Get
- Return mudtForeColor
- End Get
- Set(ByVal Value As Color)
- mudtBackColor = Value
- End Set
- End Property
- Private mudtBackColor As Color
- Public Property MessageTitle() As String
- Get
- Return mstrTitle
- End Get
- Set(ByVal Value As String)
- mstrTitle = Value
- End Set
- End Property
- Private mstrTitle As String = ""
- Public Property MessageLocation() As Point
- Get
- Return New Point(mintX, mintY)
- End Get
- Set(ByVal Value As Point)
- With Value
- mintX = .X
- mintY = .Y
- End With
- End Set
- End Property
- Private mintX As Int32
- Private mintY As Int32
- Public Property MessagePauseSeconds() As Int32
- Get
- Return mintPause
- End Get
- Set(ByVal Value As Int32)
- mintPause = Value
- mintPauseMili = Value * 1000
- End Set
- End Property
- Private mintPause As Int32
- Private mintPauseMili As Int32
- Public Property MessageButtons() As MessageBoxButtons
- Get
- Return mudtButtons
- End Get
- Set(ByVal Value As MessageBoxButtons)
- mudtButtons = Value
- End Set
- End Property
- Private mudtButtons As MessageBoxButtons
- Public Property MessagePrompt() As String
- Get
- Return mstrPrompt
- End Get
- Set(ByVal Value As String)
- mstrPrompt = Value
- End Set
- End Property
- Private mstrPrompt As String = ""
- Public Property MessageCheckboxText() As String
- Get
- Return mstrCheckboxText
- End Get
- Set(ByVal Value As String)
- mstrCheckboxText = Value
- End Set
- End Property
- Private mstrCheckboxText As String = ""
- Public WriteOnly Property MessageButtonCaptions(ByVal pintIndex As Int32) As String
- Set(ByVal Value As String)
- If pintIndex >= LBound(mstrButtonText) And pintIndex <= UBound(mstrButtonText) Then
- mstrButtonText(pintIndex) = Value
- End If
- End Set
- End Property
- Private mstrButtonText(2) As String
- Public Property MessageSelfClosingText() As String
- Get
- Return mstrSelfClosingMessageText
- End Get
- Set(ByVal Value As String)
- mstrSelfClosingMessageText = Value
- End Set
- End Property
- Private mstrSelfClosingMessageText As String = ""
- Public Property CheckboxState() As Boolean
- Get
- Return mblnCheckState
- End Get
- Set(ByVal Value As Boolean)
- mblnCheckState = Value
- End Set
- End Property
- Private mblnCheckState As Boolean
- Public ReadOnly Property MessageResult() As System.Windows.Forms.DialogResult
- Get
- Return mudtMessageResult
- End Get
- End Property
- Private mudtMessageResult As System.Windows.Forms.DialogResult
- Public Property MessageIcon() As MessageBoxIcon
- Get
- Return mudtIcon
- End Get
- Set(ByVal Value As MessageBoxIcon)
- Value = mudtIcon
- End Set
- End Property
- Private mudtIcon As MessageBoxIcon
- Public Property MessageDefaultButton() As MessageBoxDefaultButton
- Get
- Return mudtDefaultButton
- End Get
- Set(ByVal Value As MessageBoxDefaultButton)
- mudtDefaultButton = Value
- End Set
- End Property
- Private mudtDefaultButton As MessageBoxDefaultButton
- Public Property MessageOptions() As MessageBoxOptions
- Get
- Return mudtOptions
- End Get
- Set(ByVal Value As MessageBoxOptions)
- mudtOptions = Value
- End Set
- End Property
- Private mudtOptions As MessageBoxOptions
- #End Region
- #Region " Iridium internal vars "
- Private mintCheckHwnd As Int32
- Private mintHook As Int32
- Private mudtScreenSize As Size
- Private mintCaptionHwnd As Int32
- Private mintLabelHwnd As Int32
- Private mudtOwnerHandle As IWin32Window
- #End Region
- #Region " Iridium functions "
- 'standard
- Public Sub New(ByVal pudtOwnerHandle As IWin32Window, ByVal pstrPrompt As String, Optional ByVal pudtButtons As MessageBoxButtons = MessageBoxButtons.OK, Optional ByVal pstrTitle As String = "", Optional ByVal pudtIcon As MessageBoxIcon = MessageBoxIcon.None, Optional ByVal pudtDefaultButton As MessageBoxDefaultButton = MessageBoxDefaultButton.Button1, Optional ByVal pudtOptions As MessageBoxOptions = MessageBoxOptions.DefaultDesktopOnly)
- Initialise(False, pudtOwnerHandle, pstrPrompt, pudtButtons, pstrTitle, pudtIcon, pudtDefaultButton, pudtOptions)
- End Sub
- 'self closing
- Public Sub New(ByVal pudtOwnerHandle As IWin32Window, ByVal pstrPrompt As String, ByVal pintMessagePauseSeconds As Int32, ByVal pstrMessageSelfClosingText As String, Optional ByVal pudtButtons As MessageBoxButtons = MessageBoxButtons.OK, Optional ByVal pstrTitle As String = "", Optional ByVal pudtIcon As MessageBoxIcon = MessageBoxIcon.None, Optional ByVal pudtDefaultButton As MessageBoxDefaultButton = MessageBoxDefaultButton.Button1, Optional ByVal pudtOptions As MessageBoxOptions = MessageBoxOptions.DefaultDesktopOnly)
- mstrSelfClosingMessageText = pstrMessageSelfClosingText
- MessagePauseSeconds = pintMessagePauseSeconds
- Initialise(True, pudtOwnerHandle, pstrPrompt, pudtButtons, pstrTitle, pudtIcon, pudtDefaultButton, pudtOptions)
- End Sub
- 'move
- Public Sub New(ByVal pudtOwnerHandle As IWin32Window, ByVal pstrPrompt As String, ByVal pudtMessageLocation As Point, Optional ByVal pudtButtons As MessageBoxButtons = MessageBoxButtons.OK, Optional ByVal pstrTitle As String = "", Optional ByVal pudtIcon As MessageBoxIcon = MessageBoxIcon.None, Optional ByVal pudtDefaultButton As MessageBoxDefaultButton = MessageBoxDefaultButton.Button1, Optional ByVal pudtOptions As MessageBoxOptions = MessageBoxOptions.DefaultDesktopOnly)
- MessageLocation = pudtMessageLocation
- Initialise(True, pudtOwnerHandle, pstrPrompt, pudtButtons, pstrTitle, pudtIcon, pudtDefaultButton, pudtOptions)
- End Sub
- 'alternate buttons
- Public Sub New(ByVal pudtOwnerHandle As IWin32Window, ByVal pstrPrompt As String, ByVal pstrButton1Caption As String, ByVal pstrButton2Caption As String, ByVal pstrButton3Caption As String, Optional ByVal pudtButtons As MessageBoxButtons = MessageBoxButtons.OK, Optional ByVal pstrTitle As String = "", Optional ByVal pudtIcon As MessageBoxIcon = MessageBoxIcon.None, Optional ByVal pudtDefaultButton As MessageBoxDefaultButton = MessageBoxDefaultButton.Button1, Optional ByVal pudtOptions As MessageBoxOptions = MessageBoxOptions.DefaultDesktopOnly)
- mstrButtonText(0) = pstrButton1Caption
- mstrButtonText(1) = pstrButton2Caption
- mstrButtonText(2) = pstrButton3Caption
- Initialise(True, pudtOwnerHandle, pstrPrompt, pudtButtons, pstrTitle, pudtIcon, pudtDefaultButton, pudtOptions)
- End Sub
- 'checkbox
- Public Sub New(ByVal pudtOwnerHandle As IWin32Window, ByVal pstrPrompt As String, ByVal pstrMessageCheckboxText As String, ByVal pblnInitialCheckboxState As Boolean, Optional ByVal pudtButtons As MessageBoxButtons = MessageBoxButtons.OK, Optional ByVal pstrTitle As String = "", Optional ByVal pudtIcon As MessageBoxIcon = MessageBoxIcon.None, Optional ByVal pudtDefaultButton As MessageBoxDefaultButton = MessageBoxDefaultButton.Button1, Optional ByVal pudtOptions As MessageBoxOptions = MessageBoxOptions.DefaultDesktopOnly)
- mstrCheckboxText = pstrMessageCheckboxText
- mblnCheckState = pblnInitialCheckboxState
- Initialise(True, pudtOwnerHandle, pstrPrompt, pudtButtons, pstrTitle, pudtIcon, pudtDefaultButton, pudtOptions)
- End Sub
- Private Sub Initialise(ByVal pblnDoShow As Boolean, ByVal pudtOwnerHandle As IWin32Window, ByVal pstrPrompt As String, ByVal pudtButtons As MessageBoxButtons, ByVal pstrTitle As String, ByVal pudtIcon As MessageBoxIcon, ByVal pudtDefaultButton As MessageBoxDefaultButton, ByVal pudtOptions As MessageBoxOptions)
- mstrTitle = pstrTitle
- mstrPrompt = pstrPrompt
- mudtButtons = pudtButtons
- mudtOwnerHandle = pudtOwnerHandle
- mudtIcon = pudtIcon
- mudtDefaultButton = pudtDefaultButton
- mudtOptions = pudtOptions
- ' get screen coords
- With Screen.PrimaryScreen.Bounds
- mudtScreenSize.Width = .Width
- mudtScreenSize.Height = .Height
- End With
- If pblnDoShow Then
- ShowMessage()
- End If
- End Sub
- Public Function ShowMessage() As System.Windows.Forms.DialogResult
- Dim udtTimerCountdown As System.Threading.Timer
- Dim udtTimer As System.Threading.Timer
- Dim blnFireHook As Boolean = False
- Dim intLoop As Int32
- 'only set hook if values have been set
- If mintX > 0 Or mintY > 0 Then
- 'choosing to repos the messagebox
- ' set hooking proc
- blnFireHook = True
- End If
- If mintPause > 0 Then
- 'set the timer to fire
- udtTimer = New System.Threading.Timer(New TimerCallback(AddressOf SelfClosingTimerThread), Nothing, mintPauseMili, mintPauseMili)
- 'no point in doing this unless they have set some text
- If mstrSelfClosingMessageText.Length > 0 Then
- 'create hook if not already done
- blnFireHook = True
- 'no point in doing this for 1 sec or less
- If mintPause > 1 Then
- 'set the timer to fire
- udtTimerCountdown = New System.Threading.Timer(New TimerCallback(AddressOf SelfClosingTimerCountdownThread), mintPause, 1000, 1000)
- End If
- End If
- End If
- If Not blnFireHook Then
- For intLoop = LBound(mstrButtonText) To UBound(mstrButtonText)
- If Len(mstrButtonText(intLoop)) > 0 Then
- blnFireHook = True
- Exit For
- End If
- Next intLoop
- End If
- If blnFireHook Then
- mintHook = API.SetWindowsHookEx(5, AddressOf MessageboxHook, 0, API.GetCurrentThreadId)
- End If
- 'invoke Msgbox
- Try
- mudtMessageResult = MessageBox.Show(mudtOwnerHandle, mstrPrompt, mstrTitle, mudtButtons, mudtIcon, mudtDefaultButton, mudtOptions)
- Catch
- 'if the window cannot have a parent then
- mudtMessageResult = MessageBox.Show(mstrPrompt, mstrTitle, mudtButtons, mudtIcon, mudtDefaultButton, mudtOptions)
- End Try
- If mintPause > 0 Then
- udtTimer.Dispose()
- udtTimer = Nothing
- If mstrSelfClosingMessageText.Length > 0 Then
- udtTimerCountdown.Dispose()
- udtTimerCountdown = Nothing
- End If
- End If
- Return mudtMessageResult
- End Function
- #End Region
- #Region " Iridium Threads "
- Public Sub SelfClosingTimerCountdownThread(ByVal State As Object)
- Dim intHandle As Int32
- Static Dim intCountdown As Int32
- If intCountdown = 0 Then
- 'not set so initialise to max
- intCountdown = mintPause
- End If
- intHandle = API.FindWindow("#32770", mstrTitle)
- If intHandle <> 0 Then
- If mintLabelHwnd > 0 Then
- API.SetWindowText(mintLabelHwnd, Replace(mstrSelfClosingMessageText, "%1", intCountdown.ToString))
- intCountdown -= 1
- If intCountdown = 0 Then intCountdown = -1
- End If
- End If
- End Sub
- Public Sub SelfClosingTimerThread(ByVal State As Object)
- Dim intHandle As Int32
- ' A system class is a window class registered by the system which cannot
- ' be destroyed by a processed, e.g. #32768 (a menu), #32769 (desktop
- ' window), #32770 (dialog box), #32771 (task switch window) and
- ' #32770 is a MessageBox
- intHandle = API.FindWindow("#32770", mstrTitle)
- If intHandle <> 0 Then
- API.PostMessage(intHandle, API.WM_CLOSE, 0&, 0&)
- End If
- End Sub
- #End Region
- #Region " Iridium Hooks "
- Private Function MessageboxHook(ByVal pintcode As Int32, ByVal pintwParam As Int32, ByVal pintlParam As Int32) As Int32 '(ByVal iHookCode As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
- ' Dim hdc As Int32 = API.GetDC(mintCaptionHwnd)
- Dim intFont As Int32
- Dim udtRect As API.RECT
- Dim intHeight As Int32
- Dim intLoop As Int32
- Dim intEnumParam As Int32
- Dim udtFont As Font
- Static blnAddedCheckbox As Boolean
- If (0 > pintcode) Then
- Return API.CallNextHookEx(mintHook, pintcode, pintwParam, pintlParam)
- Else
- If pintcode = 4 And mstrCheckboxText.Length > 0 Then
- 'destroying
- 'Returns the value of the checkbox on extended MsgBox
- mblnCheckState = (API.SendMessage(mintCheckHwnd, API.BM_GETSTATE, 0, 0&) <> 0)
- API.UnhookWindowsHookEx(mintHook)
- ElseIf pintcode = 5 Then
- If blnAddedCheckbox Then
- 'no need to do any more in here
- Return API.CallNextHookEx(mintHook, pintcode, pintwParam, pintlParam)
- End If
- 'creating
- If mstrCheckboxText.Length = 0 Then
- 'we only unhook if we are not doing the checkbox thing
- API.UnhookWindowsHookEx(mintHook)
- End If
- 'this enumeration allows us to set the labels handle
- intEnumParam = 1
- For intLoop = LBound(mstrButtonText) To UBound(mstrButtonText)
- If Len(mstrButtonText(intLoop)) > 0 Then
- intEnumParam = 0
- Exit For
- End If
- Next intLoop
- API.EnumChildWindows(pintwParam, AddressOf UpdateButtonHook, intEnumParam)
- API.GetWindowRect(pintwParam, udtRect)
- 'API.SetTextColor(pintwParam, 2345)
- 'API.ReleaseDC(mintCaptionHwnd, hdc)
- 'Get the font for the message window
- intFont = API.SendMessage(mintCaptionHwnd, API.WM_GETFONT, 0, 0)
- udtFont = Font.FromHfont(New IntPtr(intFont))
- intHeight = udtFont.Height
- 'should I add a checkbox
- If mstrCheckboxText.Length > 0 And mintCaptionHwnd > 0 Then
- If intFont <> 0 Then
- 'Create the checkbox control
- mintCheckHwnd = API.CreateWindowEx(0, _
- "Button", _
- mstrCheckboxText, _
- API.WS_CHILD Or API.WS_VISIBLE Or API.WS_TABSTOP Or API.BS_AUTOCHECKBOX, _
- 5, (udtRect.Bottom - udtRect.Top) - intHeight - 15 + CType(IIf(mstrSelfClosingMessageText.Length > 0, intHeight, 0), Int32), _
- udtRect.Right, intHeight, pintwParam, 0, 0, 0)
- ' set the font of the checkbox to the same as the messagebox
- API.SendMessage(mintCheckHwnd, API.WM_SETFONT, intFont, 0)
- ' set the state to a default if true
- If mblnCheckState Then
- API.SendMessage(mintCheckHwnd, API.BM_SETCHECK, CType(mblnCheckState, Int32), 0)
- End If
- 'move the msgbox (and size) to include the new checkbox
- With udtRect
- API.MoveWindow(pintwParam, .Left, .Top, .Right - .Left, .Bottom - .Top + intHeight, 1)
- End With
- End If
- End If
- blnAddedCheckbox = True
- If mintX > 0 Or mintY > 0 Then
- With udtRect
- If mintX > (mudtScreenSize.Width - (.Right - .Left) - 1) Then
- mintX = (mudtScreenSize.Width - (.Right - .Left) - 1)
- End If
- If mintY > (mudtScreenSize.Height - (.Bottom - .Top) - 1) Then
- mintY = (mudtScreenSize.Height - (.Bottom - .Top) - 1)
- End If
- End With
- If mintX < 1 Then mintX = 1
- If mintY < 1 Then mintY = 1
- End If
- If mstrSelfClosingMessageText.Length > 0 Then
- If intFont <> 0 Then
- 'Create the label control
- mintLabelHwnd = API.CreateWindowEx(0, _
- "Static", _
- "Closing in xxx secs", _
- API.WS_CHILD Or API.WS_VISIBLE Or API.WS_TABSTOP Or &H20, _
- 5, (udtRect.Bottom - udtRect.Top) - intHeight - 15, _
- udtRect.Right, intHeight, pintwParam, 0, 0, 0)
- ' set the font of the checkbox to the same as the messagebox
- API.SendMessage(mintLabelHwnd, API.WM_SETFONT, intFont, 0)
- 'move the msgbox (and size) to include the new checkbox
- With udtRect
- API.MoveWindow(pintwParam, .Left, .Top, .Right - .Left, .Bottom - .Top + intHeight + CType(IIf(mstrCheckboxText.Length > 0 And mintCaptionHwnd > 0, intHeight, 0), Int32), 1)
- End With
- SelfClosingTimerCountdownThread(Nothing)
- End If
- End If
- If mintX > 0 Or mintY > 0 Then
- API.SetWindowPos(pintwParam, API.HWND_TOPMOST, mintX, mintY, 0, 0, API.SWP_NOSIZE)
- End If
- End If
- End If
- 'udtFont.Dispose()
- End Function
- Private Function UpdateButtonHook(ByVal hWnd As Int32, ByVal lParam As Int32) As Int32
- Dim strClassName As String = API.GetClassName(hWnd)
- Static intCurrent As Int32 = 0
- If String.Compare(strClassName, "button", True) = 0 And lParam = 0 Then
- 'check we have a caption to set
- If Len(mstrButtonText(intCurrent)) > 0 Then
- API.SetWindowText(hWnd, mstrButtonText(intCurrent))
- End If
- 'increment regardless (the developer may have only set the last param
- intCurrent += 1
- ElseIf String.Compare(strClassName, "static", True) = 0 And _
- String.Compare(API.GetWindowText(hWnd), mstrPrompt, True) = 0 Then
- mintCaptionHwnd = hWnd
- End If
- Return 1
- End Function
- #End Region
- End Class
- Namespace API
- Public Module API
- #Region " API Functions"
- Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
- Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
- Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Int32, ByRef lpRect As API.RECT) As Int32
- Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
- Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Int32, ByVal lpString As String) As Int32
- Public Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Int32, ByVal lpClassName As String, ByVal lpWindowName As String, ByVal dwStyle As Int32, ByVal x As Int32, ByVal y As Int32, ByVal nWidth As Int32, ByVal nHeight As Int32, ByVal hWndParent As Int32, ByVal hMenu As Int32, ByVal hInstance As Int32, ByVal lpParam As Int32) As Int32
- Public Declare Function MoveWindow Lib "user32" Alias "MoveWindow" (ByVal hwnd As Int32, ByVal x As Int32, ByVal y As Int32, ByVal nWidth As Int32, ByVal nHeight As Int32, ByVal bRepaint As Int32) As Int32
- ' Public Declare Function GetDC Lib "user32" (ByVal hwnd As Int32) As Int32
- ' Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Int32, ByVal hdc As Int32) As Int32
- Public Declare Function GetCurrentThreadId Lib "kernel32" () As Int32
- Public Declare Function UnhookWindowsHookEx Lib "user32" Alias "UnhookWindowsHookEx" (ByVal hHook As Int32) As Int32
- Public Declare Function CallNextHookEx Lib "user32" Alias "CallNextHookEx" (ByVal hHook As Int32, ByVal ncode As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
- ' Public Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Int32, ByVal crColor As Int32) As Int32
- Public Delegate Function EnumChildWindowsCallBack(ByVal hWndParent As Int32, ByVal lParam As Int32) As Int32
- Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Int32, ByVal lpEnumFunc As EnumChildWindowsCallBack, ByVal lParam As Int32) As Int32
- Public Delegate Function SetWindowsHookCallBack(ByVal ncode As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
- Public Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Int32, ByVal lpfn As SetWindowsHookCallBack, ByVal hmod As Int32, ByVal dwThreadId As Int32) As Int32
- Public Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Int32, ByVal hWndInsertAfter As Int32, ByVal X As Int32, ByVal Y As Int32, ByVal cx As Int32, ByVal cy As Int32, ByVal wFlags As Int32)
- Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Int32, ByVal lpString As String, ByVal cch As Int32) As Int32
- Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Int32, ByVal lpClassName As String, ByVal nMaxCount As Int32) As Int32
- ' a friendlier version of the GetWindowText() API
- Public Function GetWindowText(ByVal pintHandle As Int32) As String
- Dim strValue As String
- Dim intResult As Int32
- 'init the string buffer
- strValue = Space(256)
- ' call api - the return is the no. of chars found
- intResult = GetWindowText(pintHandle, strValue, strValue.Length)
- ' if all was ok
- If intResult > 0 Then
- 'return the trimmed result
- Return strValue.Substring(0, intResult)
- Else
- Return ""
- End If
- End Function
- ' a friendlier version of the GetClassName() API
- Public Function GetClassName(ByVal pintHandle As Int32) As String
- Dim strValue As String
- Dim intResult As Int32
- 'init the string buffer
- strValue = Space(256)
- ' call api - the return is the no. of chars found
- intResult = GetClassName(pintHandle, strValue, strValue.Length)
- ' if all was ok
- If intResult > 0 Then
- 'return the trimmed result
- Return strValue.Substring(0, intResult)
- Else
- Return ""
- End If
- End Function
- #End Region
- #Region " Structures"
- <System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)> _
- Public Structure RECT
- Public Left As Int32
- Public Top As Int32
- Public Right As Int32
- Public Bottom As Int32
- End Structure
- #End Region
- #Region " Constants"
- Public Const WM_CLOSE As Int32 = &H10
- Public Const WM_GETFONT As Int32 = &H31
- Public Const WM_SETFONT As Int32 = &H30
- Public Const HWND_TOPMOST As Int32 = -1
- Public Const SWP_NOSIZE As Int32 = &H1
- Public Const WS_CHILD As Int32 = &H40000000
- Public Const WS_VISIBLE As Int32 = &H10000000
- Public Const WS_TABSTOP As Int32 = &H10000
- Public Const BS_AUTOCHECKBOX As Int32 = &H3&
- Public Const BM_GETSTATE As Int32 = &HF2
- Public Const BM_SETCHECK As Int32 = &HF1
- #End Region
- End Module
- End Namespace
Advertisement
Add Comment
Please, Sign In to add comment