I have made a program that calls itself. I must pass the command line to it, but the program must know in with state it is. (first call or the second on) I think i found the ideal solution for this problem. The global atom database!
Private sub main()
Nta = FndAtom("AdminRunStatus")
If Nta = 0 Then
Nta = SetAtom("AdminRunStatus")
'set the status for the second run
'do something for the first run (shell to myself)
call shell (App.Path & "\" & App.EXEName & " " & Command)
End If
Exit Sub
Else
Call DelAtom(Nta)
'second program and the command line
call shell(Second program & " " & Command)
'do something for the second run.
End sub
This my created wrapper for the atom database:
'---------------------------------------------------------------------------------------
' Module : AtomDataBase Wrapper
' Author : Pcuser80
' Date : 03-06-2012
' Purpose : Atom Wrapper
'---------------------------------------------------------------------------------------
Option Explicit
Private Declare Function InitAtomTable Lib "kernel32" (ByVal nSize As Long) As Long
Private Declare Function AddAtom Lib "kernel32" Alias "AddAtomA" (ByVal lpString As String) As Integer
Private Declare Function DeleteAtom Lib "kernel32" (ByVal nAtom As Integer) As Integer
Private Declare Function FindAtom Lib "kernel32" Alias "FindAtomA" (ByVal lpString As String) As Integer
Private Declare Function GetAtomName Lib "kernel32" Alias "GetAtomNameA" (ByVal nAtom As Integer, ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GlobalAddAtom Lib "kernel32" Alias "GlobalAddAtomA" (ByVal lpString As String) As Integer
Private Declare Function GlobalDeleteAtom Lib "kernel32" (ByVal nAtom As Integer) As Integer
Private Declare Function GlobalFindAtom Lib "kernel32" Alias "GlobalFindAtomA" (ByVal lpString As String) As Integer
Private Declare Function GlobalGetAtomName Lib "kernel32" Alias "GlobalGetAtomNameA" (ByVal nAtom As Integer, ByVal lpBuffer As String, ByVal nSize As Long) As Long
Public Function SetAtom(ByVal AtomStr As String) As Integer
SetAtom = GlobalAddAtom(AtomStr)
End Function
Public Function GetAtom(ByVal Atom As Integer) As String
Dim buFfer As String
Dim lRet As Long
buFfer = String(255, 0)
lRet = GlobalGetAtomName(Atom, buFfer, Len(buFfer))
If lRet > 0 Then
buFfer = Left$(buFfer, lRe