Esempio n. 1
0
/*************************************************************************\
 * function WriteProfile()
 * Trys to open the file "bermuda.ini" and saves game specific options 
 * from the profile data. 
\*************************************************************************/
BOOL WriteProfile( HAB hab )
{
	HINI hini;
	PSZ pszIniNameCopy;
	ULONG tmpLineStyle;
	BOOL  tmpSound;


	pszIniNameCopy = (PSZ)alloca( strlen( pszIniName ) + 1);
	strcpy( pszIniNameCopy, pszIniName );
	if ( !(hini = PrfOpenProfile( hab, pszIniNameCopy )) ) goto Error;
	if( !PrfWriteProfileString( hini, pszAppName,
										 PrfKeys.pszVersion, pszVersion ) )
		goto Error;
	// write line style settings
	tmpLineStyle = InfoData.GetLineStyle();
	if( !PrfWriteProfileData( hini, pszAppName, PrfKeys.pszLineStyle,
									  &tmpLineStyle, (ULONG)sizeof( ULONG ) ) )
		goto Error;
	// write sound flag
	tmpSound = Sound::GetSoundWanted();
	if( !PrfWriteProfileData( hini, pszAppName, PrfKeys.pszSound,
		 &tmpSound, (ULONG)sizeof( BOOL ) ) )
		 goto Error;

	if( !StoreWindowPos( hini, pszAppName, PrfKeys.pszWinPos, hwndFrame ) )
		goto Error;
	PrfCloseProfile( hini );
	return TRUE;
Error:
	PrfCloseProfile( hini );
	return FALSE;
}
Esempio n. 2
0
VOID SaveScoresToIni( VOID )
{
    hini = PrfOpenProfile(habMain, "MAKMAN.INI");

    PrfWriteProfileData(hini, szAppName, "ScoreNames", topNames, 15*100);
    PrfWriteProfileData(hini, szAppName, "Scores", topScores, 15 * sizeof(long));

    PrfCloseProfile(hini);

}
Esempio n. 3
0
//save current settings to the given ini file
BOOL CBZSave(HINI hIni, char szClass[], PVOID pData, char szCustomName[])
{
    PLUGINSHARE *pPluginShare;
    char szShareName[32];
    char szSaveName[128];

    pPluginShare = (PLUGINSHARE *) pData;
    //if null, this is a default apply, so load shared memory.
    if (pPluginShare == NULL)
    {
        strcpy(szShareName, PLUGIN_SHARE);
        strcat(szShareName, szClass);

        // if shared mem is not available, try allocating temporary space!
        if (DosGetNamedSharedMem((PPVOID) & pPluginShare, szShareName, PAG_READ | PAG_WRITE) != NO_ERROR)
        {
            //try Allocating temporary space for the plugin data so we can write to the ini file
            if (DosAllocMem((PPVOID) & pPluginShare,
                            sizeof(PLUGINSHARE),
                            PAG_READ | PAG_WRITE | PAG_COMMIT) != NO_ERROR)
                return (FALSE);     //No Good... can't save.

        }

        //write pPluginShare to the ini file!
        strcpy(szSaveName, szClass);
        strcat(szSaveName, "_CBZLINESPlugin");
        PrfWriteProfileData(hIni,
                            "UserOptionsData",
                            szSaveName,
                            pPluginShare,
                            sizeof(PLUGINSHARE));

        DosFreeMem(pPluginShare);
    }
    else
    {
        strcpy(szSaveName, szCustomName);
        strcat(szSaveName, "_");
        strcat(szSaveName, szClass);
        strcat(szSaveName, "_CBZLINESPlugin");

        PrfWriteProfileData(hIni,
                            "CustomOptionsData",
                            szSaveName,
                            pPluginShare,
                            sizeof(PLUGINSHARE));

    }

    return (TRUE);
}
//===========================================================================
// Deregister a WPS class by removing its data from OS2SYS.INI.
// Parameters --------------------------------------------------------------
// HWND hwnd                : window handle
// PSWPCLASSLIST pClassList : WPS class list data previously retrieved
//                            from OS2SYS.INI.
// PSZ pClassName           : name of the WPS to be removed.
// Return value ------------------------------------------------------------
// BOOL : TRUE/FALSE (success/error)
//===========================================================================
static
BOOL deleteWPSClassData(HWND hwnd, PWPSCLASSLIST pClassList, PSZ pClassName) {
   PWPSCLASSENTRY pClass, pNextClass;
   PBYTE pEnd;
   ULONG cbDel;
   pEnd = (PBYTE)pClassList + pClassList->cbData;
   // loop through the whole class list
   for (pClass = &pClassList->aClass[0];
        (PBYTE)pClass < pEnd;
        pClass = (PWPSCLASSENTRY)((PBYTE)pClass + pClass->offNext)) {
      // match found
      if (!strcmp(pClass->achClass, pClassName)) {
         cbDel = pClass->offNext;
         pNextClass = PNEXTCLASS(pClass);
         // remove all the data of the current class
         memmove(pClass, pNextClass, (ULONG)pEnd - (ULONG)pNextClass);
         pClassList->cbData -= cbDel;
         // update OS2SYS.INI
         if (PrfWriteProfileData(HINI_SYSTEM,
                                 PRF_WPSCLASSESAPP, PRF_WPSCLASSESKEY,
                                 pClassList, pClassList->cbData)) {
            return TRUE;
         } else {
            notifyError(hwnd, SZERR_UPDATEOS2SYSINI);
         } /* endif */
      } /* endif */
   } /* endfor */
   return FALSE;
}
Esempio n. 5
0
BOOL Profile::PutString ( char *ItemName, char *Item ) {

   if ( !IsReady() ) 
      return ( FALSE ) ;

#ifdef __OS2__

   if ( !PrfWriteProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, strlen(Item)+1 ) ) {
      char Message [512] ;
      Log ( "Profile::PutString: Could not put INI item.  App %s, Item %s, Value %s.  %s", Name, ItemName, Item, InterpretWinError(0,Message) ) ;
      return ( FALSE ) ;
   } /* endif */

#else // __NT__

   if ( ProfileName[0] ) {
      if ( !WritePrivateProfileString ( Name, ItemName, Item, ProfileName ) ) {
         char Message [512] ;
         Log ( "Profile::PutString: Could not put INI item.  App %s, Item %s, Value %s.  %s", Name, ItemName, Item, InterpretWinError(0,Message) ) ;
         return ( FALSE ) ;
      } /* endif */
   } else {
      if ( !WriteProfileString ( Name, ItemName, Item ) ) {
         char Message [512] ;
         Log ( "Profile::PutString: Could not put INI item.  App %s, Item %s, Value %s.  %s", Name, ItemName, Item, InterpretWinError(0,Message) ) ;
         return ( FALSE ) ;
      } /* endif */
   } /* endif */

#endif // __OS2__ vs __NT__

   return ( TRUE ) ;

} /* endmethod */
Esempio n. 6
0
/*
	write_profile_data
	Write configuration data to the selected INI file.
	There should be no reason to alter the code.
*/
void	write_profile_data()
{
	if(*ini_filename)
		return; 	// don't write if not OS2.INI

	PrfWriteProfileData(HINI_USER, (PSZ)application_name, (PSZ)modulename, (PSZ)&configuration_data, sizeof(configuration_data));
}
void        StoreSort( void)

{
    SHORT   asSort[2];

    // if these values are all set to their defaults, eliminate any
    // existing ini entry;  otherwise, construct the entry & save it
    if (sSortSense == 1 && chAsc == 0x1F)
        PrfWriteProfileData( HINI_USERPROFILE, CAMINI_APP, CAMINI_SORT, 0, 0);
    else
    {
        asSort[0] = (sSortSense < 0 ? TRUE : FALSE);
        asSort[1] = (chAsc == 0x1F ? FALSE : TRUE);
        PrfWriteProfileData( HINI_USERPROFILE, CAMINI_APP, CAMINI_SORT,
                             asSort, sizeof(asSort));
    }

    return;
}
Esempio n. 8
0
void Profile::Reset ( ) { 
   #ifdef __OS2__
      PrfWriteProfileData ( Handle, PSZ(Name), 0, 0, 0 ) ; 
   #else // __NT__
      if ( ProfileName[0] ) {
         WritePrivateProfileString ( Name, 0, 0, ProfileName ) ;
      } else {
         WriteProfileString ( Name, 0, 0 ) ;
      } /* endif */
   #endif // __OS2__ vs __NT__
} /* endmethod */
Esempio n. 9
0
BOOL CopyProfile(HINI hSourceProfile,HINI hDestinationProfile)
{
    int iAppIndex;
    int iKeyIndex;
    char *pKeyNames;
    char *pAppNames;
    char *pAppName;
    char *pKeyName;
    ULONG ulAppSize;
    ULONG ulDataSize;
    ULONG ulKeySize;
    void *pData;

    PrfQueryProfileSize(hSourceProfile,0L,0L,&ulAppSize);
    if ((pAppNames = malloc(ulAppSize + 1)) == NULL)
        return(FALSE);
    PrfQueryProfileString(hSourceProfile,0L,0L,0L,pAppNames,ulAppSize);
    iAppIndex = 0;
    while (iAppIndex < ulAppSize)
    {
        pAppName = &pAppNames[iAppIndex];
        PrfQueryProfileSize(hSourceProfile,pAppName,0L,&ulKeySize);
        if ((pKeyNames = malloc(ulKeySize + 1)) == NULL)
        {
            free (pAppNames);
            return(FALSE);
        }
        PrfQueryProfileString(hSourceProfile,pAppName,0L,0L,pKeyNames,ulKeySize);
        iKeyIndex = 0;
        while (iKeyIndex < ulKeySize)
        {
            pKeyName = &pKeyNames[iKeyIndex];
            PrfQueryProfileSize(hSourceProfile,pAppName,pKeyName,&ulDataSize);
            if ((pData = malloc(ulDataSize + 1)) != NULL)
            {
                PrfQueryProfileData(hSourceProfile,pAppName,pKeyName,pData,&ulDataSize);
                PrfWriteProfileData(hDestinationProfile,pAppName,pKeyName,pData,ulDataSize);
                free(pData);
            }
            while(pKeyNames[iKeyIndex++] != 0);
            if (pKeyNames[iKeyIndex] == 0)
                break;;
        }
        free(pKeyNames);
        while(pAppNames[iAppIndex++] != 0);
        if (pAppNames[iAppIndex] == 0)
            break;;
    }
    free(pAppNames);
    return(TRUE);
}
Esempio n. 10
0
void        DrvMenuCmd( HWND hwnd, ULONG ulCmd)

