X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/10b959e3729a77b95ab15614d1bdce74da327d8b..83626bfa72bd7f0147392818846242a846d12063:/src/msw/utils.cpp diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 53fe3c23f0..b97c5f8575 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -10,8 +10,9 @@ ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ -#pragma implementation -#pragma implementation "utils.h" +// Note: this is done in utilscmn.cpp now. +// #pragma implementation +// #pragma implementation "utils.h" #endif // For compilers that support precompilation, includes "wx.h". @@ -188,8 +189,8 @@ bool wxGetUserName(char *buf, int maxSize) // } #else #if !defined(__WATCOMC__) && !defined(__GNUWIN32__) && USE_PENWINDOWS - extern HANDLE hPenWin; // PenWindows Running? - if (hPenWin) + extern HANDLE g_hPenWin; // PenWindows Running? + if (g_hPenWin) { // PenWindows Does have a user concept! // Get the current owner of the recognizer @@ -207,97 +208,6 @@ bool wxGetUserName(char *buf, int maxSize) #endif } -// Execute a command (e.g. another program) in a -// system-independent manner. - -long wxExecute(char **argv, bool sync) -{ - if (*argv == NULL) - return 0; - - char command[1024]; - command[0] = '\0'; - - int argc; - for (argc = 0; argv[argc]; argc++) - { - if (argc) - strcat(command, " "); - strcat(command, argv[argc]); - } - - return wxExecute((char *)command, sync); -} - -long wxExecute(const wxString& command, bool sync) -{ - if (command == "") - return 0; - -#ifdef __WIN32__ - char * cl; - char * argp; - int clen; - HINSTANCE result; - DWORD dresult; - - // copy the command line - clen = command.Length(); - if (!clen) return -1; - cl = (char *) calloc( 1, 256); - if (!cl) return -1; - strcpy( cl, WXSTRINGCAST command); - - // isolate command and arguments - argp = strchr( cl, ' '); - if (argp) - *argp++ = '\0'; - - // execute the command -#ifdef __GNUWIN32__ - result = ShellExecute( (HWND) (wxTheApp->GetTopWindow() ? (HWND) wxTheApp->GetTopWindow()->GetHWND() : NULL), - (const wchar_t) "open", (const wchar_t) cl, (const wchar_t) argp, (const wchar_t) NULL, SW_SHOWNORMAL); -#else - result = ShellExecute( (HWND) (wxTheApp->GetTopWindow() ? wxTheApp->GetTopWindow()->GetHWND() : NULL), - "open", cl, argp, NULL, SW_SHOWNORMAL); -#endif - - if (((long)result) <= 32) { - free(cl); - return 0; - } - - if (!sync) - { - free(cl); - return dresult; - } - - // waiting until command executed - do { - wxYield(); - dresult = GetModuleFileName( result, cl, 256); - } while( dresult); - - /* long lastError = GetLastError(); */ - - free(cl); - return 0; -#else - long instanceID = WinExec((LPCSTR) WXSTRINGCAST command, SW_SHOW); - if (instanceID < 32) return(0); - - if (sync) { - int running; - do { - wxYield(); - running = GetModuleUsage((HANDLE)instanceID); - } while (running); - } - return(instanceID); -#endif -} - int wxKill(long pid, int sig) { return 0; @@ -419,66 +329,52 @@ void wxBell(void) #endif } +// Chris Breeze 27/5/98: revised WIN32 code to +// detect WindowsNT correctly int wxGetOsVersion(int *majorVsn, int *minorVsn) { extern char *wxOsVersion; - if (majorVsn) - *majorVsn = 0; - if (minorVsn) - *minorVsn = 0; - - int retValue ; -#ifndef __WIN32__ -#ifdef __WINDOWS_386__ - retValue = wxWIN386; -#else - -#if !defined(__WATCOMC__) && !defined(__GNUWIN32__) && USE_PENWINDOWS - extern HANDLE hPenWin; - retValue = hPenWin ? wxPENWINDOWS : wxWINDOWS ; -#endif - -#endif -#else - DWORD Version = GetVersion() ; - WORD lowWord = LOWORD(Version) ; - - if (wxOsVersion) + if (majorVsn) *majorVsn = 0; + if (minorVsn) *minorVsn = 0; + +#ifdef WIN32 + OSVERSIONINFO info; + memset(&info, 0, sizeof(OSVERSIONINFO)); + info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + if (GetVersionEx(&info)) { - if (strcmp(wxOsVersion, "Win95") == 0) - return wxWIN95; - else if (strcmp(wxOsVersion, "Win32s") == 0) - return wxWIN32S; - else if (strcmp(wxOsVersion, "Windows") == 0) - return wxWINDOWS; - else if (strcmp(wxOsVersion, "WinNT") == 0) - return wxWINDOWS_NT; + if (majorVsn) *majorVsn = info.dwMajorVersion; + if (minorVsn) *minorVsn = info.dwMinorVersion; + switch (info.dwPlatformId) + { + case VER_PLATFORM_WIN32s: + return wxWIN32S; + break; + case VER_PLATFORM_WIN32_WINDOWS: + return wxWIN95; + break; + case VER_PLATFORM_WIN32_NT: + return wxWINDOWS_NT; + break; + } } - bool Win32s = (( Version & 0x80000000 ) != 0); - bool Win95 = (( Version & 0xFF ) >= 4); - bool WinNT = Version < 0x80000000; - - // Get the version number - if (majorVsn) - *majorVsn = LOBYTE( lowWord ); - if (minorVsn) - *minorVsn = HIBYTE( lowWord ); - - if (Win95) - return wxWIN95; - else if (Win32s) - return wxWIN32S; - else if (WinNT) - return wxWINDOWS_NT; - else - return wxWINDOWS; - -// retValue = ((high & 0x8000)==0) ? wxWINDOWS_NT : wxWIN32S ; -#endif + return wxWINDOWS; // error if we get here, return generic value +#else + // Win16 code... + int retValue ; +# ifdef __WINDOWS_386__ + retValue = wxWIN386; +# else +# if !defined(__WATCOMC__) && !defined(GNUWIN32) && USE_PENWINDOWS + extern HANDLE g_hPenWin; + retValue = g_hPenWin ? wxPENWINDOWS : wxWINDOWS ; +# endif +# endif // @@@@ To be completed. I don't have the manual here... if (majorVsn) *majorVsn = 3 ; if (minorVsn) *minorVsn = 1 ; return retValue ; +#endif } // Reading and writing resources (eg WIN.INI, .Xdefaults) @@ -664,7 +560,7 @@ bool wxCheckForInterrupt(wxWindow *wnd) // MSW only: get user-defined resource from the .res file. // Returns NULL or newly-allocated memory, so use delete[] to clean up. -#ifdef __WINDOWS__ +#ifdef __WXMSW__ char *wxLoadUserResource(const wxString& resourceName, const wxString& resourceType) { char *s = NULL;