Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. to locate the previous instance of an application

to locate the previous instance of an application

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    URagavSouth
    wrote on last edited by
    #1

    I have an exe say xyz.exe. Whn i click on that exe for the second time i need to re-invoke the previous instance of that application again.Could anyone help me out on finding the previous instance of an application????? URagav Everything can be sacrificed for truth, but truth cannot be sacrificed for anything .

    A B 2 Replies Last reply
    0
    • U URagavSouth

      I have an exe say xyz.exe. Whn i click on that exe for the second time i need to re-invoke the previous instance of that application again.Could anyone help me out on finding the previous instance of an application????? URagav Everything can be sacrificed for truth, but truth cannot be sacrificed for anything .

      A Offline
      A Offline
      Anthony_Yio
      wrote on last edited by
      #2

      http://www.codeproject.com/threads/singleinstancemfc.asp[^] http://www.codeproject.com/threads/singleinstance.asp[^] http://www.codeproject.com/cpp/csingleinst.asp[^] and lot more. Sonork 100.41263:Anthony_Yio

      1 Reply Last reply
      0
      • U URagavSouth

        I have an exe say xyz.exe. Whn i click on that exe for the second time i need to re-invoke the previous instance of that application again.Could anyone help me out on finding the previous instance of an application????? URagav Everything can be sacrificed for truth, but truth cannot be sacrificed for anything .

        B Offline
        B Offline
        Basavaraj P Umadi
        wrote on last edited by
        #3

        hi, under the WIN32API we have CreateMutex function... u can use this function to check whether the appilcation is already running.. by its return values u can re-invoke the existing one... Public Declare Function CreateMutex Lib "kernel32" Alias "CreateMutexA" (lpMutexAttributes As SECURITY_ATTRIBUTES, ByVal bInitialOwner As Long, ByVal lpName As String) As Long this is the declaration for that function.(from API text viewer) u can also find help in MSDN abt this. http://support.microsoft.com/default.aspx?scid=kb;en-us;258088[^] use this link... heres a vb sample.... Option Explicit Const ERROR_ALREADY_EXISTS = 183 Public Declare Function CreateMutex Lib "Coredll" Alias "CreateMutexW" _ (lpMutexAttributes As Long, _ ByVal bInitialOwner As Long, _ ByVal lpName As String) As Long Public Declare Function GetLastError Lib "Coredll" () As Long Private Sub Form_Load() Dim error_code CreateMutex CLng(0), 1, App.Title If GetLastError() = ERROR_ALREADY_EXISTS Then MsgBox "Already running", vbOKOnly, App.Title App.End Else 'run the application MsgBox "OK to run" End If End Sub all the best.. - thanks and regards, Basavaraj P.Umadi

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups