This example calls WinStartApp in a typical termination sequence.
#define INCl_DOSSESMGR #include <os2.h> HWND hwndNotify; PPROGDETAILS pDetails; HAPP happ; pDetails = (PPROGDETAILS) malloc( sizeof(PROGDETAILS) ); /* Allocate structure */ pDetails->Length = sizeof(PROGDETAILS); pDetails->progt.progc = PROG_WINDOWABLEVIO; pDetails->progt.fbVisible = SHE_VISIBLE; pDetails->pszTitle = "TEXT"; pDetails->pszExecutable = "TEXT.EXE"; pDetails->pszParameters = NULL; pDetails->pszStartupDir = ""; pDetails->pszICON = "T.ICO"; pDetails->pszEnvironment = "WORKPLACE\0\0"; pDetails->swpInitial.fl = SWP_ACTIVATE; /* Window positioning */ pDetails->swpInitial.cy = 0; /* Width of window */ pDetails->swpInitial.cx = 0; /* Height of window */ pDetails->swpInitial.y = 0; /* Lower edge of window */ pDetails->swpInitial.x = 0; /* Left edge of window */ pDetails->swpInitial.hwndInsertBehind = HWND_TOP; pDetails->swpInitial.hwnd = hwndNotify; pDetails->swpInitial.ulReserved1 = 0; pDetails->swpInitial.ulReserved2 = 0; happ = WinStartApp(hwndNotify, pDetails, NULL, NULL, SAF_STARTCHILDAPP); . . . WinTerminateApp(happ);
The following example calls WinStartApp inorder to start Dos/Windows applications.
#define INCL_WIN #define INCL_DOSSESMGR #include <os2.h> PROGDETAILS pDetails; HAPP happ; ULONG dataLen=0; ULONG length=0; BOOL rc; PSZ pBuffer; /*Query for the size of the settings for a particular key */ rc = PrfQueryProfileSize(HINI_USERPROFILE,"WINOS2","PM_GlobalWindows31Settings", if(rc dataLen > 0) { pBuffer = (PSZ)malloc((DataLen+1)*sizeof(char)); if(pBuffer) { memset(pBuffer,0,(DataLen+1)*sizeof(char)); /*Now get the settings */ length = PrfQueryProfileString(HINI_USERPROFILE,"WINOS2","PM_GlobalWindows31Settings",NULL,pBuffer,dataLen); /* The settings retrieved from USERPROFILE are seperated with a ';'. These will have to be replaced with a '\0' and an additional '\0' will have to be inserted into tthe string at the end*/ if(length > 0) { pDetails.Length = sizeof(PROGDETAILS); pDetails.progt.progc = PROG_31_STDSEAMLESSCOMMON; pDetails.progt.fbVisible = SHE_VISIBLE; pDetails.pszTitle = "Calculator"; pDetails.pszExecutable = "calc.exe"; pDetails.pszParameters = NULL; pDetails.pszStartupDir = NULL; pDetails.pszIcon = NULL; pDetails.pszEnvironment = pBuffer; pDetails.swpInitial.fl = SWP_SHOW; pDetails.swpInitial.cy = 0; pDetails.swpInitial.cx = 0; pDetails.swpInitial.y = 0; pDetails.swpInitial.x = 0; pDetails.swpInitial.hwndInsertBehind = HWND_TOP; pDetails.swpInitial.hwnd = (HWND)NULL; pDetails.swpInitial.ulReserved1 = 0; pDetails.swpInitial.ulReserved2 = 0; happ = WinStartApp((HWND)NULL, INSTALLEDCMDLINE); } } }