Use of Internet Explorer and MSHTML object

Saturday, May 17, 2008

How to use Internet Explorer controls in vb ?
Dim ie As New InternetExplorer
Dim hdoc As mshtml.IHTMLDocument
Dim iHTMLCol As IHTMLElementCollection
Dim iHTMLEle As IHTMLElement

ie.navigate ("about:blank")
ie.Visible = False
Do

Loop Until Not ie.Busy
str = ie.document.body.innerText
If str Like "*cannot be*" Then
msgbox "Check For Internet Connection"
End If

str = ie.document.body.innerText
If str Like "*cannot be*" Then
ValidatePANInformation = "Check For Internet Connection"
Exit Function
End If

Set hdoc = ie.document
Set iHTMLCol = hdoc.getElementsByTagName("input")
Do
For Each iHTMLEle In iHTMLCol
If iHTMLEle.name = "abc" Then
iHTMLEle.innerText = " "
End If

If iHTMLEle.name = "XYZ" Then
iHTMLEle.Click
End If
Next
Loop While SetValue <> True

Do

Loop Until Not ie.Busy

Set iHTMLCol = hdoc.getElementsByTagName("span")
Do

For Each iHTMLEle In iHTMLCol
If iHTMLEle.id = "nameofcontrol" Then
'MsgBox iHTMLEle.innerText
End If
Next
Loop While SetValue <> True
ie.Quit

How To Register an Extension

Friday, May 16, 2008

How to Register an Extension in VB 6.0 ?


Public Sub RegisterRJVExtension()

On Error Resume Next

Dim reg As Registry

Set reg = New Registry

Call reg.UpdateKey(REGToolRootTypes.HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.rjv", "Application", "RJVOpener.exe")

Call reg.UpdateKey(REGToolRootTypes.HKEY_CLASSES_ROOT, "Applications\RJVOpener.exe\Shell\open\command", "", App.Path & "\RJVOpener.exe %1")

Set reg = Nothing

End Sub


How to register an extension in vb.net?
Public Sub RegExtension() Dim reg As Microsoft.Win32.Registry Dim regkey As Microsoft.Win32.RegistryKey regkey = Microsoft.Win32.Registry.CurrentUser regkey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.lux", Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree) regkey.SetValue("Application", "ShowMessage.exe", Microsoft.Win32.RegistryValueKind.String) Dim regkey1 As Microsoft.Win32.RegistryKey regkey1 = Microsoft.Win32.Registry.ClassesRoot regkey1 = Microsoft.Win32.Registry.ClassesRoot.CreateSubKey("Applications\ShowMessage.exe\Shell\open\command", Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree) regkey1.SetValue("", Application.StartupPath & "\ShowMessage.exe %1", Microsoft.Win32.RegistryValueKind.String)
End Sub

Register a Port and Exe



Public Sub RegisterportandSoftware()
Dim reg As Registry
'''' Register Your Port ( No need to off your firewall)
Set reg = New Registry
Call reg.UpdateKey(REGToolRootTypes.HKEY_LOCAL_MACHINE, "SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List", "3306:TCP", "3306:TCP:*:Enabled:EnterYourText")
Call reg.UpdateKey(REGToolRootTypes.HKEY_LOCAL_MACHINE, "SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\GloballyOpenPorts\List", "1412:TCP", "1412:TCP:*:Enabled:EnteryourPortName")
'''''' Reg ister Your Application
Call reg.UpdateKey(REGToolRootTypes.HKEY_LOCAL_MACHINE, "SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List", App.Path, App.Path & ":*:Enabled:EnteryourApplicationName")
Set reg = Nothing
End Sub

Get Process Id/ Thread ID In Visual Basic

Wednesday, May 14, 2008

How to get Process id and Thread id in Visual Basic?

Private Declare Function GetCurrentThreadId Lib "kernel32" () As Long
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long


Public Property Get ThreadID() As VariantThreadID = GetCurrentThreadIdEnd Property Public Property Get ProcessID() As Variant ProcessID = GetCurrentProcessId End Property

Get User Name

Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _ (ByVal lpBuffer As String, nSize As Long) As Long
Public Property Get UserName() As Variant Dim sBuffer As String Dim lSize As Long sBuffer = Space$(255) lSize = Len(sBuffer) Call GetUserName(sBuffer, lSize) UserName = Left$(sBuffer, lSize) End Property