Click here to Skip to main content
11,717,570 members (81,180 online)

.NET Framework

 
AnswerRe: spawning mmc to a particular server or hosting remote console in an application Pin
Dave Kreskowiak7-Mar-13 2:33
mvpDave Kreskowiak7-Mar-13 2:33 
AnswerRe: spawning mmc to a particular server or hosting remote console in an application Pin
Martin-FFB14-Apr-13 22:57
memberMartin-FFB14-Apr-13 22:57 
AnswerRe: spawning mmc to a particular server or hosting remote console in an application Pin
garaber30-Apr-13 13:04
membergaraber30-Apr-13 13:04 
QuestionCrystal Report Selection Formula Pin
Neeraj86624-Mar-13 20:30
memberNeeraj86624-Mar-13 20:30 
Questionc# Pin
K.Bharathidhasan1-Mar-13 2:03
memberK.Bharathidhasan1-Mar-13 2:03 
AnswerRe: c# Pin
ThePhantomUpvoter1-Mar-13 3:00
memberThePhantomUpvoter1-Mar-13 3:00 
AnswerRe: c# Pin
Eddy Vluggen1-Mar-13 3:00
mvpEddy Vluggen1-Mar-13 3:00 
AnswerRe: c# Pin
ProgramFOX3-Mar-13 6:17
member ProgramFOX3-Mar-13 6:17 
QuestionI want to store webservice method's XML output as string in C# Pin
Member 982628125-Feb-13 0:21
memberMember 982628125-Feb-13 0:21 
AnswerRe: I want to store webservice method's XML output as string in C# Pin
Eddy Vluggen25-Feb-13 8:20
mvpEddy Vluggen25-Feb-13 8:20 
AnswerRe: I want to store webservice method's XML output as string in C# Pin
jschell25-Feb-13 9:01
memberjschell25-Feb-13 9:01 
Question[VB.NET 2008] Compact Framework: how to start a single instance of an application Pin
steve_949661324-Feb-13 23:28
membersteve_949661324-Feb-13 23:28 
AnswerRe: [VB.NET 2008] Compact Framework: how to start a single instance of an application Pin
Eddy Vluggen25-Feb-13 8:10
mvpEddy Vluggen25-Feb-13 8:10 
GeneralRe: [VB.NET 2008] Compact Framework: how to start a single instance of an application Pin
steve_949661325-Feb-13 23:44
membersteve_949661325-Feb-13 23:44 
Hi Eddy!
Searching again I found some code about mutex and with little changes it seems to work.
I wrote (copy/past + some changes...) a class SingleInstanceApplication:

Imports System.Reflection
Imports System.Runtime.InteropServices
 
Public Class SingleInstanceApplication
 
  <DllImport("Coredll.dll", SetLastError:=True)> _
  Public Shared Function CreateMutex(ByVal Attr As IntPtr, ByVal Own As Boolean, ByVal Name As String) As IntPtr
  End Function
 
  <DllImport("Coredll.dll", SetLastError:=True)> _
  Public Shared Function ReleaseMutex(ByVal hMutex As IntPtr) As Boolean
  End Function
 
  Const ERROR_ALREADY_EXISTS As Long = 183
 
  Public Shared Sub Run(ByVal frm As Form)
    Dim name As String = Assembly.GetExecutingAssembly().GetName().Name
    Dim mutexHandle As IntPtr = CreateMutex(IntPtr.Zero, True, name)
    Dim Rerror As Long = Marshal.GetLastWin32Error()
 
    'MessageBox.Show(name & " - " & mutexHandle.ToString & " - " & Rerror.ToString)  'just for debug

    If (Not Rerror = ERROR_ALREADY_EXISTS) Then
      Application.Run(frm)
    End If
 
    'MessageBox.Show("release mutex")  'just for debug

    ReleaseMutex(mutexHandle)
 
  End Sub
End Class

then I wrote a class to start the application:

Public Class StartApp
  Public Shared Sub main()
    Try
      SingleInstanceApplication.Run(FormMain)
    Catch ex As Exception
      MessageBox.Show(ex.Message)
    End Try
  End Sub
End Class

finally I modified the start object of the application from "FormMain" (the main form of the application) to "StartApp".
It works!

