1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxSingleInstanceChecker documentation
4 %% Author: Vadim Zeitlin
8 %% Copyright: (c) 2001 Vadim Zeitlin
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxSingleInstanceChecker
}}\label{wxsingleinstancechecker
}
14 wxSingleInstanceChecker class allows to check that only a single instance of a
15 program is running. To do it, you should create an object of this class. As
16 long as this object is alive, calls to
17 \helpref{IsAnotherRunning()
}{wxsingleinstancecheckerisanotherrunning
} from
18 other processes will return
{\tt TRUE
}.
20 As the object should have the life span as big as possible, it makes sense to
21 create it either as a global or in
\helpref{wxApp::OnInit
}{wxapponinit
}. For
27 m_checker = new wxSingleInstanceChecker(GetAppName());
28 if ( m_checker->IsAnotherRunning() )
30 wxLogError(_("Another program instance is already running, aborting."));
35 ... more initializations ...
48 This class is implemented for Win32 and Unix platforms supporting
{\tt fcntl()
}
51 \wxheading{Derived from
}
55 \latexignore{\rtfignore{\wxheading{Members
}}}
57 \membersection{wxSingleInstanceChecker::wxSingleInstanceChecker
}\label{wxsingleinstancecheckerctor
}
59 \func{}{wxSingleInstanceChecker
}{\void}
61 Default ctor, use
\helpref{Create()
}{wxsingleinstancecheckercreate
} after it.
63 \membersection{wxSingleInstanceChecker::wxSingleInstanceChecker
}\label{wxsingleinstancecheckerwxsingleinstancechecker
}
65 \func{}{wxSingleInstanceChecker
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{path = wxEmptyString
}}
67 Like
\helpref{Create()
}{wxsingleinstancecheckercreate
} but without
70 \membersection{wxSingleInstanceChecker::Create
}\label{wxsingleinstancecheckercreate
}
72 \func{bool
}{Create
}{\param{const wxString\&
}{name
},
\param{const wxString\&
}{path = wxEmptyString
}}
74 Initialize the object if it had been created using the default constructor.
75 Note that you can't call Create() more than once, so calling it if the
76 \helpref{non default ctor
}{wxsingleinstancecheckerwxsingleinstancechecker
}
77 had been used is an error.
79 \wxheading{Parameters
}
81 \docparam{name
}{must be given and be as unique as possible. It is used as the
82 mutex name under Win32 and the lock file name under Unix.
83 \helpref{GetAppName()
}{wxappgetappname
} may be a good value for this parameter
}
85 \docparam{path
}{is optional and is ignored under Win32 and used as the directory to
86 create the lock file in under Unix (default is
87 \helpref{wxGetHomeDir()
}{wxgethomedir
})
}
89 \wxheading{Return value
}
91 Returns
{\tt FALSE
} if initialization failed, it doesn't mean that another
92 instance is running - use
93 \helpref{IsAnotherRunning()
}{wxsingleinstancecheckerisanotherrunning
} to check
96 \membersection{wxSingleInstanceChecker::IsAnotherRunning
}\label{wxsingleinstancecheckerisanotherrunning
}
98 \constfunc{bool
}{IsAnotherRunning
}{\void}
100 Returns
{\tt TRUE
} if another copy of this program is already running,
{\tt
103 \membersection{wxSingleInstanceChecker::
\destruct{wxSingleInstanceChecker
}}\label{wxsingleinstancecheckerdtor
}
105 \func{}{\destruct{wxSingleInstanceChecker
}}{\void}
107 Destructor frees the associated resources.
109 Note that it is not virtual, this class is not meant to be used polymorphically