{
    ULONG   ulOld = ulDrvOpts;

do {
    if (ulCmd == IDM_AUTOMOUNT) {
        ulDrvOpts ^= CAMDRV_NOLVM;
        WinSendDlgItemMsg( hwnd, FID_MENU, MM_SETITEMATTR,
                           MPFROM2SHORT( ulCmd, TRUE),
                           MPFROM2SHORT( MIA_CHECKED,
                           ((ulDrvOpts & CAMDRV_NOLVM) ? 0 : MIA_CHECKED)));
        break;
    }

    ulDrvOpts &= ~CAMDRV_EJECTMASK;
    if (ulCmd == IDM_EJECTALWAYS)
        ulDrvOpts |= CAMDRV_ALWAYSEJECT;
    else
    if (ulCmd == IDM_EJECTNEVER)
        ulDrvOpts |= CAMDRV_NEVEREJECT;
    else
    if (ulCmd != IDM_EJECTDLG) {
        ulDrvOpts = ulOld;
        break;
    }

    WinSendDlgItemMsg( hwnd, FID_MENU, MM_SETITEMATTR,
                       MPFROM2SHORT( IDM_EJECTDLG, TRUE),
                       MPFROM2SHORT( MIA_CHECKED,
                       ((ulCmd == IDM_EJECTDLG) ? MIA_CHECKED : 0)));
    WinSendDlgItemMsg( hwnd, FID_MENU, MM_SETITEMATTR,
                       MPFROM2SHORT( IDM_EJECTNEVER, TRUE),
                       MPFROM2SHORT( MIA_CHECKED,
                       ((ulCmd == IDM_EJECTNEVER) ? MIA_CHECKED : 0)));
    WinSendDlgItemMsg( hwnd, FID_MENU, MM_SETITEMATTR,
                       MPFROM2SHORT( IDM_EJECTALWAYS, TRUE),
                       MPFROM2SHORT( MIA_CHECKED,
                       ((ulCmd == IDM_EJECTALWAYS) ? MIA_CHECKED : 0)));

} while (0);

    if (ulDrvOpts != ulOld)
        PrfWriteProfileData( HINI_USERPROFILE, CAMINI_APP, CAMINI_DRVOPTS,
                             &ulDrvOpts, sizeof(ulDrvOpts));

    return;
}
Esempio n. 11
0
void        DrvSetUseLvm( HWND hwnd, BOOL fUse)

{
    if ((fUse && (ulDrvOpts & CAMDRV_NOLVM)) ||
        (!fUse && !(ulDrvOpts & CAMDRV_NOLVM))) {
        ulDrvOpts ^= CAMDRV_NOLVM;

        PrfWriteProfileData( HINI_USERPROFILE, CAMINI_APP, CAMINI_DRVOPTS,
                             &ulDrvOpts, sizeof(ulDrvOpts));

        WinSendDlgItemMsg( hwnd, FID_MENU, MM_SETITEMATTR,
                           MPFROM2SHORT( IDM_AUTOMOUNT, TRUE),
                           MPFROM2SHORT( MIA_CHECKED,
                           (CAMDRV_IS_NOLVM ? 0 : MIA_CHECKED)));
    }

    return;
}
Esempio n. 12
0
/*
	load_configuration_data
	Load all module configuration data from the INI-file into the
	configuration_data structure, if not done already loaded.
*/
void	load_configuration_data(void)
{
	if(configuration_data_loaded == FALSE){
		// data not loaded yet
		ULONG	size;
		BOOL	fSuccess;
		// get name of the saver module (stored as resource string)
		if(WinLoadString(hab, hmodDLL, IDS_MODULENAME,
		  SAVER_NAME_MAXLEN, (PSZ)modulename) == 0){
			// resource string not found. indicate error by
			// setting module name to empty string (the name
			// "" is interpreted as an error by SSDLL.DLL and
			// the module does not show up in the list box).
			strcpy(modulename, "");
			return;
		}
		// load data from INI-file. the key name is the name of the
		// saver module
		size = sizeof(configuration_data);
		fSuccess = PrfQueryProfileData(HINI_USER,
		  (PSZ)application_name, (PSZ)modulename,
		  (PSZ)&configuration_data, &size);
		if(!fSuccess || size != sizeof(configuration_data) || configuration_data.version != MODULEVERSION){
			// if entry is not found or entry has invalid size or
			// entry has wrong version number, create a new entry
			// with default values and write it to the INI-file
			configuration_data.version = MODULEVERSION;
			configuration_data.enabled = TRUE;
			configuration_data.animation_speed = CONFIGURATION_DEFAULT_ANIMATIONSPEED;
/*
			$$$$$ insert code here $$$$$
			If you have added data to the configuration_data
			structure, insert code here to set the default
			values for your data items.

			$$$$$ for example $$$$$
			configuration_data.count = CONFIGURATION_DEFAULT_COUNT;
*/
			configuration_data.drunken = DRUNKEN;
			PrfWriteProfileData(HINI_USER, (PSZ)application_name, (PSZ)modulename, (PSZ)&configuration_data, sizeof(configuration_data));
		}
		configuration_data_loaded = TRUE;
	}
}
Esempio n. 13
0
/*************************************************************************\
 * function StoreWindowPos
 * This function is meant as a replacement for the os/2 library function
 * WinStoreWindowPos. It stores the current size and postion of the window
 * hwnd (window handle) to the profile hini (profile handle).
 * I use my own function because the original always stores it's
 * information in os2.ini which slows down system performace. 
 * Note: The function WinStoreWindowPos does a bit more. It also saves
 * the presentation parameters (i.e. color, fonts etc) of the window.
 * Because I don't need this it's not included here. (It would be a lot of
 * stupid work.)
 * Like the original this function returns TRUE if it was successful and
 * FALSE otherwise.
\*************************************************************************/
BOOL StoreWindowPos(	const HINI hini, const PSZ pszAppName,
							const PSZ pszKeyName, const HWND hwnd )
{
    SWP swp;				/* structure to save window information returned
					 * by WinQueryWindowPos 									*/
    LONG lWinPos[4];
	
	
    if ( !WinQueryWindowPos( hwnd, &swp ) ) return FALSE;
    lWinPos[0] = swp.x;
    lWinPos[1] = swp.y;
    lWinPos[2] = swp.cx;
    lWinPos[3] = swp.cy;
    /* write the values of swp.cy, swp.cx, swp.y and swp.x only */
    if ( !PrfWriteProfileData( hini, pszAppName, pszKeyName,
			       lWinPos, 4 * sizeof( LONG ) )
	) return FALSE;
    return TRUE;
}
Esempio n. 14
0
BOOL Profile::PutItem ( char *ItemName, void *Item, int Size ) {

   if ( !IsReady() ) 
      return ( FALSE ) ;

   #ifdef __OS2__

      if ( !PrfWriteProfileData ( Handle, PSZ(Name), PSZ(ItemName), Item, Size ) ) {
         char Message [512] ;
         Log ( "Profile::PutItem: Could not put INI item.  App %s, Item %s, size %i.  %s", Name, ItemName, Size, InterpretWinError(0,Message) ) ;
         return ( FALSE ) ;
      } /* endif */

   #else // __NT__

      char *Buffer = new char [Size*2+1] ;
      if ( Buffer ) {
         for ( int i=0; i<Size; i++ ) 
            sprintf ( &Buffer[i*2], "%02X", ((unsigned char*)Item)[i] ) ;
         if ( ProfileName[0] ) {
            if ( !WritePrivateProfileString ( Name, ItemName, Buffer, ProfileName ) ) {
               char Message [512] ;
               Log ( "Profile::PutString: Could not put INI item.  App %s, Item %s, Value %s.  %s", Name, ItemName, Buffer, InterpretWinError(0,Message) ) ;
               return ( FALSE ) ;
            } /* endif */
         } else {
            if ( !WriteProfileString ( Name, ItemName, Buffer ) ) {
               char Message [512] ;
               Log ( "Profile::PutString: Could not put INI item.  App %s, Item %s, Value %s.  %s", Name, ItemName, Buffer, InterpretWinError(0,Message) ) ;
               return ( FALSE ) ;
            } /* endif */
         } /* endif */
         delete [] Buffer ;
      } else {
         Log ( "Profile::PutItem: Could not put INI item.  App %s, Item %s, size %i.  Insufficient memory.", Name, ItemName, Size ) ;
         return ( FALSE ) ;
      } /* endif */

   #endif // __OS2__ vs __NT__

   return ( TRUE ) ;

} /* endmethod */
Esempio n. 15
0
//************************************************************************************************
// The not so mighty ShutdownThread
//************************************************************************************************
void _Optlink ShutdownThread(void *pArg)
{
   HWND           hWnd = (HWND)pArg;
   AnchorBlock    ab;
   MessageQueue   mq(ab);

   ULONG            ulError = 0;
   MCI_STATUS_PARMS msp;
   MCI_GENERIC_PARMS mciGenericParms;
   USHORT           usDeviceID = WinQueryWindowUShort(hWnd, QWS_DEVICEID);

   //*********************************************************************************************
   // Set the lowest posible priority to make us systemfriendly
   //*********************************************************************************************
   DosSetPriority(PRTYS_THREAD, PRTYC_IDLETIME, PRTYD_MINIMUM, 0);


   //*********************************************************************************************
   // Store windowpositoin
   //*********************************************************************************************
   SWP   swp;
   WinQueryWindowPos(WinQueryWindow(hWnd, QW_PARENT), &swp);
   PrfWriteProfileData(HINI_USERPROFILE, "WavePlayer", "WindowPosition", (PVOID)&swp, sizeof(swp));

   memset((void*)&msp, 0, sizeof(msp));

   msp.ulItem = MCI_STATUS_MODE;
   ulError = mciSendCommand(usDeviceID, MCI_STATUS, MCI_WAIT | MCI_STATUS_ITEM, (PVOID)&msp, (USHORT)0);

   mciGenericParms.hwndCallback = NULL;

   if(msp.ulReturn == MCI_MODE_PLAY)
      mciSendCommand(usDeviceID, MCI_STOP, MCI_WAIT, (PVOID)&mciGenericParms, NULL);

   mciSendCommand(usDeviceID, MCI_CLOSE, MCI_WAIT, (PVOID)&mciGenericParms, (USHORT)0);

   plNuke(hWnd);

   WinPostMsg(hWnd, WM_QUIT, NULL, NULL);

   _endthread();
}
Esempio n. 16
0
BOOL PRF_SetProfileData (PPRF_PROFILEDATA CustomPtr) {
   HMODULE DLLHandle    = 0;
   PVOID   ResourcePtr  = 0;
   ULONG   ResourceSize = 0;
   HINI    INIHandle    = 0;
   BOOL    ErrorOccured = FALSE;
   BOOL    NeedToClose  = FALSE;

   if ((DLLHandle = DLL_Load(CustomPtr->Dll))!=0) {
      if (DLL_GetDataResource (DLLHandle, CustomPtr->Id, &ResourcePtr, &ResourceSize)) {
         // Uppercase filename...
         strupr (CustomPtr->Ini);

         // Check for hardcoded SYSTEM/USER...
         if (strcmp(CustomPtr->Ini, "HINI_SYSTEM")==0) {
            INIHandle = HINI_SYSTEMPROFILE;
          } else if (strcmp(CustomPtr->Ini, "HINI_USER")==0) {
            INIHandle = HINI_USERPROFILE;
          } else {
            // We assume that the string is an INI-Filename...
            if (!(INIHandle   = PrfOpenProfile(MINSTALL_PMHandle, CustomPtr->Ini)))
               ErrorOccured = TRUE;
            NeedToClose = TRUE;
          }
       } else ErrorOccured = TRUE;
    } else ErrorOccured = TRUE;

   if (INIHandle) {
      // Got valid INI-Handle, so write the string...
      ErrorOccured = !PrfWriteProfileData(INIHandle, CustomPtr->AppName, CustomPtr->KeyName, ResourcePtr, ResourceSize);
    } else ErrorOccured = TRUE;

   if (NeedToClose) PrfCloseProfile(INIHandle);
   if (DLLHandle)   DLL_UnLoad(DLLHandle);
   return !ErrorOccured;
 }
