Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


Visual Basic Programming Code Examples

Visual Basic > Internet Web Mail Stuff Code Examples

Open browser with URL

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
Open browser with URL Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey as Long) as Long Declare Function RegOpenKeyEx Lib "advapi32.dll" alias "RegOpenKeyExA" (ByVal hKey as Long, ByVal lpSubKey as String, ByVal ulOptions as Long, ByVal samDesired as Long, phkResult as Long) as Long Declare Function RegQueryValueEx Lib "advapi32.dll" alias "RegQueryValueExA" (ByVal hKey as Long, ByVal lpValueName as String, ByVal lpReserved as Long, lpType as Long, lpData as Any, lpcbData as Long) as Long Public Const HKEY_CLASSES_ROOT = &H80000000 Public Const ERROR_SUCCESS = 0& Const REG_OPTION_NON_VOLATILE = &O0 Const KEY_ALL_CLASSES as long = &HF0063 Const KEY_ALL_ACCESS = &H3F Const REG_SZ as long = 1 Public Function RegGetString$(hInKey as Long, ByVal subkey$, ByVal valname$) dim RetVal$, hSubKey as Long, dwType as Long, SZ as Long, v$, r as Long RetVal$ = "" r = RegOpenKeyEx(hInKey, subkey$, 0, KEY_ALL_CLASSES, hSubKey) If r <> ERROR_SUCCESS Then GoTo Quit_Now SZ = 256: v$ = String$(SZ, 0) r = RegQueryValueEx(hSubKey, valname$, 0, dwType, ByVal v$, SZ) If r = ERROR_SUCCESS And dwType = REG_SZ Then RetVal$ = Left(v$, SZ - 1) Else RetVal$ = "" end If If hInKey = 0 Then r = RegCloseKey(hSubKey) Quit_Now: RegGetString$ = RetVal$ End Function Public sub ConnectW3(url$) On Error GoTo fout_connectw3 dim strProgram$, strDDETopic$, strDDEItem$ dim intLoaded% 'make on Form1 a invisible textbox named DDEText strProgram = RegGetString(HKEY_CLASSES_ROOT, "http\shell\open\command", "") strDDETopic = UCase(RegGetString(HKEY_CLASSES_ROOT, "http\shell\open\ddeexec\Application", "")) & "|" & RegGetString(HKEY_CLASSES_ROOT, "http\shell\open\ddeexec\Topic", "") strDDEItem = url$ With Form1.DDEText .LinkTopic = strDDETopic .LinkItem = strDDEItem & ",," & -1 .LinkMode = 2 .LinkRequest end With exit Sub fout_connectw3: If Err.Number = 282 Then If intLoaded = 0 Then Shell strProgram, vbNormalFocus intLoaded = 1 ElseIf intLoaded <= 5 Then intLoaded = intLoaded + 1 Else Err.Number = vbObjectError + 1 GoTo fout_connectw3 end If Resume ElseIf Err.Number <> 0 Then MsgBox "Fatal error while communicating to browser" exit Sub end If End Sub Return