Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

SingleInstance Application [C#/VB]

(Oct 2, 2014 01:33 AM)DBots Wrote:  @Nikey646, what I am understanding is you have an application which is a single-instance app. When you send command-line arguments to it, it does not detect them.

If that is the case then I had the same problem and the solution I found was using the StartUpNextInstance event.

Here is a sample of the code I used:
http://pastebin.com/NV6RcDB7

This was originally designed in C#, and i didn't want to import the Microsoft.VisualBasic namespace like you have. Weird errors due to an extra namespace can cause a few problems. I just converted it to VB for fun...then regretted doing so about 30 minutes later while trying to fix errors.

So while you can use StartUpNextInstance with no problems in VB, in C# it'll start causing Intellisense to act up, and further more, the Compiler will get just as confused as Intellisense. (EG: Try to create a new button in code while in a WPF project, but have System.Windows.Forms imported to use the NativeWindow class.)
(Oct 1, 2014 06:29 AM)ThePussyBarret Wrote:  Well not all the peeps arround here had a clue what this does or should perform, perhaps this could be tagged as a challenge ^^

I bet you have no idea aswell . You just like to talk like a tough guy
with MyApplication u use it like
Edit - 😊 just saw dbots paste link

Code
Namespace My
    Partial Friend Class MyApplication

      Private mtx As Threading.Mutex = Nothing
      Private Sub MyApplication_Startup(sender As Object, e As ApplicationServices.StartupEventArgs) Handles Me.Startup
      Dim bExists As Boolean = True
      mtx = New Threading.Mutex(False, "Local\UniqueMutexName", bExists)
      If Not bExists Then
      ' An instance is already opened.
      e.Cancel = True
      Else
      ' No instances opened yet.
      End If
      End Sub

      'Private Sub MyApplication_StartupNextInstance(sender As Object, e As ApplicationServices.StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
      '    Dim inputArgument As String = "/input="
      '    Dim inputName As String = ""

      '    For Each s As String In e.CommandLine
      '      If s.ToLower.StartsWith(inputArgument) Then
      '      inputName = s.Remove(0, inputArgument.Length)
      '      End If
      '    Next

      '    If inputName = "" Then
      '      MsgBox("No input name")
      '    Else
      '      MsgBox("Input name: " & inputName)
      '    End If
      'End Sub
    End Class
End Namespace
(Oct 2, 2014 03:19 AM)unknown123456 Wrote:  I bet you have no idea aswell . You just like to talk like a tough guy

Aww how cute ^^ now hush hush, go play with the others kids.
(Oct 2, 2014 03:19 AM)unknown123456 Wrote:  I bet you have no idea aswell . You just like to talk like a tough guy

Sighs
TheBarret has shown knowledge about a protocol unmentioned in this thread until he pointed out the similarity of it to my original post, that has been around since the early stages of Windows, and what it's proper use for it is. He is also able to create applications that are of no use to anyone, but very few users of this forum could replicate to such completeness. What do you have under your name? A Public Exploit(Patched) converted to VB Code, UDP Flooder, and various other seen-before-malicious-crap.

(P.S: I respect his knowledge of VB, that is all.)

(Oct 2, 2014 04:20 AM)Only3 Wrote:  with MyApplication u use it like
Edit - 😊 just saw dbots paste link

Code
Namespace My
    Partial Friend Class MyApplication

      Private mtx As Threading.Mutex = Nothing
      Private Sub MyApplication_Startup(sender As Object, e As ApplicationServices.StartupEventArgs) Handles Me.Startup
      Dim bExists As Boolean = True
      mtx = New Threading.Mutex(False, "Local\UniqueMutexName", bExists)
      If Not bExists Then
      ' An instance is already opened.
      e.Cancel = True
      Else
      ' No instances opened yet.
      End If
      End Sub

      'Private Sub MyApplication_StartupNextInstance(sender As Object, e As ApplicationServices.StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
      '    Dim inputArgument As String = "/input="
      '    Dim inputName As String = ""

      '    For Each s As String In e.CommandLine
      '      If s.ToLower.StartsWith(inputArgument) Then
      '      inputName = s.Remove(0, inputArgument.Length)
      '      End If
      '    Next

      '    If inputName = "" Then
      '      MsgBox("No input name")
      '    Else
      '      MsgBox("Input name: " & inputName)
      '    End If
      'End Sub
    End Class
End Namespace

Then i presume you also saw my response to DBo's post, which is above your post as well. It also states that the primary purpose of this code was for C#, and your Microsoft.VisualBasic namespace solution is meaningless. Unless your telling me that i should use the Microsoft.VisualBasic namespace in a C# application, upon which i reply to you, Go use the Microsoft.CSharp namespace in your VB application...Oh wait...that's pointlessly stupid...


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by TennoFeb 3, 2019 04:49 AM 4 307 Feb 3, 2019 04:49 AM
Last Post: Tenno
[C#] by DaHaxorAug 12, 2015 09:53 AM 3 260 Aug 12, 2015 09:53 AM
Last Post: salmoneus
[C#] by RedBull™May 8, 2015 04:32 AM 3 143 May 8, 2015 04:32 AM
Last Post: Exussit