Esempio n. 17
0
/****************************************************************************
   Main Message Cue Dialog Procedure
*****************************************************************************/
MRESULT EXPENTRY MainDlgProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    {
        BOOL    Handled = TRUE;
        MRESULT mReturn  = 0;
        ULONG   ulScrWidth, ulScrHeight;
        RECTL   Rectl;
        POINTL  Pointl;
        HINI    hini;
        ULONG   temp;

        switch (msg)
            {

                /* Called on startup */
                case WM_INITDLG:
                    ulScrWidth  = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
                    ulScrHeight = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);
                    UPDATE_HOURS = TRUE;
                    UPDATE_DATE = TRUE;
                    DTSWITCH = FALSE;
                    hini = HINI_USERPROFILE;
                    Pointl.x = Pointl.y = 10;
                    if(PrfQueryProfileSize(hini,pAppname,pKeyname,(PULONG)&temp) &&temp)
                        { 
                            if(temp == sizeof(POINTL)) PrfQueryProfileData(hini, pAppname,
                                                       pKeyname, &Pointl, (PULONG)&temp);
                        }
                    WinQueryWindowRect (hWnd, &Rectl);
/*
                    WinSetWindowPos (hWnd, HWND_TOP, Pointl.x,
                            Pointl.y, 0, 0, SWP_SHOW | SWP_MOVE | SWP_ACTIVATE);
*/
                    WinSetWindowPos (hWnd, HWND_TOP, (ulScrWidth-Rectl.xRight)/2,
                            (ulScrHeight-Rectl.yTop) - 10, 0, 0, SWP_SHOW | SWP_MOVE | SWP_ACTIVATE);
                    /* A neat little trick to float the window on top... */
                    WinFocusChange(HWND_DESKTOP,HWND_TOP,0);
                    timerID = WinStartTimer(hab, hWnd, 1, 1000L);
                    break;
                case WM_TIMER:
                    if(SHORT1FROMMP(mp1) == timerID)
                        {
                            while(DosGetDateTime( &(datetime[DTSWITCH?1:0]) ));
                            UPDATE_HOURS = (    (datetime[DTSWITCH?1:0].minutes != datetime[DTSWITCH?0:1].minutes)
                                             || (datetime[DTSWITCH?1:0].hours   != datetime[DTSWITCH?0:1].hours  ) );
                            UPDATE_DATE |= (    (datetime[DTSWITCH?1:0].day     != datetime[DTSWITCH?0:1].day    )
                                             || (datetime[DTSWITCH?1:0].weekday != datetime[DTSWITCH?0:1].weekday)
                                             || (datetime[DTSWITCH?1:0].month   != datetime[DTSWITCH?0:1].month  )
                                             || (datetime[DTSWITCH?1:0].year    != datetime[DTSWITCH?0:1].year   ) );
                            ClockSetDateString( &(datetime[DTSWITCH?1:0]));
                            DTSWITCH = !DTSWITCH;
                            if(UPDATE_HOURS)
                                {
                                    WinSetDlgItemText (hWnd, IDD_TIME, szHours);
                                    if(UPDATE_DATE)
                                        { 
                                            WinSetWindowText(hWndFrame,(PSZ)szTitle);
                                            UPDATE_DATE = FALSE;
                                        }
                                            UPDATE_HOURS = FALSE;
                                }
                            WinSetDlgItemText (hWnd, IDD_SEC, szSecs);
                        }
                    Handled = FALSE;
                    break;
                case WM_SYSCOMMAND:
                case WM_COMMAND:
                    switch (LOUSHORT(mp1))
                      {
                            case SC_CLOSE:
                                hini = HINI_USERPROFILE;
                                WinStopTimer(hab, hWnd, timerID);
                                Pointl.x = Pointl.y = 0;
                                WinMapWindowPoints(hWnd, HWND_DESKTOP, &Pointl, 1);
                                temp = sizeof(POINTL);
                                PrfWriteProfileData(hini, pAppname, pKeyname, &Pointl, temp);
                                WinPostMsg(hWnd, WM_QUIT, 0L, 0L);
                                break;
                            default:
                                Handled = (msg == WM_COMMAND);
                                break;
                        }
                    break; // forget this break and you are in dead trouble !!!
                default:
                    Handled = FALSE;
                    break;
            }
        if (!Handled) mReturn = WinDefDlgProc (hWnd, msg, mp1, mp2);
        return (mReturn);
    }
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение.
// Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением.
MRESULT EXPENTRY Keyboard_Echo_WndProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter )
{
 // Указатель на страницу.
 PPAGE Page = Enhancer.Pages.Keyboard_echo;

 // Проверяем сообщение.
 switch( Message )
  {
   // Отображаем настройки.
   case SM_SHOW_SETTINGS:
    {
     BYTE Value = 0; if( Clicker.Settings.Keyboard_echo ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_Echo.Settings.Play_sound, BM_SETCHECK, MPFROMLONG( Value ), 0 );
     WinEnableControl( Window, Keyboard_Echo.Settings.For_IRC, Value );
     WinEnableControl( Window, Keyboard_Echo.Settings.For_ICQ, Value );
     WinEnableControl( Window, Keyboard_Echo.Settings.Use_RAMFS, Value );

     Value = 0; if( Clicker.Settings.Keyboard_echo_for_IRC ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_Echo.Settings.For_IRC, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( Clicker.Settings.Keyboard_echo_for_ICQ ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_Echo.Settings.For_ICQ, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( Clicker.Settings.Cache_echo_file ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_Echo.Settings.Use_RAMFS, BM_SETCHECK, MPFROMLONG( Value ), 0 );
    }
   return 0;

   // Следим за полями ввода.
   case WM_CONTROL:
    {
     ULONG WM_Control_Window_ID = SHORT1FROMMP( First_parameter );
     ULONG WM_Control_Action_ID = SHORT2FROMMP( First_parameter );

     if( WM_Control_Window_ID == Keyboard_Echo.Settings.Play_sound )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Clicker.Settings.Keyboard_echo = 0;
           else Clicker.Settings.Keyboard_echo = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Keyboard_Echo.Settings.For_IRC )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Clicker.Settings.Keyboard_echo_for_IRC = 0;
           else Clicker.Settings.Keyboard_echo_for_IRC = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Keyboard_Echo.Settings.For_ICQ )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Clicker.Settings.Keyboard_echo_for_ICQ = 0;
           else Clicker.Settings.Keyboard_echo_for_ICQ = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Keyboard_Echo.Settings.Use_RAMFS )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Clicker.Settings.Cache_echo_file = 0;
           else Clicker.Settings.Cache_echo_file = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }
    }
   return 0;

   // Обрабатываем нажатия на кнопки.
   case WM_COMMAND:
    {
     ULONG WM_Control_Button_ID = SHORT1FROMMP( First_parameter );

     if( WM_Control_Button_ID == OK_BUTTON_ID )
      {
       CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
       HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

       if( Ini_file )
        {
         PrfWriteProfileData( Ini_file, "Settings", "Keyboard echo", &Clicker.Settings.Keyboard_echo, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Keyboard echo for IRC", &Clicker.Settings.Keyboard_echo_for_IRC, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Keyboard echo for ICQ", &Clicker.Settings.Keyboard_echo_for_ICQ, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Cache echo file", &Clicker.Settings.Cache_echo_file, sizeof( BYTE ) );

         PrfCloseProfile( Ini_file );

         BroadcastRSMessages();
         NiceReadSettings();
        }
      }

     if( WM_Control_Button_ID == PD_BUTTON_ID )
      {
       if( Page->SetDefSettings ) Page->SetDefSettings( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext1 ) Page->SetDefSettings_Ext1( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext2 ) Page->SetDefSettings_Ext2( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext3 ) Page->SetDefSettings_Ext3( Page->Settings_to_show );

       WinPostMsg( Window, WM_COMMAND, (MPARAM) OK_BUTTON_ID, 0 );
      }

     if( WM_Control_Button_ID == HP_BUTTON_ID )
      {
       Help( Page->Settings_to_show, Enhancer.Code_page );
      }
    }
   return 0;
  }

 // Возврат.
 return WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
}
/****************************************************************\
 *
 *--------------------------------------------------------------
 *
 *  Name:SaveApplication()
 *
 *  Purpose:Handle the   WM_SAVEAPPLICATION message from the desktop
 *
 *
 *
 *  Usage:
 *
 *  Method:
 *          -
 *
 *          -
 *          -
 *
 *          -
 *          -
 *
 *  Returns: VOID
 *
 *
\****************************************************************/
VOID FAR SaveApplication( HWND hwnd )
{

    WinQueryWindowPos(hwnd, (PSWP)&cp.swp);
    PrfWriteProfileData(HINI_USER, SZ_APPNAME, SZ_KEYNAME, &cp, sizeof(cp));
}
Esempio n. 20
0
static  BOOL    saveProfile(HAB hab)
{
#ifdef DEBUG
    TRACE("in saveProfile ... ") ;
#endif

    int     entry, i, id ;
    HINI    hini  ;
    BOOL    stat  ;
    ULONG   len   ;
    UCHAR   key[32] ;

#ifdef DEBUG
    TRACE("done in saveProfile\n") ;
#endif

    /*
     * save to profile
     */

    if ((hini = PrfOpenProfile(hab, ProfilePath)) == NULLHANDLE) {

#ifdef DEBUG
        TRACE("saveProfile - failed to open %s\n", ProfilePath) ;
#endif

        return FALSE ;
    }

    /*
     * re-load new profile
     */

    len = sizeof(profOrder) ;
    stat = PrfQueryProfileData(hini, ProgramName, "ORDER", profOrder, &len) ;

    if (stat != TRUE || len != sizeof(profOrder)) {
        memset(profOrder, 0xff, sizeof(profOrder)) ;
    }

    for (i = 0 ; i < MAXHOSTS ; i++) {
        if ((id = profOrder[i]) == 0xff) {
            continue ;
        }
        sprintf(key, "HOST%02d", id) ;
        len = sizeof(HOSTREC) ;
        stat = PrfQueryProfileData(hini,
                    ProgramName, key, &profHosts[id], &len) ;
        if (stat != TRUE || len != sizeof(HOSTREC)) {
            profOrder[i] = 0xff ;
        }
    }

    /*
     * select new entry
     */

    if ((entry = saveParam()) < 0) {
        PrfCloseProfile(hini) ;
        return FALSE ;
    }

    /*
     * save new order and host data
     */

    sprintf(key, "HOST%02d", entry) ;
    PrfWriteProfileData(hini, ProgramName,
                "ORDER", profOrder, sizeof(profOrder)) ;
    PrfWriteProfileData(hini, ProgramName,
                key, &profHosts[entry], sizeof(HOSTREC)) ;

    PrfCloseProfile(hini) ;

#ifdef DEBUG
    TRACE("saveProfile ... saved to %d\n", entry) ;
#endif

    return TRUE ;
}
Esempio n. 21
0
ZExport (ZProfile &) ZProfile::setValue (const ZString & aValue,
                                         const ZString & aValueName,
                                         int aType)
{
  ZFUNCTRACE_DEVELOP
    ("ZProfile::setValue(const ZString& aValue, const ZString& aValueName, int aType)");

  // find out type if auto
  if (aType == Auto)
      {
        ZString v (aValue);
        if (ZString (v.strip ().asLong ()) == v)
          aType = Integer;
        else
            {
              if (aValue.isPrintable ())
                aType = String;
              else
                aType = Binary;
            }                   // if
      }                         // if

#ifdef ZC_WIN
  long dataType;
  switch (aType)
      {
      case String:
        dataType = 1;           // String
        break;
      case Integer:
        return setValue (aValue.asLong (), aValueName);
      default:
        dataType = 3;           // Binary
      }                         // switch

  openPath (zTrue);

  if (valueExists (aValueName))
    deleteValue (aValueName);

  if (!RegSetValueEx ((HKEY) iPathHandle, aValueName, 0,
                      dataType, (LPBYTE) (const char *) aValue,
                      aValue.size ()) == ERROR_SUCCESS)
    throwSysErr (SRegSetValueEx);
#endif
#ifdef ZC_OS2
  if (!iPath.size ())
    ZTHROWEXC (MissingPath);
  if (!aValueName.size ())
    ZTHROWEXC (MissingValueName);
  openRoot ();

  switch (aType)
      {
      case String:
        if (!PrfWriteProfileString (iRootHandle, iPath, aValueName,
                                    ZString::exp (aValue)))
          throwSysErr (PrfWriteProfileStringName);
        break;
      case Integer:
        {
          ZString v (aValue);
          if (!PrfWriteProfileString (iRootHandle, iPath, aValueName,
                                      ZString (v.strip ().asLong ())))
            throwSysErr (PrfWriteProfileStringName);
          break;
        }                       // Integer
      default:
        {
          ZString val (aValue);
          if (!PrfWriteProfileData (iRootHandle, iPath, aValueName,
                                    (char *) val, val.size ()))
            throwSysErr (PrfWriteProfileDataName);
        }                       // default
      }                         // switch
#endif
  return *this;
}                               // setValue
Esempio n. 22
0
Profile::Profile
(
  PSZ     name,
  HAB     Anchor,
  HMODULE Library,
  int     DialogID,
  HWND    HelpInstance,
  BOOL    ResetFlag
) {

  /**************************************************************************
   * Save the names.                                                        *
   **************************************************************************/

   Name = new BYTE [ strlen(PCHAR(name)) + 1 ] ;
   strcpy ( PCHAR(Name), PCHAR(name) ) ;

  /**************************************************************************
   * If resetting the profile, clear the system profile information now.    *
   **************************************************************************/

   if ( ResetFlag ) {
      PrfWriteProfileData ( HINI_USERPROFILE, Name, PSZ(NULL), PSZ(NULL), 0 ) ;
   }

  /**************************************************************************
   * Query the system INI for the profile file's path.                      *
   **************************************************************************/

   PSZ ProfilePath = PSZ(NULL) ;
   ULONG Size ;

   if ( PrfQueryProfileSize ( HINI_USERPROFILE, Name, PSZ("INIPATH"), &Size ) ) {

      // The info exists.  Fetch it.
      ProfilePath = new BYTE [ Size ] ;
      PrfQueryProfileData ( HINI_USERPROFILE, Name,
         PSZ("INIPATH"), ProfilePath, &Size ) ;

      // Build the profile file name.
      BYTE FullPath [_MAX_PATH] ;
      strcpy ( PCHAR(FullPath), PCHAR(ProfilePath) ) ;
      strcat ( PCHAR(FullPath), "\\" ) ;
      strcat ( PCHAR(FullPath), PCHAR(Name) ) ;
      strcat ( PCHAR(FullPath), ".INI" ) ;

      // Clean the name up and expand it to a full path.
      BYTE Path [256] ;
      DosQueryPathInfo ( FullPath, FIL_QUERYFULLNAME, Path, sizeof(Path) ) ;

      // Does the file exist?  If not, discard the name.
      FILESTATUS3 Status ;
      if ( DosQueryPathInfo ( Path, FIL_STANDARD, &Status, sizeof(Status) ) ) {
         delete [] ProfilePath ;
         ProfilePath = PSZ(NULL) ;
      }
   }

  /**************************************************************************
   * If the profile file couldn't be found, ask the user for a path.        *
   **************************************************************************/

   if ( ProfilePath == NULL ) {
      // Set the default path.
      BYTE Path [256] ;
      DosQueryPathInfo ( PSZ("."), FIL_QUERYFULLNAME, Path, sizeof(Path) ) ;

      // Call up the entry dialog.
      PROFILE_PARMS Parms ;
      Parms.id = short ( DialogID ) ;
      Parms.hwndHelp = HelpInstance ;
      Parms.Path = Path ;
      Parms.PathSize = sizeof(Path) ;
      if ( WinDlgBox ( HWND_DESKTOP, HWND_DESKTOP, PFNWP(ProfileProcessor), Library, DialogID, &Parms ) ) {
         // If OK, save the approved path in the system profile.
         ProfilePath = new BYTE [ strlen(PCHAR(Path)) + 1 ] ;
         strcpy ( PCHAR(ProfilePath), PCHAR(Path) ) ;

         PrfWriteProfileData ( HINI_USERPROFILE, Name, PSZ("INIPATH"),
            ProfilePath, strlen(PCHAR(ProfilePath))+1 ) ;
      }
   }

  /**************************************************************************
   * Reset profile handle.  If the path could be determined . . .           *
   **************************************************************************/

   Handle = 0 ;

   if ( ProfilePath ) {

     /***********************************************************************
      * Build the full profile file name.                                   *
      ***********************************************************************/

      BYTE ProfileName [_MAX_PATH] ;
      strcpy ( PCHAR(ProfileName), PCHAR(ProfilePath) ) ;
      strcat ( PCHAR(ProfileName), "\\"  ) ;
      strcat ( PCHAR(ProfileName), PCHAR(Name) ) ;
      strcat ( PCHAR(ProfileName), ".INI" ) ;

     /***********************************************************************
      * Release the memory previously allocated to store the path.          *
      ***********************************************************************/

      if ( ProfilePath ) {
         delete [] ProfilePath ;
      }

     /***********************************************************************
      * Open/Create the profile file and return the resultant handle.       *
      ***********************************************************************/

      Handle = PrfOpenProfile ( Anchor, ProfileName ) ;

     /***********************************************************************
      * If resetting, then clean this profile out.                          *
      ***********************************************************************/

      if ( ResetFlag ) {
         PrfWriteProfileData ( Handle, Name, PSZ(NULL), PSZ(NULL), 0 ) ;
      }
   }
}
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение.
// Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением.
MRESULT EXPENTRY Keyboard_Break_WndProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter )
{
 // Указатель на страницу.
 PPAGE Page = Enhancer.Pages.Keyboard_break;

 // Проверяем сообщение.
 switch( Message )
  {
   // Отображаем настройки.
   case SM_SHOW_SETTINGS:
    {
     BYTE Value = 0; if( Controller.Settings.Suppress_CtrlAltDel ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_Break.Settings.CAD_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( Controller.Settings.Suppress_CtrlBreak ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_Break.Settings.CB_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );
    }
   return 0;

   // Следим за полями ввода.
   case WM_CONTROL:
    {
     ULONG WM_Control_Window_ID = SHORT1FROMMP( First_parameter );
     ULONG WM_Control_Action_ID = SHORT2FROMMP( First_parameter );

     if( WM_Control_Window_ID == Keyboard_Break.Settings.CAD_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Controller.Settings.Suppress_CtrlAltDel = 0;
           else Controller.Settings.Suppress_CtrlAltDel = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Keyboard_Break.Settings.CB_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Controller.Settings.Suppress_CtrlBreak = 0;
           else Controller.Settings.Suppress_CtrlBreak = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }
    }
   return 0;

   // Обрабатываем нажатия на кнопки.
   case WM_COMMAND:
    {
     ULONG WM_Control_Button_ID = SHORT1FROMMP( First_parameter );

     if( WM_Control_Button_ID == OK_BUTTON_ID )
      {
       CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
       HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

       if( Ini_file )
        {
         PrfWriteProfileData( Ini_file, "Settings", "Suppress Ctrl+Alt+Del", &Controller.Settings.Suppress_CtrlAltDel, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Suppress Ctrl+Break", &Controller.Settings.Suppress_CtrlBreak, sizeof( BYTE ) );

         PrfCloseProfile( Ini_file );

         BroadcastRSMessages();
         NiceReadSettings();
        }
      }

     if( WM_Control_Button_ID == PD_BUTTON_ID )
      {
       if( Page->SetDefSettings ) Page->SetDefSettings( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext1 ) Page->SetDefSettings_Ext1( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext2 ) Page->SetDefSettings_Ext2( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext3 ) Page->SetDefSettings_Ext3( Page->Settings_to_show );

       WinPostMsg( Window, WM_COMMAND, (MPARAM) OK_BUTTON_ID, 0 );
      }

     if( WM_Control_Button_ID == HP_BUTTON_ID )
      {
       Help( Page->Settings_to_show, Enhancer.Code_page );
      }
    }
   return 0;
  }

 // Возврат.
 return WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
}
Esempio n. 24
0
//=============================================================================
// GetOpt - подпрограмма чтения параметров из INI-файла
//=============================================================================
void GetOpt (char *INIname)
{
#ifndef CONFIG_LS
char *pBfr;
#endif
//-----------------------------------------------------------------------------
// Copy the Window position info from a private INI into OS2.INI
//-----------------------------------------------------------------------------
  hini = PrfOpenProfile(hab, INIname); // Open private profile
  if ( hini )
    {
#ifndef CONFIG_LS
    if ( PrfQueryProfileSize(hini, APPNAME, WINPOS, &ulSize) )
      {
      pBfr = calloc(ulSize, L1);
      PrfQueryProfileData(hini, APPNAME, WINPOS, pBfr, &ulSize);
      PrfWriteProfileData(HINI_USERPROFILE, APPNAME, WINPOS, pBfr, ulSize);
      free(pBfr);
      }
#endif
//-----------------------------------------------------------------------------
// Restore Options from INI file
//-----------------------------------------------------------------------------
    GetParm(AUTORUN, AutoRun);
    GetParm(AUTOLOG, AutoLog);
    GetParm(COMMONLOG, CommonLog);
    GetParm(INTERVAL, Interval);
    GetParm(BASEIND, BaseInd);
    GetParm(USEDNS, useDNS);
    GetParm(USEOTHD, useOTHD);
    GetParm(PINGTO, pingtv.tv_sec);
    GetParm(ARPTO, ArpWait);
    GetParm(TCPTO, TcpWait);
    GetParm(NUMPING, NumPing);
    GetParm(PINGSTART, PingStart);
    GetParm(PINGSTOP, PingStop);
    GetParm(NBACT, NBact);
    GetParm(NBACTP, NBactP);
    GetParm(NBADRSET, NBadrSet);
    GetParm(NBADRM, NBadrM);
#ifdef CONFIG_LS
    GetParm(NUMIPADR, NumIPadr);
    GetParm(ADDRINFO, AddrInfoIP);
    GetParm(IPINTERVAL, Interv);
    GetParm(HOSTINT, HostInt);
#else
    GetParm(NUMIPADR, TempNumIPadr);
    GetParm(ADDRINFO, TempAddrInfo);
    GetParm(IPINTERVAL, TempInterv);
    GetParm(HOSTINT, TempHostInt);
    GetParm(VERTSPLITBAR, VertSplitBar);
#endif
#ifndef DAEMON
    if ( PrfQueryProfileSize(hini, APPNAME, INITFONT, &DataLen) )
      if ( DataLen == sizeof(FONTDLG) )
        {
        PrfQueryProfileData(hini, APPNAME, INITFONT, &pfdFontdlg, &DataLen);
        sprintf(FontCntnr, "%d.%s", FIXEDINT(pfdFontdlg.fxPointSize),
                                    pfdFontdlg.fAttrs.szFacename);
#ifndef CONFIG_LS
        FontSetFl = FALSE;
#endif
        }
    GetParm(INITFONTNAME, InitFont);
#endif
    PrfCloseProfile(hini);   // Close private profile
    }
//-----------------------------------------------------------------------------
// Check (and correct) parameters
//-----------------------------------------------------------------------------
  Interval = ( Interval > L60 ) ? L60 : Interval;
  Interval = ( Interval < L5 ) ? L5 : Interval;
  Interval = ( Interval / L5 ) * L5;

  BaseInd = ( BaseInd > BaseARP ) ? BaseLS : BaseInd;

  pingtv.tv_sec = ( pingtv.tv_sec > L10) ? L10 : pingtv.tv_sec;
  pingtv.tv_sec = ( pingtv.tv_sec < L1 ) ? L1 : pingtv.tv_sec;

  if ( ArpWait <= L15 )
    {
    ArpWait = ( ArpWait < L3 ) ? L3 : ArpWait;
    ArpWait = ( ArpWait / L3 ) * L3;
    }
  else
    {
    ArpWait = ( ArpWait > L90 ) ? L90 : ArpWait;
    ArpWait = ( ArpWait < L30 ) ? L30 : ArpWait;
    ArpWait = ( ArpWait / L15 ) * L15;
    }

  TcpWait = ( TcpWait > L100 ) ? L100 : TcpWait;
  TcpWait = ( TcpWait < L10 ) ? L10 : TcpWait;
  TcpWait = ( TcpWait / L10 ) * L10;
}
Esempio n. 25
0
//called to allocate memory and setup initial settings
BOOL CBZInit(HINI hIni, char szName[], char szClass[], PVOID * pData)
{
    PLUGINSHARE *pPluginShare;
    PLUGINSHARE *pPluginData;
    char szReadName[64];
    char szShareName[64];
    ULONG szData;

    // alloc window words for the plugin's data
    if ((DosAllocMem((PPVOID) (pData),
                     sizeof(PLUGINSHARE),
                     PAG_READ | PAG_WRITE | PAG_COMMIT)) != NO_ERROR)
    {
        return FALSE;
    }

    //initialize the plugin's data to zeros.
    memset(*pData, 0, sizeof(PLUGINSHARE));

    pPluginData = (PLUGINSHARE *) * pData;

    strcpy(szShareName, PLUGIN_SHARE);
    strcat(szShareName, szClass);

    //custom name was specified, try to load the custom config for it.
    if (strlen(szName) > 0)
    {
        strcpy(szReadName, szName);
        strcat(szReadName, "_");
        strcat(szReadName, szClass);
        strcat(szReadName, "_CBZLINESPlugin");
        szData = sizeof(PLUGINSHARE);

        // get shared mem
        if (!PrfQueryProfileData(hIni,
                                 "CustomOptionsData",
                                 szReadName,
                                 pPluginData,
                                 &szData))
        {
            // if shared mem is not available, use defaults!
            if (DosGetNamedSharedMem((PPVOID) & pPluginData, szShareName, PAG_READ) != NO_ERROR)
            {
                //use some defaults?
                pPluginData->lActiveLineColor = 121 * 65536 + 127;
                pPluginData->lActiveShadowColor = 255 * (65536 + 1);
                pPluginData->lInactiveLineColor = 100 * (65536 + 256 + 1);
                pPluginData->lInactiveShadowColor = 204 * (65536 + 256 + 1);
                pPluginData->bActiveEnabled = TRUE;
                pPluginData->bInactiveEnabled = TRUE;
                pPluginData->lLineStyle = 7;

                if (!PrfWriteProfileData(hIni,
                                         "CustomOptionsData",
                                         szReadName,
                                         pPluginData,
                                         sizeof(PLUGINSHARE)))
                {
                    //not a fatal error
                }
            }
        }

    }                           //end if (szName > 0)

    else
    {
        //Load defaults!  No custom name specified.

        // if shared mem is not available, try allocating it!
        if (DosGetNamedSharedMem((PPVOID) & pPluginShare, szShareName, PAG_READ) != NO_ERROR)
        {
            //try Allocating the SharedMem space for this plugin!
            if (DosAllocSharedMem((PPVOID) & pPluginShare,
                                  szShareName,
                                  sizeof(PLUGINSHARE),
                             PAG_READ | PAG_WRITE | PAG_COMMIT) != NO_ERROR)
                return (FALSE); //ignore this plugin... It must be broken?

            // clear it
            memset(pPluginShare, 0, sizeof(PLUGINSHARE));

            szData = sizeof(PLUGINSHARE);

            // get shared mem
            strcpy(szReadName, szClass);
            strcat(szReadName, "_CBZLINESPlugin");
            if (!PrfQueryProfileData(hIni,
                                     "UserOptionsData",
                                     szReadName,
                                     pPluginShare,
                                     &szData))
            {
                pPluginShare->lActiveLineColor = 121 * 65536 + 127;
                pPluginShare->lActiveShadowColor = 255 * (65536 + 1);
                pPluginShare->lInactiveLineColor = 100 * (65536 + 256 + 1);
                pPluginShare->lInactiveShadowColor = 204 * (65536 + 256 + 1);
                pPluginShare->bActiveEnabled = TRUE;
                pPluginShare->bInactiveEnabled = TRUE;
                pPluginShare->lLineStyle = 7;

                if (!PrfWriteProfileData(hIni,
                                         "UserOptionsData",
                                         szReadName,
                                         pPluginShare,
                                         sizeof(PLUGINSHARE)))
                {
                    //not a fatal error.
                }
            }
        }                       //end if

        //copy from shared memory to each windows window words.
        pPluginData->lActiveLineColor = pPluginShare->lActiveLineColor;
        pPluginData->lActiveShadowColor = pPluginShare->lActiveShadowColor;
        pPluginData->lInactiveLineColor = pPluginShare->lInactiveLineColor;
        pPluginData->lInactiveShadowColor = pPluginShare->lInactiveShadowColor;
        pPluginData->bActiveEnabled = pPluginShare->bActiveEnabled;
        pPluginData->bInactiveEnabled = pPluginShare->bInactiveEnabled;
        pPluginData->lLineStyle = pPluginShare->lLineStyle;
    }                           //end else

    return TRUE;
}
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение.
// Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением.
MRESULT EXPENTRY Placement_Settings_WndProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter )
{
 // Указатель на страницу.
 PPAGE Page = Enhancer.Pages.Placement_settings;

 // Проверяем сообщение.
 switch( Message )
  {
   // Отображаем настройки.
   case SM_SHOW_SETTINGS:
    {
     BYTE Value = 0; if( Arranger.Settings.Arrange_VIO_windows ) Value = 1;
     WinSendDlgItemMsg( Window, Placement_Settings.Settings.VIO_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );
     WinEnableWindow( WinWindowFromID( Window, Placement_Settings.Settings.FC2_button_ID ), Value );

     Value = 0; if( Arranger.Settings.Arrange_FC2_windows ) Value = 1;
     WinSendDlgItemMsg( Window, Placement_Settings.Settings.FC2_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( Arranger.Settings.Arrange_WindowList ) Value = 1;
     WinSendDlgItemMsg( Window, Placement_Settings.Settings.WindowList_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( Arranger.Settings.Arrange_WPS_windows ) Value = 1;
     WinSendDlgItemMsg( Window, Placement_Settings.Settings.WPS_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( Arranger.Settings.Arrange_Browser_windows ) Value = 1;
     WinSendDlgItemMsg( Window, Placement_Settings.Settings.Browser_button_ID, BM_SETCHECK, MPFROMLONG( Value ), 0 );
    }
   return 0;

   // Следим за полями ввода.
   case WM_CONTROL:
    {
     ULONG WM_Control_Window_ID = SHORT1FROMMP( First_parameter );
     ULONG WM_Control_Action_ID = SHORT2FROMMP( First_parameter );

     if( WM_Control_Window_ID == Placement_Settings.Settings.VIO_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Arranger.Settings.Arrange_VIO_windows = 0;
           else Arranger.Settings.Arrange_VIO_windows = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Placement_Settings.Settings.FC2_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Arranger.Settings.Arrange_FC2_windows = 0;
           else Arranger.Settings.Arrange_FC2_windows = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Placement_Settings.Settings.WindowList_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Arranger.Settings.Arrange_WindowList = 0;
           else Arranger.Settings.Arrange_WindowList = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Placement_Settings.Settings.WPS_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Arranger.Settings.Arrange_WPS_windows = 0;
           else Arranger.Settings.Arrange_WPS_windows = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Placement_Settings.Settings.Browser_button_ID )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) Arranger.Settings.Arrange_Browser_windows = 0;
           else Arranger.Settings.Arrange_Browser_windows = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }
    }
   return 0;

   // Обрабатываем нажатия на кнопки.
   case WM_COMMAND:
    {
     ULONG WM_Control_Button_ID = SHORT1FROMMP( First_parameter );

     if( WM_Control_Button_ID == OK_BUTTON_ID )
      {
       CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
       HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

       if( Ini_file )
        {
         PrfWriteProfileData( Ini_file, "Settings", "Arrange VIO windows", &Arranger.Settings.Arrange_VIO_windows,  sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Arrange FC2 windows", &Arranger.Settings.Arrange_FC2_windows,  sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Arrange WindowList",  &Arranger.Settings.Arrange_WindowList,   sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Arrange WPS windows", &Arranger.Settings.Arrange_WPS_windows,  sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Arrange Browsers", &Arranger.Settings.Arrange_Browser_windows, sizeof( BYTE ) );

         PrfCloseProfile( Ini_file );

         BroadcastRSMessages();
         NiceReadSettings();
        }
      }

     if( WM_Control_Button_ID == PD_BUTTON_ID )
      {
       if( Page->SetDefSettings ) Page->SetDefSettings( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext1 ) Page->SetDefSettings_Ext1( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext2 ) Page->SetDefSettings_Ext2( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext3 ) Page->SetDefSettings_Ext3( Page->Settings_to_show );

       WinPostMsg( Window, WM_COMMAND, (MPARAM) OK_BUTTON_ID, 0 );
      }

     if( WM_Control_Button_ID == HP_BUTTON_ID )
      {
       Help( Page->Settings_to_show, Enhancer.Code_page );
      }
    }
   return 0;
  }

 // Возврат.
 return WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
}
Esempio n. 27
0
/*--------------------------------------------------------------------------------------*\
 * Procedure opens the profile and writes the UPS structure into.                       *
 * Req:                                                                                 *
 *      pHini ......... A pointer to the handle of the profile                          *
 *      pHab .......... A pointer to extract the anchor block of the window             *
 *      pUps .......... A pointer to the UPS structure                                  *
 * Returns:                                                                             *
 *      TRUE/FALSE .... If called sucessfully/unsucessfully                             *
\*--------------------------------------------------------------------------------------*/
BOOL    Write_Profile(HINI *pHini, HAB *pHab, UPS *pUps)
{
                                        /* First open the profile */
*pHini=PrfOpenProfile(*pHab, pucSD2Profile);
if(*pHini!=NULLHANDLE)
    {
    PrfWriteProfileData(                /* Write binary data to profile */
        *pHini,                         /* Handle of profile */
        SD2_CLASSNAME,                  /* Application name */
        "IDUBC_Hours",                  /* Key name */
        &pUps->IDUBC_Hours,             /* Value data */
        sizeof(UCHAR));                 /* Size of value data */
    PrfWriteProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUBC_Minutes",
        &pUps->IDUBC_Minutes,
        sizeof(UCHAR));
    PrfWriteProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUAS_Hours",
        &pUps->IDUAS_Hours,
        sizeof(UCHAR));
    PrfWriteProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUAS_Minutes",
        &pUps->IDUAS_Minutes,
        sizeof(UCHAR));
    PrfWriteProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUASD_Hours",
        &pUps->IDUASD_Hours,
        sizeof(UCHAR));
    PrfWriteProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUASD_Minutes",
        &pUps->IDUASD_Minutes,
        sizeof(UCHAR));
    PrfWriteProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUS_Hours",
        &pUps->IDUS_Hours,
        sizeof(UCHAR));
    PrfWriteProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUS_Minutes",
        &pUps->IDUS_Minutes,
        sizeof(UCHAR));
    PrfWriteProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_PgmName",
        pUps->IDS_PgmName);
    PrfWriteProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_PgmDirectory",
        pUps->IDS_PgmDirectory);
    PrfWriteProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_PgmInputs",
        pUps->IDS_PgmInputs);
    PrfWriteProfileData(
        *pHini,
        SD2_CLASSNAME,
        "GRP_Mode",
        &pUps->GRP_Mode,
        sizeof(ULONG));
    PrfWriteProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_UserInfo",
        pUps->IDS_UserInfo);
    return(PrfCloseProfile(*pHini));    /* Close and return result */
    }
