Ali.Ghasemi
New Member
سلام در ویژوالبیسیک چه کدی بزارم که وقتی یک نفر دکمه رفتن به سایت زد با موزیلا براش باز بشه نه اکسپولیر
سلام در ویژوالبیسیک چه کدی بزارم که وقتی یک نفر دکمه رفتن به سایت زد با موزیلا براش باز بشه نه اکسپولیر
notepad.exe "C:\MyFolder\test.txt"
firefox.exe "www.google.com"
Option Explicit
Private Const ERROR_SUCCESS As Long = 0
Private Const HKEY_LOCAL_MACHINE As Long = &H80000002
Private Const REG_SZ As Long = 1
Private Const KEY_READ As Long = &H20019
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As Long, ByRef lpcbData As Long) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Form_Load()
Dim URL As String, Path As String
URL = "http://forum.majidonline.com/"
Path = GetFirefoxPath
If Len(Path) > 0 Then
ShellExecute Me.hWnd, "open", Path, """" & URL & """", vbNullString, 1
End If
End Sub
Private Function [B][COLOR="Blue"]GetFirefoxPath[/COLOR][/B]() As String
Dim hKey As Long, SubKey As String
Dim Length As Long, Path() As Byte
SubKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe"
If RegOpenKeyEx(HKEY_LOCAL_MACHINE, SubKey, 0, KEY_READ, hKey) = ERROR_SUCCESS Then
Length = 4096
ReDim Path(0 To Length)
If RegQueryValueEx(hKey, vbNullString, 0, REG_SZ, VarPtr(Path(0)), Length) = ERROR_SUCCESS Then
If Length > 1 Then
GetFirefoxPath = Left(StrConv(Path, vbUnicode), Length - 1)
End If
End If
RegCloseKey hKey
End If
End Function
مرسی
کد Opsera هم میذارید
عزیز یک کد هم برای باز کردن پش فرش مروگرها بزاری خیلی ممنون میشم
Option Explicit
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Form_Load()
Dim URL As String
URL = "http://forum.majidonline.com/"
ShellExecute Me.hWnd, "open", URL, vbNullString, vbNullString, 1
End Sub
Option Explicit
Private Const ERROR_SUCCESS As Long = 0
Private Const HKEY_LOCAL_MACHINE As Long = &H80000002
Private Const REG_SZ As Long = 1
Private Const KEY_READ As Long = &H20019
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal lpData As Long, ByRef lpcbData As Long) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Sub Form_Load()
Clipboard.Clear
Clipboard.SetText ("&H" & Hex(KEY_READ))
Dim URL As String, Path As String
URL = "http://forum.majidonline.com/"
Path = GetOperaPath
If Len(Path) > 0 Then
ShellExecute Me.hWnd, "open", Path, """" & URL & """", vbNullString, 1
End If
End Sub
Private Function GetOperaPath() As String
Dim hKey As Long, SubKey As String
Dim Length As Long, Path() As Byte
Dim Command As String
SubKey = "SOFTWARE\Classes\Applications\Opera.exe\shell\open\command"
If RegOpenKeyEx(HKEY_LOCAL_MACHINE, SubKey, 0, KEY_READ, hKey) = ERROR_SUCCESS Then
Length = 4096
ReDim Path(0 To Length)
If RegQueryValueEx(hKey, vbNullString, 0, REG_SZ, VarPtr(Path(0)), Length) = ERROR_SUCCESS Then
If Length > 1 Then
Command = Left(StrConv(Path, vbUnicode), Length - 1)
If Left(Command, 1) = """" Then
GetOperaPath = Mid(Command, 2, InStr(2, Command, """") - 2)
End If
End If
End If
RegCloseKey hKey
End If
End Function