void ColorPalProc(void) { char szColors[255]; hColorPalette=WinQueryObject("<WP_LORESCLRPAL>"); if(hColorPalette==NULLHANDLE) WinMessageBox(HWND_DESKTOP,hwndClient, "Could not open Color Palette", szAppName,0,MB_OK|MB_MOVEABLE|MB_ICONEXCLAMATION); else { WinSetObjectData(hColorPalette,"OPEN=DEFAULT"); strcpy(szColors,"COLORS="); strcat(szColors,"0xFFFFFF,");//1 strcat(szColors,"0xFF0000,");//2 strcat(szColors,"0xFF00FF,");//3 strcat(szColors,"0x0000FF,");//4 strcat(szColors,"0x00FFFF,");//5 strcat(szColors,"0x00FF00,");//6 strcat(szColors,"0xFFFF00,");//7 strcat(szColors,"0xCCCCCC,");//8 strcat(szColors,"0x000000,");//9 strcat(szColors,"0x800000,");//10 strcat(szColors,"0x800080,");//11 strcat(szColors,"0x000080,");//12 strcat(szColors,"0x008080,");//13 strcat(szColors,"0x008000,");//14 strcat(szColors,"0x808000,");//15 strcat(szColors,"0x808080");//16 WinSetObjectData(hColorPalette,szColors); hwndColorPalette=WinQueryActiveWindow(HWND_DESKTOP); } }
BOOL OCL::saveID(PCH DESK) { HOBJECT hObject; hObject=WinQueryObject((PCH) DESK); if (hObject==NULLHANDLE) return(FALSE); if ((WinSetObjectData(hObject, "OBJECTID=<WP_DESKTOP>")==TRUE)) return(TRUE); else return(FALSE); }
void FontPalProc(void) { hFontPalette=WinQueryObject("<WP_FNTPAL>"); if(hFontPalette==NULLHANDLE) WinMessageBox(HWND_DESKTOP,hwndClient, "Could not open Font Palette", szAppName,0,MB_OK|MB_MOVEABLE|MB_ICONEXCLAMATION); else WinSetObjectData(hFontPalette,"OPEN=DEFAULT"); hwndFontPalette=WinQueryActiveWindow(HWND_DESKTOP); }
int main (int argc, char *argv[]) { APIRET rc; PCHAR pcEnv; PRFPROFILE prfProfile; #ifdef DEBUG ulDebugMask = 0xFFFFFFFF; #endif /* DEBUG */ hab = WinInitialize(0); hmq = WinCreateMsgQueue(hab, 0); DebugS (1, "PM Interface initialized"); /* Shared Memory organisieren */ if (rc = DosGetNamedSharedMem ((PPVOID) &pShareInitOS2, SHARE_INITOS2, PAG_READ | PAG_WRITE)) { if (rc = DosAllocSharedMem( (PPVOID) &pShareInitOS2, // Pointer to shared mem SHARE_INITOS2, // Name CCHSHARE_INITOS2, // Size of shared mem PAG_COMMIT | PAG_READ | PAG_WRITE)) // Flags return(1); else { /* Shared Memory initialisieren */ memset (pShareInitOS2, '\0', CCHSHARE_INITOS2); pShareInitOS2->pszRegFile = (PCHAR) pShareInitOS2 + sizeof(*pShareInitOS2); strcpy (pShareInitOS2->pszRegFile, DosScanEnv (ENV_SYSTEM_INI, &pcEnv) ? "" : pcEnv); pShareInitOS2->pszRootUserIni = pShareInitOS2->pszRegFile + strlen(pShareInitOS2->pszRegFile) + 1; pShareInitOS2->pszRootSystemIni = pShareInitOS2->pszRootUserIni + 1; pShareInitOS2->pszUserIni = pShareInitOS2->pszRootSystemIni + 1; pShareInitOS2->pszSystemIni = pShareInitOS2->pszUserIni + CCHMAXPATH; pShareInitOS2->pszEnvironment = pShareInitOS2->pszSystemIni + CCHMAXPATH; } } DebugS (1, "Shared Memory initialized"); /* Semaphoren organisieren */ rc = DosOpenEventSem (HEV_SAMMY, &hevSammy); if( rc ) rc = DosCreateEventSem( HEV_SAMMY, // Name &hevSammy, // Pointer to sem 0, // Not used with named sems FALSE); // Initial state (FALSE = SET) else /* Sammy ist bereits installiert */ { pShareInitOS2->pszEnvironment[0] = '\0'; pShareInitOS2->pszEnvironment[1] = '\0'; pShareInitOS2->pszSystemIni[0] = '\0'; pShareInitOS2->pszUserIni[0] = '\0'; DosPostEventSem(hevSammy); goto Exit; } if( rc ) { intSammyRetCode = rc; goto Exit; } rc = DosOpenEventSem (HEV_PRFRESETLOCK, &hevPrfResetLock); if( rc ) rc = DosCreateEventSem( HEV_PRFRESETLOCK, // Name &hevPrfResetLock, // Pointer to sem 0, // Not used with named sems TRUE); // Initial state (TRUE = POSTED) if( rc ) { intSammyRetCode = rc; goto Exit; } DebugS (1, "Semaphores initialized"); ChangeWPS(pShareInitOS2->pszUserIni, pShareInitOS2->pszSystemIni); /* Hintergrundloop starten, das Shell mit aktueller Env. startet */ DosCreateThread (&tid1, (PFNTHREAD) thStartProg, (ULONG) ((argc > 1) ? argv[1] : ""), 0, THREADSTACK); DebugS (1, "Background loop started"); /* Hintergrundloop starten, das jeweils nach L�schen einer Semaphore */ /* einen prfReset initiiert */ DosCreateThread (&tid2, (PFNTHREAD) thSwitch, (ULONG) 0, 0, THREADSTACK); while (WinGetMsg (hab, &qmsg, 0, 0, 0)) WinDispatchMsg (hab, &qmsg); if (intSammyRetCode) { DosKillThread (tid1); DosKillThread (tid2); WinSetObjectData(WinQueryObject("<WP_DESKTOP>"), "WORKAREA=NO"); WinPostMsg(WinQueryWindow(HWND_DESKTOP, QW_BOTTOM), WM_CLOSE, 0, 0); WinAlarm (HWND_DESKTOP, WA_ERROR); prfProfile.pszSysName = (DosScanEnv (ENV_SYSTEM_INI, &pcEnv) ? "" : pcEnv); prfProfile.pszUserName = (DosScanEnv (ENV_USER_INI, &pcEnv) ? "" : pcEnv); prfProfile.cchUserName = strlen(prfProfile.pszUserName); prfProfile.cchSysName = strlen(prfProfile.pszSysName); DosSleep (1000); DosKillProcess( DKP_PROCESSTREE, ulShellID ); if ( !PrfReset(hab, &prfProfile)) WinSetObjectData(WinQueryObject("<WP_DESKTOP>"), "OPEN=ICON;WORKAREA=YES"); } Exit: WinDestroyMsgQueue(hmq); WinTerminate(hab); DebugS (1, "Application terminated"); return intSammyRetCode; }
BOOL ChangeWPS(PCHAR pszUserIni, PCHAR pszSystemIni) { PCHAR pcEnv; PRFPROFILE prfProfile; BOOL bSuccess; if (*pszSystemIni == '\0') prfProfile.pszSysName = pShareInitOS2->pszRootSystemIni; else prfProfile.pszSysName = pszSystemIni; if (*prfProfile.pszSysName == '\0') prfProfile.pszSysName = (DosScanEnv (ENV_SYSTEM_INI, &pcEnv) ? "" : pcEnv); if (*pszUserIni == '\0') { prfProfile.pszUserName = pShareInitOS2->pszRootUserIni; pShareInitOS2->ulFlag = pShareInitOS2->ulFlag_Root; // ulFlag f�r Rootdesktop } else prfProfile.pszUserName = pszUserIni; if (*prfProfile.pszUserName == '\0') prfProfile.pszUserName = (DosScanEnv (ENV_USER_INI, &pcEnv) ? "" : pcEnv); prfProfile.cchUserName = strlen(prfProfile.pszUserName); prfProfile.cchSysName = strlen(prfProfile.pszSysName); if (ulOldFlag & CLOSEAPPL) WinSetObjectData(WinQueryObject("<WP_DESKTOP>"), "WORKAREA=YES"); else WinSetObjectData(WinQueryObject("<WP_DESKTOP>"), "WORKAREA=NO"); WinPostMsg(WinQueryWindow(HWND_DESKTOP, QW_BOTTOM), WM_CLOSE, 0, 0); DebugS (1, "HWND_DESKTOP closed"); if( hevPrfResetLock ) { DosWaitEventSem (hevPrfResetLock, SEM_INDEFINITE_WAIT); DosSleep(1000); DebugS (1, "hevPrfResetLock released"); } else DosSleep(20000); bSuccess = PrfReset(hab, &prfProfile); DebugULd (1, "PrfReset", "return", bSuccess); /* * Beim Umschalten auf den Root, egal ob von Sammy oder von WPSamF ausgel�st, * wird die Shell vom PrfReset nicht geschlossen. * Solange die Ursache nicht bekannt ist, bleibt nichts anderes �brig, * als an dieser Stelle symptomatisch vorzugehen und die Shell abzuschie�en. */ if (*pszUserIni == '\0') { DosSuspendThread (tid1); DosKillProcess( DKP_PROCESSTREE, ulShellID ); // sog. Budnik'scher Arschtritt DebugS (1, "Shell killed"); DosResumeThread (tid1); } if( !bSuccess ) { WinSetObjectData(WinQueryObject("<WP_DESKTOP>"), "OPEN=ICON;WORKAREA=YES"); DebugS (1, "Desktop set to <WP_DESKTOP>"); intSammyRetCode = 250; WinPostQueueMsg (hmq, WM_QUIT, 0L, 0L); } else ulOldFlag = pShareInitOS2->ulFlag; return( bSuccess ); }