Thanks.
GeneralRe: [VB.NET 2008] Compact Framework: how to start a single instance of an application Pin
Eddy Vluggen26-Feb-13 0:33
mvpEddy Vluggen26-Feb-13 0:33 
QuestionEvent Handling between Threads Pin
AeroClassics19-Feb-13 11:37
memberAeroClassics19-Feb-13 11:37 
AnswerRe: Event Handling between Threads Pin
Gerry Schmitz19-Feb-13 19:25
memberGerry Schmitz19-Feb-13 19:25 
GeneralRe: Event Handling between Threads Pin
AeroClassics20-Feb-13 4:45
memberAeroClassics20-Feb-13 4:45 
QuestionWays of implenting IEnumerable in VB Pin
Mike-MadBadger19-Feb-13 11:10
memberMike-MadBadger19-Feb-13 11:10 
AnswerRe: Ways of implenting IEnumerable in VB Pin
MicroVirus13-Mar-13 11:56
memberMicroVirus13-Mar-13 11:56 
GeneralRe: Ways of implenting IEnumerable in VB Pin
Mike-MadBadger13-Mar-13 21:44
memberMike-MadBadger13-Mar-13 21:44 
Questionhow to manage exicution code Pin
nanhesab18-Feb-13 0:58
membernanhesab18-Feb-13 0:58 
AnswerRe: how to manage exicution code Pin
Eddy Vluggen18-Feb-13 1:01
mvpEddy Vluggen18-Feb-13 1:01 
AnswerRe: how to manage exicution code Pin
Super Lloyd18-Feb-13 1:33
memberSuper Lloyd18-Feb-13 1:33 
AnswerRe: how to manage exicution code Pin
Sandeep Mewara18-Feb-13 3:13
mvpSandeep Mewara18-Feb-13 3:13 
Questionharvesting social images for bi concept image search Pin
krish888817-Feb-13 16:32
memberkrish888817-Feb-13 16:32 
AnswerRe: harvesting social images for bi concept image search Pin
N a v a n e e t h17-Feb-13 17:13
memberN a v a n e e t h17-Feb-13 17:13 
AnswerRe: harvesting social images for bi concept image search Pin
Sandeep Mewara17-Feb-13 18:24
mvpSandeep Mewara17-Feb-13 18:24 
AnswerRe: harvesting social images for bi concept image search Pin
Abhinav S19-Feb-13 0:08
mvpAbhinav S19-Feb-13 0:08 
AnswerRe: harvesting social images for bi concept image search Pin
Dave Kreskowiak19-Feb-13 1:45
mvpDave Kreskowiak19-Feb-13 1:45 
QuestionWhere to get Regasm and Gacutil? Pin
cjb11015-Feb-13 0:54
membercjb11015-Feb-13 0:54 
AnswerRe: Where to get Regasm and Gacutil? Pin
Richard Deeming15-Feb-13 1:01
memberRichard Deeming15-Feb-13 1:01 
GeneralRe: Where to get Regasm and Gacutil? Pin
cjb11015-Feb-13 2:55
membercjb11015-Feb-13 2:55 
AnswerRe: Where to get Regasm and Gacutil? Pin
Dave Kreskowiak15-Feb-13 2:12
mvpDave Kreskowiak15-Feb-13 2:12 
GeneralRe: Where to get Regasm and Gacutil? Pin
cjb11015-Feb-13 2:48
membercjb11015-Feb-13 2:48 
QuestionWeb development using C++ Pin
AseelHadlaq14-Feb-13 23:04
memberAseelHadlaq14-Feb-13 23:04 
AnswerRe: Web development using C++ Pin
N a v a n e e t h14-Feb-13 23:47
memberN a v a n e e t h14-Feb-13 23:47 
AnswerRe: Web development using C++ Pin
Dave Kreskowiak15-Feb-13 2:04
mvpDave Kreskowiak15-Feb-13 2:04 
AnswerRe: Web development using C++ Pin
Marco Bertschi15-Feb-13 3:27
memberMarco Bertschi15-Feb-13 3:27 
GeneralRe: Web development using C++ Pin
krysiaaa15-Feb-13 5:44
memberkrysiaaa15-Feb-13 5:44 
AnswerRe: Web development using C++ Pin
jschell15-Feb-13 9:11
memberjschell15-Feb-13 9:11 
AnswerRe: Web development using C++ Pin
Rahul Rajat Singh17-Feb-13 18:43
mvpRahul Rajat Singh17-Feb-13 18:43 
QuestionUSB Barcode scanner in C# Pin
Member 830583814-Feb-13 22:15
memberMember 830583814-Feb-13 22:15 
AnswerRe: USB Barcode scanner in C# Pin
Dave Kreskowiak15-Feb-13 2:05
mvpDave Kreskowiak15-Feb-13 2:05 
GeneralRe: USB Barcode scanner in C# Pin
Member 830583815-Feb-13 3:00
memberMember 830583815-Feb-13 3:00 
GeneralRe: USB Barcode scanner in C# Pin
Dave Kreskowiak15-Feb-13 3:33
mvpDave Kreskowiak15-Feb-13 3:33 
GeneralMessage Removed Pin
Member 984580018-Feb-13 19:33
memberMember 984580018-Feb-13 19:33 
GeneralRe: USB Barcode scanner in C# Pin
Dave Kreskowiak19-Feb-13 1:44
mvpDave Kreskowiak19-Feb-13 1:44 
QuestionwinRT xaml/C# listview selected index Pin
Clodetta del Mar14-Feb-13 4:38
memberClodetta del Mar14-Feb-13 4:38 
AnswerRe: winRT xaml/C# listview selected index Pin
Marco Bertschi15-Feb-13 3:33
memberMarco Bertschi15-Feb-13 3:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web01 | 2.8.150901.1 | Last Updated 3 Sep 2015
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid