Hello. Just putting final touches to my app and i just wanted to know two things.
The first thing is this is the code i use to run my app via right click(it hosts an image)
which all works fine but if the application is already open. it opens another instance of the app. is there a way to stop this? Not a mjor issue but still.
The second is this is the code i use to get the image to host.
is this the best way? It seems a biot messy to me.
thankis
The first thing is this is the code i use to run my app via right click(it hosts an image)
VB.NET:
'Lets set the application dir for are context menu
Dim AppPath As String = Application.ExecutablePath & " " + Chr(34) + "%1" + Chr(34)
'
'lets set subkeys
My.Computer.Registry.ClassesRoot.CreateSubKey("jpegfile\shell\Simple Host")
My.Computer.Registry.ClassesRoot.CreateSubKey("jpegfile\shell\Simple Host\command")
'
'Lets set string value
My.Computer.Registry.SetValue("HKEY_CLASSES_ROOT\jpegfile\shell\Simple Host\command", "", AppPath)
which all works fine but if the application is already open. it opens another instance of the app. is there a way to stop this? Not a mjor issue but still.
The second is this is the code i use to get the image to host.
VB.NET:
'************** Right click context menu *****************
'
'User has chosen to host a file via right click....
'
For Each arg As String In Environment.GetCommandLineArgs()
'Display argument
txtHiddenArgument.Text = arg
Dim Dir As String = txtHiddenArgument.Text
Dim fi As New System.IO.FileInfo(Dir)
txtSplit.Text = fi.Name
If fi.Extension.ToLower = ".jpg" Then
txtFilePath.Text = txtHiddenArgument.Text
txtSendTray.Text = "1"
Me.Size = New Size(764, 416)
chkPre.Checked = True
Dim Pre As Image = _
Image.FromFile(txtHiddenArgument.Text)
PictureBox1.Image = Pre
txtHiddenArgument.Text = ""
Call UploadPicture()
ElseIf fi.Extension.ToLower = ".jpeg" Then
txtFilePath.Text = txtHiddenArgument.Text
txtSendTray.Text = "1"
Me.Size = New Size(764, 416)
chkPre.Checked = True
Dim Pre As Image = _
Image.FromFile(txtHiddenArgument.Text)
PictureBox1.Image = Pre
txtHiddenArgument.Text = ""
Call UploadPicture()
ElseIf fi.Extension.ToLower = ".gif" Then
txtFilePath.Text = txtHiddenArgument.Text
txtSendTray.Text = "1"
Me.Size = New Size(764, 416)
chkPre.Checked = True
Dim Pre As Image = _
Image.FromFile(txtHiddenArgument.Text)
PictureBox1.Image = Pre
txtHiddenArgument.Text = ""
Call UploadPicture()
ElseIf fi.Extension.ToLower = ".tif" Then
txtFilePath.Text = txtHiddenArgument.Text
txtSendTray.Text = "1"
Me.Size = New Size(764, 416)
chkPre.Checked = True
Dim Pre As Image = _
Image.FromFile(txtHiddenArgument.Text)
PictureBox1.Image = Pre
txtHiddenArgument.Text = ""
Call UploadPicture()
ElseIf fi.Extension.ToLower = ".bmp" Then
txtFilePath.Text = txtHiddenArgument.Text
txtSendTray.Text = "1"
Me.Size = New Size(764, 416)
chkPre.Checked = True
Dim Pre As Image = _
Image.FromFile(txtHiddenArgument.Text)
PictureBox1.Image = Pre
txtHiddenArgument.Text = ""
Call UploadPicture()
ElseIf fi.Extension.ToLower = ".png" Then
txtFilePath.Text = txtHiddenArgument.Text
txtSendTray.Text = "1"
Me.Size = New Size(764, 416)
chkPre.Checked = True
Dim Pre As Image = _
Image.FromFile(txtHiddenArgument.Text)
PictureBox1.Image = Pre
txtHiddenArgument.Text = ""
Call UploadPicture()
End If
Next arg
is this the best way? It seems a biot messy to me.
thankis