Friday, July 31, 2009

VB.net to open a web page on a button click

System.Diagnostics.Process.Start("http://www.website.com")

You can actually use this to open a text page, word document.  IT will open the document with the application associated with that type of file.

Thursday, July 23, 2009

Check if the program is the first instance

I read this on codeproject and wanted to save it incase I need it down the road
 
To check that the program is the first instance, try this code :-

'Check to see if already running
Dim currentProcess As Process = Process.GetCurrentProcess()
Dim allProcesses() As Process = Process.GetProcessesByName(currentProcess.ProcessName)

If allProcesses.Length > 1 Then
'already running
Else
'not already running
End If


You could also pass the necessary parameter via a file. For instance write an file somewhere, containing the necessary parameters and use a FileSystemWatcher to monitor the file for changes.

Depands how slick you want it, but the simplest options are usually the best.