From c1cb41536a6106968b546cdba8d3d89805f802bc Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 12 Jun 2002 20:26:24 +0000 Subject: [PATCH] added wxGetProcessId() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15814 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/function.tex | 13 +++++++++++++ include/wx/utils.h | 11 ++++++++--- src/msw/utils.cpp | 15 +++++++++++++++ src/unix/utilsunx.cpp | 5 +++++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex index 9ebfa7b43f..5527dddcf2 100644 --- a/docs/latex/wx/function.tex +++ b/docs/latex/wx/function.tex @@ -114,6 +114,7 @@ the corresponding topic. \helpref{wxGetPrinterPreviewCommand}{wxgetprinterpreviewcommand}\\ \helpref{wxGetPrinterScaling}{wxgetprinterscaling}\\ \helpref{wxGetPrinterTranslation}{wxgetprintertranslation}\\ +\helpref{wxGetProcessId}{wxgetprocessid}\\ \helpref{wxGetResource}{wxgetresource}\\ \helpref{wxGetSingleChoiceData}{wxgetsinglechoicedata}\\ \helpref{wxGetSingleChoiceIndex}{wxgetsinglechoiceindex}\\ @@ -584,6 +585,18 @@ enum wxKillError +\membersection{::wxGetProcessId}\label{wxgetprocessid} + +\func{unsigned long}{wxGetProcessId}{\void} + +Returns the number uniquely identifying the current process in the system. + +If an error occurs, $0$ is returned. + +\wxheading{Include files} + + + \membersection{::wxShell}\label{wxshell} \func{bool}{wxShell}{\param{const wxString\& }{command = NULL}} diff --git a/include/wx/utils.h b/include/wx/utils.h index 9362a0055a..0d51ae667b 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -226,7 +226,7 @@ enum wxShutdownFlags wxSHUTDOWN_REBOOT // shutdown and reboot }; -// Shutdown or reboot the PC +// Shutdown or reboot the PC WXDLLEXPORT bool wxShutdown(wxShutdownFlags wFlags); // send the given signal to the process (only NONE and KILL are supported under @@ -251,6 +251,9 @@ WXDLLEXPORT void wxSleep(int nSecs); // Sleep for a given amount of milliseconds WXDLLEXPORT void wxUsleep(unsigned long milliseconds); +// Get the process id of the current process +WXDLLEXPORT unsigned long wxGetProcessId(); + // Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX) WXDLLEXPORT long wxGetFreeMemory(); @@ -356,6 +359,8 @@ WXDLLEXPORT wxWindow* wxFindWindowByName(const wxString& name, wxWindow *parent // Message/event queue helpers // ---------------------------------------------------------------------------- +// NB: these functions are obsolete, please use wxApp methods instead! + // Yield to other apps/messages WXDLLEXPORT bool wxYield(); @@ -379,14 +384,14 @@ WXDLLEXPORT void wxFlushEvents(); // ctor and enables them back in its dtor class WXDLLEXPORT wxWindowDisabler { - DECLARE_NO_COPY_CLASS(wxWindowDisabler) - public: wxWindowDisabler(wxWindow *winToSkip = (wxWindow *)NULL); ~wxWindowDisabler(); private: wxWindowList *m_winDisabled; + + DECLARE_NO_COPY_CLASS(wxWindowDisabler) }; // ---------------------------------------------------------------------------- diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 185d3ebb9e..d9fcbb0033 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -40,6 +40,12 @@ #include "wx/msw/private.h" // includes +#ifdef __GNUWIN32_OLD__ + // apparently we need to include winsock.h to get WSADATA and other stuff + // used in wxGetFullHostName() with the old mingw32 versions + #include +#endif + #include "wx/timer.h" #if !defined(__GNUWIN32__) && !defined(__WXWINE__) && !defined(__SALFORDC__) && !defined(__WXMICROWIN__) @@ -941,6 +947,15 @@ long wxGetFreeMemory() #endif } +unsigned long wxGetProcessId() +{ +#ifdef __WIN32__ + return ::GetCurrentProcessId(); +#else + return 0; +#endif +} + // Emit a beeeeeep void wxBell() { diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index fbeb877d03..a455399ffd 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -1018,6 +1018,11 @@ int wxGetOsVersion(int *majorVsn, int *minorVsn) #endif // !wxUSE_GUI +unsigned long wxGetProcessId() +{ + return (unsigned long)getpid(); +} + long wxGetFreeMemory() { #if defined(__LINUX__) -- 2.45.2