else
    {                                   /* Profile couldn't be opened successfully */
                                        /* SHUTDOWN.INI defective logging into logfile */
    DosGetDateTime(&UPS_Current);
    UPS_LogfileIO(LF_INIFILE_PROBLEM, MPFROMP(&UPS_Current));
    return(FALSE);
    }
}
// Поток приложения вызывает WindowProc всякий раз, когда для окна есть сообщение.
// Window - окно, Message - сообщение, *_parameter - данные, которые передаются вместе с сообщением.
MRESULT EXPENTRY Keyboard_FireFox_WndProc( HWND Window, ULONG Message, MPARAM First_parameter, MPARAM Second_parameter )
{
 // Указатель на страницу.
 PPAGE Page = Enhancer.Pages.Keyboard_ffx;

 // Проверяем сообщение.
 switch( Message )
  {
   // Отображаем настройки.
   case SM_SHOW_SETTINGS:
    {
     BYTE Value = 0; if( KeyMapper.Settings.Define_Dash ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_FireFox.Settings.Dash, BM_SETCHECK, MPFROMLONG( Value ), 0 );

     Value = 0; if( KeyMapper.Settings.Define_Ctrl_Dash ) Value = 1;
     WinSendDlgItemMsg( Window, Keyboard_FireFox.Settings.Ctrl_Dash, BM_SETCHECK, MPFROMLONG( Value ), 0 );
    }
   return 0;

   // Проверяем другие настройки.
   case SM_CHECK_OTHER_SETTINGS:
    {
     CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
     HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

     if( Ini_file )
      {
       ULONG Byte = 0; ULONG Byte_data = 0;
       ULONG CopyPaste_keys_in_VIO = 0; ULONG Mouse_in_VIO = 0;

       Byte = sizeof( BYTE ); if( PrfQueryProfileData( Ini_file, "Settings", INI_CLIPPER_VIO_COPYPASTE, &Byte_data, &Byte ) ) CopyPaste_keys_in_VIO = Byte_data;
       Byte = sizeof( BYTE ); if( PrfQueryProfileData( Ini_file, "Settings", INI_CLIPPER_VIO_MOUSE, &Byte_data, &Byte ) ) Mouse_in_VIO = Byte_data;

       if( !CopyPaste_keys_in_VIO && !Mouse_in_VIO ) WinEnableControl( Window, Keyboard_FireFox.Settings.Dash, 0 );
      }
    }
   return 0;

   // Следим за полями ввода.
   case WM_CONTROL:
    {
     ULONG WM_Control_Window_ID = SHORT1FROMMP( First_parameter );
     ULONG WM_Control_Action_ID = SHORT2FROMMP( First_parameter );

     if( WM_Control_Window_ID == Keyboard_FireFox.Settings.Dash )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) KeyMapper.Settings.Define_Dash = 0;
           else KeyMapper.Settings.Define_Dash = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }

     if( WM_Control_Window_ID == Keyboard_FireFox.Settings.Ctrl_Dash )
      {
       switch( WM_Control_Action_ID )
        {
         case BN_CLICKED:
         case BN_DBLCLICKED:
          {
           ULONG Button_is_checked = (ULONG) WinSendDlgItemMsg( Window, WM_Control_Window_ID, BM_QUERYCHECK, 0, 0 );

           if( Button_is_checked ) KeyMapper.Settings.Define_Ctrl_Dash = 0;
           else KeyMapper.Settings.Define_Ctrl_Dash = 1;

           WinSendMsg( Window, SM_SHOW_SETTINGS, 0, 0 );
          }
         break;
        }
      }
    }
   return 0;

   // Обрабатываем нажатия на кнопки.
   case WM_COMMAND:
    {
     ULONG WM_Control_Button_ID = SHORT1FROMMP( First_parameter );

     if( WM_Control_Button_ID == OK_BUTTON_ID )
      {
       CHAR Settings_file_name[ SIZE_OF_PATH ] = ""; GetSettingsFileName( Settings_file_name );
       HINI Ini_file = OpenIniProfile( Enhancer.Application, Settings_file_name );

       if( Ini_file )
        {
         PrfWriteProfileData( Ini_file, "Settings", "Define Dash", &KeyMapper.Settings.Define_Dash, sizeof( BYTE ) );
         PrfWriteProfileData( Ini_file, "Settings", "Define Ctrl + Dash", &KeyMapper.Settings.Define_Ctrl_Dash, sizeof( BYTE ) );

         PrfCloseProfile( Ini_file );

         BroadcastRSMessages();
         NiceReadSettings();
        }
      }

     if( WM_Control_Button_ID == PD_BUTTON_ID )
      {
       if( Page->SetDefSettings ) Page->SetDefSettings( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext1 ) Page->SetDefSettings_Ext1( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext2 ) Page->SetDefSettings_Ext2( Page->Settings_to_show );
       if( Page->SetDefSettings_Ext3 ) Page->SetDefSettings_Ext3( Page->Settings_to_show );

       WinPostMsg( Window, WM_COMMAND, (MPARAM) OK_BUTTON_ID, 0 );
      }

     if( WM_Control_Button_ID == HP_BUTTON_ID )
      {
       Help( Page->Settings_to_show, Enhancer.Code_page );
      }
    }
   return 0;
  }

 // Возврат.
 return WinDefWindowProc( Window, Message, First_parameter, Second_parameter );
}
Esempio n. 29
0
BOOL launchPad::lpSaveObjectList()
{
  SOMClass *folderClass;
  WPFolder *wpFolder;
  char chrPath[CCHMAXPATH];
  ULONG ulBufferSize;
  HINI hIni;
  char * memPtr;
  HOBJECT *hObject;
  HOBJECT hObject2;
  int a;
  LPObject *lpoTemp;

  /* First check the config folder */
  if((hObject2=WinQueryObject(chrConfigID))==NULLHANDLE)
    {
      /* Toolbar folder lost recreate it */
      if(!checkFileExists(chrConfigTarget))
        return FALSE; /* No install dir defined */
      
      sprintf(chrPath,"OBJECTID=%s",chrConfigID);
      if((hObject2=WinCreateObject("WPFolder", chrConfigID, chrPath,chrConfigTarget,CO_FAILIFEXISTS))==NULLHANDLE)
        return FALSE; /* Can't create new toolbar folder */
    }
  
  /* Get toolbar folder */
  if(somIsObj(wpParentFolder)) {
    folderClass=wpParentFolder->somGetClass();
    if(somIsObj(folderClass))
      wpFolder=(WPFolder*)((M_WPFolder*)folderClass)->wpclsQueryFolder(chrConfigID, FALSE);
  }

  ulBufferSize=sizeof(chrPath);
  wpFolder->wpQueryRealName(chrPath, &ulBufferSize, TRUE);
  strcat(chrPath,"\\objects.ini");/* Ini-File containing the hobjects */
  
  //  WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, chrPath, "~launchPad", 123, MB_OK| MB_MOVEABLE);  
  do{
    /* Open the ini-file */
    if((hIni=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),chrPath))==NULLHANDLE)
      break; 

    if((memPtr=(char*)malloc(ulNumObjects*sizeof(HOBJECT)))==NULL)
      break;
    

    hObject=(HOBJECT*)memPtr;

    lpoTemp=lpoObjectList;
    for(a=ulNumObjects;a>0 && lpoTemp; a--)
      {
        hObject[a-1]=lpoTemp->hObject;
        lpoTemp=lpoTemp->lpoNext;
      }

    if(!PrfWriteProfileData(hIni,"objects","handles", hObject, ulNumObjects*sizeof(HOBJECT))) {
      free(hObject);
      break;
    }

    free(hObject);
    
    PrfCloseProfile(hIni);
    return TRUE;
  }while(TRUE);

  if(hIni)
    PrfCloseProfile(hIni);
  return FALSE;
}
Esempio n. 30
0
BOOL APIENTRY InstallPager(INSTALL *pstInst)
  {
  int iIndex;
  int iCountPos;
  int iDestPathEnd;
  int iSourcePathEnd;
  APIRET rc;
  BOOL bSuccess = TRUE;
  HPOINTER hPointer;
//  int iLen;
  int iFileCount;
  int iObjectCount;
  int iEnd;
  HOBJECT hObject;
  HOBJECT *phObject;
  BOOL bObjectBad;
  unsigned int uiAttrib;
  ULONG ulFileCount;
  ULONG cbDataSize = sizeof(ULONG);
  HINI hInstalledProfile;
  HINI hSourceProfile;

  hSourceProfile = PrfOpenProfile(pstInst->hab,pstInst->pszSourceIniPath);
  iEnd = sprintf(szFileNumber,"File_");
  strcpy(szDestSpec,pstInst->pszAppsPath);
  iDestPathEnd = strlen(szDestSpec);
  szDestSpec[iDestPathEnd++] = '\\';
  szDestSpec[iDestPathEnd] = 0;
  hPointer = WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,FALSE);
  WinSetPointer(HWND_DESKTOP,hPointer);

  strcpy(szSourceSpec,pstInst->pszSourcePath);
  iSourcePathEnd = strlen(szSourceSpec);
  szSourceSpec[iSourcePathEnd++] = '\\';

  szPagerEXEname[0] = 0;
  szInstallEXEname[0] = 0;

  sprintf(szInstalledIniPath,"%s%s",szDestSpec,pstInst->paszStrings[UNINSTALLINIFILENAME]);
  if (!MakePath(pstInst->hwndFrame,pstInst->pszAppsPath))
   return(FALSE);
  hInstalledProfile = PrfOpenProfile(pstInst->hab,szInstalledIniPath);
  cbDataSize = sizeof(ULONG);
  if (!PrfQueryProfileData(hInstalledProfile,"Installed","Files",&iFileCount,&cbDataSize))
    iFileCount = 0;
  if (!PrfQueryProfileData(hInstalledProfile,"Installed","Objects",&iObjectCount,&cbDataSize))
    iObjectCount = 0;
  sprintf(szPath,"%c:\\DELLOCKS.CMD",pstInst->chBootDrive);
  DosForceDelete(szPath);
  if (pstInst->bCopyCOMi)
    {
    strcpy(szDestSpec,pstInst->pszAppsPath);
    iDestPathEnd = strlen(szDestSpec);
    szDestSpec[iDestPathEnd++] = '\\';
    szDestSpec[iDestPathEnd] = 0;
    sprintf(pstInst->paszStrings[DRIVERINISPEC],"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[DDNAME]);
    if (strlen(pstInst->paszStrings[CURRENTDRIVERSPEC]) != 0)
      {
      if (strcmp(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC]) != 0)
        {
        strcpy(szPath,pstInst->paszStrings[DDNAME]);
        AppendINI(szPath);
        sprintf(szFileName,"Existing %s",szPath);
        if (pstInst->paszStrings[REMOVEOLDDRIVERSPEC] != NULL)
          strcpy(pstInst->paszStrings[REMOVEOLDDRIVERSPEC],pstInst->paszStrings[CURRENTDRIVERSPEC]);
        AppendINI(pstInst->paszStrings[DRIVERINISPEC]);
        AppendINI(pstInst->paszStrings[CURRENTDRIVERSPEC]);
        pstInst->pfnPrintProgress(szFileName,pstInst->paszStrings[DRIVERINISPEC]);
        if (pstInst->bSavedDriverIniFile)
          {
          sprintf(pstInst->paszStrings[CURRENTDRIVERSPEC],"%c:\\COMDDINI.OLD",pstInst->chBootDrive);
          DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING);
          pstInst->bSavedDriverIniFile = FALSE;
          if (pstInst->fCurrentIni != UNINSTALL_SAVE_INI)
            DosDelete(pstInst->paszStrings[CURRENTDRIVERSPEC]);
          }
        else
          if (DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING) != NO_ERROR)
            {
            sprintf(pstInst->paszStrings[CURRENTDRIVERSPEC],"%c:\\COMDDINI.OLD",pstInst->chBootDrive);
            DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING);
            DosForceDelete(pstInst->paszStrings[CURRENTDRIVERSPEC]);
            }
        }
      else
        {
        rc = DosQueryPathInfo(pstInst->paszStrings[CURRENTDRIVERSPEC],1,&stFileStatus,sizeof(FILESTATUS3));
        if ((rc == ERROR_PATH_NOT_FOUND) || (rc == ERROR_FILE_NOT_FOUND))
          {
          sprintf(pstInst->paszStrings[CURRENTDRIVERSPEC],"%c:\\COMDDINI.OLD",pstInst->chBootDrive);
          DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING);
          DosForceDelete(pstInst->paszStrings[CURRENTDRIVERSPEC]);
          }
        }
      }
    else
      {
      AppendINI(pstInst->paszStrings[DRIVERINISPEC]);
      rc = DosQueryPathInfo(pstInst->paszStrings[DRIVERINISPEC],1,&stFileStatus,sizeof(FILESTATUS3));
      if ((rc == ERROR_PATH_NOT_FOUND) || (rc == ERROR_FILE_NOT_FOUND))
        {
        sprintf(szPath,"%c:\\COMDDINI.OLD",pstInst->chBootDrive);
        DosCopy(szPath,pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING);
        DosForceDelete(szPath);
        }
      }
    AppendINI(pstInst->paszStrings[DRIVERINISPEC]);
    sprintf(&szDestSpec[iDestPathEnd],"%s",pstInst->paszStrings[DDNAME]);
    sprintf(&szSourceSpec[iSourcePathEnd],"%s",pstInst->paszStrings[DDNAME]);
    pstInst->pfnPrintProgress(pstInst->paszStrings[DDNAME],szDestSpec);
    if ((rc = DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING)) != NO_ERROR)
      {
      bSuccess = FALSE;
      if (!DisplayCopyError(pstInst->paszStrings[DDNAME],szDestSpec,rc))
        goto gtFreePathMem;
      }
    ClearReadOnly(szDestSpec);
    itoa(++iFileCount,&szFileNumber[iEnd],10);
    PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
    AppendINI(szSourceSpec);
    if (DosQueryPathInfo(szSourceSpec,FIL_STANDARD,&stFileStatus,sizeof(FILESTATUS3)) == NO_ERROR)
      {
      AppendINI(szDestSpec);
      strcpy(szPath,pstInst->paszStrings[DDNAME]);
      AppendINI(szPath);
      pstInst->pfnPrintProgress(szPath,szDestSpec);
      DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING);
      ClearReadOnly(szDestSpec);
      itoa(++iFileCount,&szFileNumber[iEnd],10);
      PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
      }
    strcpy(szFileKey,"File_");
    iCountPos = strlen(szFileKey);
    ulFileCount = 0;
    PrfQueryProfileData(hSourceProfile,"COMi","Files",&ulFileCount,&cbDataSize);
    for (iIndex = 1;iIndex <= ulFileCount;iIndex++)
      {
      itoa(iIndex,&szFileKey[iCountPos],10);
      if (PrfQueryProfileString(hSourceProfile,"COMi",szFileKey,0,szFileName,18) != 0)
        {
        if (iIndex == 1)
          strcpy(szCOMiINFname,szFileName);
        strcpy(&szDestSpec[iDestPathEnd],szFileName);
        strcpy(&szSourceSpec[iSourcePathEnd],szFileName);
        pstInst->pfnPrintProgress(szFileName,szDestSpec);
        if ((rc = DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING)) != NO_ERROR)
          {
          bSuccess = FALSE;
          if (!DisplayCopyError(szFileName,szDestSpec,rc))
            goto gtFreePathMem;
          }
        ClearReadOnly(szDestSpec);
        itoa(++iFileCount,&szFileNumber[iEnd],10);
        PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
        }
      }
    MenuItemEnable(pstInst->hwndFrame,IDM_SETUP,TRUE);
    /*
    ** This entry must be placed here so the the Configuration DLL can "find" the
    ** COMi initialization file, before the device driver is actually loaded.
    */
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Initialization",pstInst->paszStrings[DRIVERINISPEC]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Version",pstInst->paszStrings[COMIVERSION]);
    }
  if (pstInst->bCopyPager)
    {
    bCopyLibraries = TRUE;
    szPagerEXEname[0] = 0;
    strcpy(szDestSpec,pstInst->pszAppsPath);
    iDestPathEnd = strlen(szDestSpec);
    szDestSpec[iDestPathEnd++] = '\\';
    szDestSpec[iDestPathEnd] = 0;
    strcpy(szFileKey,"File_");
    iCountPos = strlen(szFileKey);
    ulFileCount = 0;
    PrfQueryProfileData(hSourceProfile,"Pager","Files",&ulFileCount,&cbDataSize);
    for (iIndex = 1;iIndex <= ulFileCount;iIndex++)
      {
      itoa(iIndex,&szFileKey[iCountPos],10);
      if (PrfQueryProfileString(hSourceProfile,"Pager",szFileKey,0,szFileName,18) != 0)
        {
        if (iIndex == 1)
          strcpy(szPagerEXEname,szFileName);
        strcpy(&szDestSpec[iDestPathEnd],szFileName);
        strcpy(&szSourceSpec[iSourcePathEnd],szFileName);
        pstInst->pfnPrintProgress(szFileName,szDestSpec);
        if (!CopyFile(szSourceSpec,szDestSpec))
          {
          bSuccess = FALSE;
          if (!DisplayCopyError(szFileName,szDestSpec,rc))
            goto gtFreePathMem;
          }
        itoa(++iFileCount,&szFileNumber[iEnd],10);
        PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
        }
      }
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGAPPNAME],"Version",pstInst->paszStrings[APPVERSION]);
    }
  if (pstInst->bCopyUtil)
    {
    strcpy(szDestSpec,pstInst->pszAppsPath);
    iDestPathEnd = strlen(szDestSpec);
    szDestSpec[iDestPathEnd++] = '\\';
    szDestSpec[iDestPathEnd] = 0;
    strcpy(szFileKey,"File_");
    iCountPos = strlen(szFileKey);
    ulFileCount = 0;
    PrfQueryProfileData(hSourceProfile,"Utilities","Files",&ulFileCount,&cbDataSize);
    for (iIndex = 1;iIndex <= ulFileCount;iIndex++)
      {
      itoa(iIndex,&szFileKey[iCountPos],10);
      if (PrfQueryProfileString(hSourceProfile,"Utilities",szFileKey,0,szFileName,18) != 0)
        {
        strcpy(&szDestSpec[iDestPathEnd],szFileName);
        strcpy(&szSourceSpec[iSourcePathEnd],szFileName);
        pstInst->pfnPrintProgress(szFileName,szDestSpec);
        if ((rc = DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING)) != NO_ERROR)
          {
          bSuccess = FALSE;
          if (!DisplayCopyError(szFileName,szDestSpec,rc))
            goto gtFreePathMem;
          }
        ClearReadOnly(szDestSpec);
        itoa(++iFileCount,&szFileNumber[iEnd],10);
        PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
        }
      }
    }
  if (pstInst->bCopyInstall)
    {
    bCopyLibraries = TRUE;
    szInstallEXEname[0] = 0;
    strcpy(szDestSpec,pstInst->pszAppsPath);
    iDestPathEnd = strlen(szDestSpec);
    szDestSpec[iDestPathEnd++] = '\\';
    szDestSpec[iDestPathEnd] = 0;
    sprintf(&szDestSpec[iDestPathEnd],pstInst->paszStrings[INIFILENAME]);
    strcpy(&szSourceSpec[iSourcePathEnd],pstInst->paszStrings[INIFILENAME]);
    PrfCloseProfile(hSourceProfile);
    DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING);
    ClearReadOnly(szDestSpec);
    hSourceProfile = PrfOpenProfile(pstInst->hab,pstInst->pszSourceIniPath);
    itoa(++iFileCount,&szFileNumber[iEnd],10);
    PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
    strcpy(szFileKey,"File_");
    iCountPos = strlen(szFileKey);
    ulFileCount = 0;
    PrfQueryProfileData(hSourceProfile,"Install","Files",&ulFileCount,&cbDataSize);
    for (iIndex = 1;iIndex <= ulFileCount;iIndex++)
      {
      itoa(iIndex,&szFileKey[iCountPos],10);
      if (PrfQueryProfileString(hSourceProfile,"Install",szFileKey,0,szFileName,18) != 0)
        {
        if (iIndex == 1)
          strcpy(szInstallEXEname,szFileName);
        strcpy(&szDestSpec[iDestPathEnd],szFileName);
        strcpy(&szSourceSpec[iSourcePathEnd],szFileName);
        pstInst->pfnPrintProgress(szFileName,szDestSpec);
        if (!CopyFile(szSourceSpec,szDestSpec))
          {
//          bSuccess = FALSE;
          if (!DisplayCopyError(szFileName,szDestSpec,rc))
            goto gtFreePathMem;
          }
        itoa(++iFileCount,&szFileNumber[iEnd],10);
        PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
        }
      }
    }
  PrfWriteProfileString(hInstalledProfile,"Installed","Program Path",pstInst->pszAppsPath);
  PrfWriteProfileData(hInstalledProfile,"Installed","Files",&iFileCount,sizeof(int));
  if (strlen(pstInst->paszStrings[CONFIGDDLIBRARYNAME]) != 0)
    {
    sprintf(pstInst->paszStrings[CONFIGAPPLIBRARYSPEC],"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGDDLIBRARYNAME]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Configuration",pstInst->paszStrings[CONFIGAPPLIBRARYSPEC]);
    }
  if (strlen(pstInst->paszStrings[CONFIGDDHELPFILENAME]) != 0)
    {
    sprintf(szPath,"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGDDHELPFILENAME]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Help",szPath);
    }
  if (strlen(pstInst->paszStrings[CONFIGAPPLIBRARYNAME]) != 0)
    {
    sprintf(pstInst->paszStrings[CONFIGAPPLIBRARYSPEC],"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGAPPLIBRARYNAME]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGAPPNAME],"Configuration",pstInst->paszStrings[CONFIGAPPLIBRARYSPEC]);
    }
  if (strlen(pstInst->paszStrings[CONFIGAPPHELPFILENAME]) != 0)
    {
    sprintf(szPath,"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGAPPHELPFILENAME]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGAPPNAME],"Help",szPath);
    }
  pstInst->bFilesCopied = TRUE;
  MenuItemEnable(pstInst->hwndFrame,IDM_SETUP,TRUE);

  if (pstInst->bCreateObjects)
    {
    bObjectBad = FALSE;
    strcpy(szFileNumber,"Object_");
    iEnd = strlen(szFileNumber);
    hObject = WinCreateObject("WPFolder",szFolderName,szFolderSetup,"<WP_DESKTOP>",CO_UPDATEIFEXISTS);
    if (hObject == 0)
      {
      sprintf(&szFolderName[strlen(szFolderName)],":1");
      hObject = WinCreateObject("WPFolder",szFolderName,szFolderSetup,"<WP_DESKTOP>",CO_UPDATEIFEXISTS);
      }
    if (hObject != 0)
      {
      itoa(++iObjectCount,&szFileNumber[iEnd],10);
      PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT));
      szDestSpec[iDestPathEnd - 1] = 0;
      sprintf(szPath,"<%s>",szFolderName);
      strcpy(szFolderName,szPath);
      if (szCOMiINFname[0] != 0)
        {
        sprintf(szSetupString,"%sEXENAME=VIEW.EXE;PARAMETERS=%s\\%s",szINFobjectSetup,szDestSpec,pstInst->paszStrings[CONFIGDDNAME]);
        sprintf(szObjectName,"%s Users Guide",pstInst->paszStrings[CONFIGDDNAME]);
        hObject = WinCreateObject("WPProgram",szObjectName,szSetupString,szFolderID,CO_UPDATEIFEXISTS);
        if (hObject != 0)
          {
          itoa(++iObjectCount,&szFileNumber[iEnd],10);
          PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT));
          }
        else
          bObjectBad = TRUE;
        }
      if (szPagerEXEname[0] != 0)
        {
        iEnd = sprintf(szSetupString,"%sEXENAME=%s\\%s;STARTUPDIR=%s;ASSOCFILTER=*.PAG;PARAMETERS=% /MSG:\"[Message: ]\" /CFG:\"%*\"",szProgramObjectSetup,szDestSpec,szPagerEXEname,szDestSpec);
        if (strlen(pstInst->paszStrings[APPICONFILE]) != 0)
          sprintf(&szSetupString[iEnd],";ICON=%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[APPICONFILE]);
        strcat(szObjectName,"Drop");
        hObject = WinCreateObject("WPProgram",szObjectName,szSetupString,szFolderID,CO_UPDATEIFEXISTS);
        if (hObject != 0)
          {
          itoa(++iObjectCount,&szFileNumber[iEnd],10);
          PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT));
          }
        else
          bObjectBad = TRUE;
        }
      if (szInstallEXEname[0] != 0)
        {
        sprintf(szSetupString,"%sEXENAME=%s\\%s;STARTUPDIR=%s",szProgramObjectSetup,szDestSpec,szInstallEXEname,szDestSpec);
        hObject = WinCreateObject("WPProgram","OS/tools Install",szSetupString,szFolderID,CO_UPDATEIFEXISTS);
        if (hObject != 0)
          {
          itoa(++iObjectCount,&szFileNumber[iEnd],10);
          PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT));
          }
        else
          bObjectBad = TRUE;
        }
      PrfWriteProfileData(hInstalledProfile,"Installed","Objects",&iObjectCount,sizeof(int));
      }
    }
  if (bObjectBad || (hObject == 0))
    {
    sprintf(szMessage,"At least one desktop object was not created due to an unknown system error.");
    sprintf(szCaption,"Object(s) Not Created!");
    WinMessageBox(HWND_DESKTOP,
                  HWND_DESKTOP,
                  szMessage,
                  szCaption,
                  0,
                 (MB_MOVEABLE | MB_OK));
    }
gtFreePathMem:
  PrfCloseProfile(hInstalledProfile);
  PrfCloseProfile(hSourceProfile);
  return(bSuccess);
  }