how to make my photo viewer open when user open drive C and get all photo in the drive to be shown i

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
hi
I design photo viewer app using this code
<pre>Imports Microsoft.Win32
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If My.Application.CommandLineArgs.Count > 0 Then OpenPicture(My.Application.CommandLineArgs(0))
RegisterForAllFiles("""" & Application.ExecutablePath & """" & " ""%1""", "Open with Max Photo Viewer")
End Sub
Private Sub OpenPicture(ByVal imgFile As String)
PictureBox1.Image = Image.FromFile(imgFile)
PictureBox1.Width = PictureBox1.Image.Width
PictureBox1.Height = PictureBox1.Image.Height
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
Dim ofd As New OpenFileDialog
ofd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
ofd.Filter = "Images|*.jpg;*.tif;*.BMP;*.GIF;*.ico;*.PNG;*.TIF"
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then OpenPicture(ofd.FileName)
End Sub

Public Shared Sub RegisterForAllFiles(ByVal menuCommand As String, ByVal MenuText As String)
Dim key As RegistryKey
Try
key = Registry.ClassesRoot.CreateSubKey("*shell")
key.Close()
key = Registry.ClassesRoot.CreateSubKey("*shell" & MenuText)
key.Close()
key = Registry.ClassesRoot.CreateSubKey("*shell" & MenuText & "command")
key.SetValue(Nothing, menuCommand)
key.Close()
Catch ex As Exception
End Try
If Not key Is Nothing Then
key.Close()
End If
End Sub

End Class
[/code]
now how to make my photo viewer open when user open drive C and get all photo in the drive to be shown in it ?

View the full article
 
Back
Top