Esempio n. 1
0
/*
	query_profile_data
	Read configuration data from the selected INI file.
	There should be no reason to alter the code.
*/
ULONG	query_profile_data()
{
	HINI	ini_file;
	BOOL	fSuccess;
	ULONG	size;

	if(*ini_filename){
		ini_file = PrfOpenProfile(hab, (PSZ)ini_filename);
		if(ini_file == NULLHANDLE)
			ini_file = HINI_USER;
	}else
		ini_file = HINI_USER;

	size = sizeof(configuration_data);
	fSuccess = PrfQueryProfileData(ini_file,
	  (PSZ)application_name, (PSZ)modulename,
	  (PSZ)&configuration_data, &size);

	if(ini_file != HINI_USER)
		PrfCloseProfile(ini_file);
	if(fSuccess == FALSE)
		return 0;
	else
		return size;
}
Esempio n. 2
0
VOID GetOptionsFromIni( VOID )
{
    int TileSet, Input, Sound, Priority;

    hini = PrfOpenProfile (habMain, "MAKMAN.INI");

    TileSet  = PrfQueryProfileInt(hini,szAppName,"Tile Set", 1);
    Input    = PrfQueryProfileInt(hini,szAppName,"Input Source", 0);
    Sound    = PrfQueryProfileInt(hini,szAppName,"Sound Enabled", 1);
    Priority = PrfQueryProfileInt(hini,szAppName,"Priority", 0);

    if (debOut)
    {
        fprintf(debOut, "TS : %i, Input %i, Sound %i, Prio %i\n", TileSet, Input, Sound, Priority);
        fflush(debOut);
    }

    SetDefault (IDM_T_CLASSIC + TileSet);
    SetDefault (IDM_KEYBOARD + Input);
    if (Sound)
        SetDefault (IDM_SOUND_ON);
    else
        SetDefault (IDM_SOUND_OFF);
    SetDefault (IDM_PRI_NORMAL + Priority);

    PrfCloseProfile(hini);
}
Esempio n. 3
0
BOOL PRF_SetProfileString (PPRF_PROFILESTRING CustomPtr) {
   HINI INIHandle    = 0;
   BOOL ErrorOccured = FALSE;
   BOOL NeedToClose  = FALSE;

   // Uppercase filename...
   strupr (CustomPtr->Inis);

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

   if (INIHandle) {
      // Got valid INI-Handle, so write the string...
      ErrorOccured = !PrfWriteProfileString(INIHandle, CustomPtr->AppNames, CustomPtr->KeyNames, CustomPtr->Datas);
    } else ErrorOccured = TRUE;
   if (NeedToClose) PrfCloseProfile(INIHandle);
   return !ErrorOccured;
 }
void RecallWindowSizePos(void)
{
    int deskw,deskh;
    GetDefaultWH(deskw,deskh);
    char ws[32+1];
    char hs[32+1];
    sprintf(ws,"%d",deskw);
    sprintf(hs,"%d",deskh);
    ///
    char path[400+1];
    sprintf(path,"%s\\PROFOWL.INI",MyHomePath);
    HAB hab;
    HINI  hini = PrfOpenProfile(hab,path);
    char s[MAXPATHSIZE];
    s[0] = NULL;
    PrfQueryProfileString(hini,"profsowl","X","16",s,32);
    int x = atoi(s);
    PrfQueryProfileString(hini,"profsowl","Y","3",s,32);
    int y = atoi(s);
    PrfQueryProfileString(hini,"profsowl","Width",ws,s,32);
    int w = atoi(s);
    PrfQueryProfileString(hini,"profsowl","Height",hs,s,32);
    int h = atoi(s);
    PrfCloseProfile(hini);
    //
    // IF Something Valid To Recall !
    //
    if(x >= 0 && x < 1000 && y >= 0 && y < 1000)
    {
        MainFramePtr->MoveWindow(x,y,w,h,TRUE);
    }
}
Esempio n. 5
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;
}
void ForgetProjectPath(void)
{
    char path[400+1];
    sprintf(path,"%s\\PROFOWL.INI",MyHomePath);
    HAB hab;
    HINI  hini = PrfOpenProfile(hab,path);
    PrfWriteProfileString(hini,"profsowl","ProjectPath",".\\");
    PrfCloseProfile(hini);
}
Esempio n. 7
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. 8
0
void ZProfile::openRoot ()
{
  ZFUNCTRACE_DEVELOP ("ZProfile::openRoot()");
  if (iRootHandle == 0)
      {
        iRootHandle = PrfOpenProfile (iHab, iRoot);
        if (!iRootHandle)
          throwSysErr (PrfOpenProfileName);
      }                         // if
}                               // openRoot
void RememberProjectPath(void)
{
    char path[400+1];
    sprintf(path,"%s\\PROFOWL.INI",MyHomePath);
    HAB hab;
    HINI  hini = PrfOpenProfile(hab,path);
    char s[512];
    getcwd(s,sizeof(s));
    PrfWriteProfileString(hini,"profsowl","ProjectPath",s);
    PrfCloseProfile(hini);
}
Esempio n. 10
0
VOID GetScoresFromIni ( VOID )
{
    ULONG bMax;

    hini = PrfOpenProfile(habMain, "MAKMAN.INI");

    bMax = 15*100;
    PrfQueryProfileData(hini, szAppName, "ScoreNames", topNames, &bMax);
    bMax = 15 * sizeof(long);
    PrfQueryProfileData(hini, szAppName, "Scores", topScores, &bMax);

    PrfCloseProfile(hini);
}
Esempio n. 11
0
// try loading each plugin module.
// if opened sucessfully, call the plugin's CBZParseAttributes(hIni, keyValue, count) function
// the plugin is responsible for writing data to the ini file.
BOOL ApplyPreviewTheme(HWND hwndPreview, char themeFile[])
{
    HINI hIni;
    int count = 0;
    char szProfile[CCHMAXPATH + 1];
    char szPluginBase[CCHMAXPATH];

    // get profile name
    if (!PrfQueryProfileString(HINI_USERPROFILE,
                               "CandyBarZ",
                               "Profile",
                               NULL,
                               szProfile,
                               CCHMAXPATH))
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewTheme", "Failed to Get Profile Filename", 0UL);
        return FALSE;
    }

    // get profile name
    if (!PrfQueryProfileString(HINI_USERPROFILE,
                               "CandyBarZ",
                               "BasePath",
                               NULL,
                               szPluginBase,
                               CCHMAXPATH))
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewTheme", "Failed to Get BasePath", 0UL);
        return FALSE;
    }


    if ((hIni = PrfOpenProfile(WinQueryAnchorBlock(hwndPreview), szProfile)) == NULLHANDLE)
    {
        PSUTErrorFunc(NULLHANDLE, "Error", "ApplyPreviewTheme", "Failed to Open Profile", 0UL);
        return FALSE;
    }

    count = ApplyPreviewBlock(hwndPreview, themeFile, "TITLEBAR", szPluginBase, hIni, 0);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "FRAME", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "FRAMEBRDR", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "PUSHBUTTON", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "RADIOBUTTON", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "CHECKBOX", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "MINMAX", szPluginBase, hIni, count);
    count = ApplyPreviewBlock(hwndPreview, themeFile, "MENU", szPluginBase, hIni, count);
    //insert here!!!!
    PrfCloseProfile(hIni);
    return TRUE;
}
Esempio n. 12
0
BOOL  RestoreSettings( HWND hwndClient, HAB habAnchor )
{
   HINI  hiniPrf;
   CHAR *pLastSlash;


   /*
    * Construct a fully qualified profile file name (path and
    * file name) from the full path/name of the executable.
    */

   strncpy( szProfileFile, szExecFile, sizeof( szProfileFile ) );
   pLastSlash = strrchr( szProfileFile, '\\' );
   strcpy( pLastSlash + 1, szPrfBaseName );

   /*
    * Now open that profile file
    */

   hiniPrf = PrfOpenProfile( habAnchor, szProfileFile );

   /*
    * If the profile open was successful, restore the data therein
    */

   if ( hiniPrf != NULLHANDLE )
   {
      /*
       * Allow all modules to restore settings from the profile file
       */

      h2cursor_restore( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2edit_restore( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2file_restore( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2font_restore( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2help_restore( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2reg_restore( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2screen_restore( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2search_restore( hwndClient, hiniPrf, (PSZ)szPrfAppName );

      /*
       * Close the profile file and return TRUE
       */

      PrfCloseProfile( hiniPrf );
      return TRUE;
   }

   return FALSE;
}
Esempio n. 13
0
//
// Save MakMan/2 Options from INI files
//
VOID SaveOptionsToIni( VOID )
{
    int TileSet, Input, Sound, Priority;

    hini = PrfOpenProfile(habMain, "MAKMAN.INI");

    if (WinIsMenuItemChecked(hwndMenu, IDM_T_CLASSIC))
        TileSet = 0;
    else
       if (WinIsMenuItemChecked(hwndMenu, IDM_T_3D))
          TileSet = 1;
       else
            TileSet = 2;


    if (WinIsMenuItemChecked(hwndMenu, IDM_KEYBOARD))
        Input = 0;
    if (WinIsMenuItemChecked(hwndMenu, IDM_JOY_A))
        Input = 1;
    if (WinIsMenuItemChecked(hwndMenu, IDM_JOY_B))
        Input = 2;


    if (WinIsMenuItemChecked(hwndMenu, IDM_SOUND_ON))
        Sound = 1;
    else
        Sound = 0;

    if (WinIsMenuItemChecked(hwndMenu, IDM_PRI_NORMAL))
        Priority = 0;
    if (WinIsMenuItemChecked(hwndMenu, IDM_PRI_CRIT))
        Priority = 1;
    if (WinIsMenuItemChecked(hwndMenu, IDM_PRI_SERVER))
        Priority = 2;


    if (debOut)
    {
        fprintf(debOut, "TS : %i, Input %i, Sound %i, Prio %i\n", TileSet, Input, Sound, Priority);
        fflush(debOut);
    }

    WriteProfileInt ("Tile Set", TileSet);
    WriteProfileInt ("Input Source", Input);
    WriteProfileInt ("Sound Enabled", Sound);
    WriteProfileInt ("Priority", Priority);

    PrfCloseProfile(hini);
}
Esempio n. 14
0
/* On OS/2, closing a profile is potentially expensive operation
 * (buffer flushes and whatnot). Therefore we cache the ini handle
 * to minimize the profile open/close operations.
 */
IniFile::IniFile()
{
    char    buff[FILENAME_MAX];
    char    *p = getenv( "USER_INI" );

    strcpy( buff, p );
    for( p = buff + strlen(buff) - 1; p >= buff; p-- ) {
        if( *p == '\\' ) {
            *p = 0;
            break;
        }
    }
    strcat( buff, "\\" IDE_INI_FILENAME);
    _handle = PrfOpenProfile( NULL, (PSZ)buff );
}
Esempio n. 15
0
File: gvpmisc.c Progetto: 131/gsview
void
play_system_sound(char *id)
{
HINI hini;
char buf[MAXSTR];
char *p;
	if ( (hini = PrfOpenProfile(hab, szMMini)) == NULLHANDLE )
	    return;
	PrfQueryProfileString(hini, (PCSZ)"MMPM2_AlarmSounds", (PCSZ)id, (PCSZ)"##", buf, sizeof(buf));
	PrfCloseProfile(hini);
    	p = strchr(buf,'#');
    	if (p != (char *)NULL) {
	    *p = '\0';
	    (*pfnMciPlayFile)(hwnd_frame, (PSZ)buf, 0, 0, 0);
	}
	return;
}
Esempio n. 16
0
/*************************************************************************\
 * function ReadProfile()
 * Tries to open the file "bermuda.ini" and sets game specific options taken
 * from the profile data. If the file isn't found or the data is invalid
 * FALSE is returned otherwise the function returns TRUE.
\*************************************************************************/
BOOL ReadProfile( HAB hab )
{
	CHAR pszVersionFound[MaxVersionLen] = "";
	ULONG lNumRead;
	ULONG tmpLineStyle;
	BOOL  tmpSound;
	HINI hini;
	PSZ pszIniNameCopy;


	pszIniNameCopy = (PSZ)alloca( strlen( pszIniName ) + 1);
	strcpy( pszIniNameCopy, pszIniName );
	if ( !(hini = PrfOpenProfile( hab, pszIniNameCopy )) ) goto Error;

	// query version string
	PrfQueryProfileString( hini, pszAppName, PrfKeys.pszVersion, NULL,
								  pszVersionFound, MaxVersionLen );
	// and compare with current version								  
	if ( strcmp( pszVersion, pszVersionFound ) != 0 ){
		PrfCloseProfile( hini );
		return FALSE;
	}

	// retrieve line style settings
	lNumRead = sizeof( ULONG );
	if( !PrfQueryProfileData( hini, pszAppName, PrfKeys.pszLineStyle,
		 &tmpLineStyle, &lNumRead ) ) goto Error;
	InfoData.SetLineStyle( tmpLineStyle );		 
	// retrieve sound flag
	lNumRead = sizeof( BOOL );
	if( !PrfQueryProfileData( hini, pszAppName, PrfKeys.pszSound,
		 &tmpSound, &lNumRead ) )
		 goto Error;
	Sound::SetSoundWanted( tmpSound );		 

	if ( !RestoreWindowPos( hini, pszAppName, PrfKeys.pszWinPos, hwndFrame )
		) goto Error;
	PrfCloseProfile( hini );
	return TRUE;

Error:
	PrfCloseProfile( hini );
	return FALSE;
}
void RecallProjectPath(char *rs, int ChDir)
{
    char path[400+1];
    sprintf(path,"%s\\PROFOWL.INI",MyHomePath);
    HAB hab;
    HINI  hini = PrfOpenProfile(hab,path);
    char s[MAXPATHSIZE];
    PrfQueryProfileString(hini,"profsowl","ProjectPath",".\\",s,sizeof(s));
    PrfCloseProfile(hini);

    if(ChDir && s[1] == ':')
    {
        ChPath(s);
    }

    if(rs)
    {
        strcpy(rs,s);
    }
}
void SaveWindowSizePos(void)
{
    int x = MainFramePtr->Attr.X;
    int y = MainFramePtr->Attr.Y;

    SWP swp;
    WinQueryWindowPos(MainFramePtr->HWindow, &swp);
    int w = swp.cx;
    int h = swp.cy;

    static int oldx, oldy, oldw, oldh;
    ///
    if(x == oldx && y == oldy && w == oldw && h == oldh)
    {
        return;
    }
    ////
    oldx = x;
    oldy = y;
    oldw = w;
    oldh = h;
    ////
    char path[400+1];
    sprintf(path,"%s\\PROFOWL.INI",MyHomePath);
    HAB hab;
    HINI  hini = PrfOpenProfile(hab,path);
    if(!hini)
        return;

    char s[32+1];
    s[0] = NULL;
    sprintf(s,"%d",x);
    PrfWriteProfileString(hini,"profsowl","X",s);
    sprintf(s,"%d",y);
    PrfWriteProfileString(hini,"profsowl","Y",s);
    sprintf(s,"%d",w);
    PrfWriteProfileString(hini,"profsowl","Width",s);
    sprintf(s,"%d",h);
    PrfWriteProfileString(hini,"profsowl","Height",s);
    PrfCloseProfile(hini);
}
Esempio n. 19
0
BOOL  SaveSettings( HWND hwndClient, HAB habAnchor )
{
   HINI  hiniPrf;


   /*
    * Open the profile file
    */

   hiniPrf = PrfOpenProfile( habAnchor, szProfileFile );

   /*
    * If the profile open was successful, save what needs to be saved therein.
    */

   if ( hiniPrf != NULLHANDLE )
   {
      /*
       * Allow all modules to save settings to the profile file
       */

      h2cursor_save( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2edit_save( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2file_save( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2font_save( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2help_save( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2reg_save( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2screen_save( hwndClient, hiniPrf, (PSZ)szPrfAppName );
      h2search_save( hwndClient, hiniPrf, (PSZ)szPrfAppName );

      /*
       * Close the profile file and return TRUE
       */

      PrfCloseProfile( hiniPrf );
      return TRUE;
   }

   return FALSE;
}
void LoadToolSettings(void)
{
    char path[400+1];
    sprintf(path,"%s\\PROFOWL.INI",MyHomePath);
    //
    int ns = sizeof(UserTools[1].Name);
    int ps = sizeof(UserTools[1].Path);
    int ds = sizeof(UserTools[1].Dir);
    //
    HAB hab;
    HINI hini = PrfOpenProfile(hab,path);
    PrfQueryProfileString(hini,"profsowl","Tool1Name","",UserTools[1].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool2Name","",UserTools[2].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool3Name","",UserTools[3].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool4Name","",UserTools[4].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool5Name","",UserTools[5].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool6Name","",UserTools[6].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool7Name","",UserTools[7].Name,ns);
    PrfQueryProfileString(hini,"profsowl","Tool8Name","",UserTools[8].Name,ns);
    //--
    PrfQueryProfileString(hini,"profsowl","Tool1Path","",UserTools[1].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool2Path","",UserTools[2].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool3Path","",UserTools[3].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool4Path","",UserTools[4].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool5Path","",UserTools[5].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool6Path","",UserTools[6].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool7Path","",UserTools[7].Path,ps);
    PrfQueryProfileString(hini,"profsowl","Tool8Path","",UserTools[8].Path,ps);
    //--
    PrfQueryProfileString(hini,"profsowl","Tool1Dir","",UserTools[1].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool2Dir","",UserTools[2].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool3Dir","",UserTools[3].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool4Dir","",UserTools[4].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool5Dir","",UserTools[5].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool6Dir","",UserTools[6].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool7Dir","",UserTools[7].Dir,ds);
    PrfQueryProfileString(hini,"profsowl","Tool8Dir","",UserTools[8].Dir,ds);
    PrfCloseProfile(hini);
}
void SetTool::SaveToolSettings(void)
{
    char path[400+1];
    sprintf(path,"%s\\PROFOWL.INI",MyHomePath);

    HAB hab;
    HINI  hini = PrfOpenProfile(hab,path);
    //
    PrfWriteProfileString(hini,"profsowl","Tool1Name",UserTools[1].Name);
    PrfWriteProfileString(hini,"profsowl","Tool2Name",UserTools[2].Name);
    PrfWriteProfileString(hini,"profsowl","Tool3Name",UserTools[3].Name);
    PrfWriteProfileString(hini,"profsowl","Tool4Name",UserTools[4].Name);
    PrfWriteProfileString(hini,"profsowl","Tool5Name",UserTools[5].Name);
    PrfWriteProfileString(hini,"profsowl","Tool6Name",UserTools[6].Name);
    PrfWriteProfileString(hini,"profsowl","Tool7Name",UserTools[7].Name);
    PrfWriteProfileString(hini,"profsowl","Tool8Name",UserTools[8].Name);
    //--
    PrfWriteProfileString(hini,"profsowl","Tool1Path",UserTools[1].Path);
    PrfWriteProfileString(hini,"profsowl","Tool2Path",UserTools[2].Path);
    PrfWriteProfileString(hini,"profsowl","Tool3Path",UserTools[3].Path);
    PrfWriteProfileString(hini,"profsowl","Tool4Path",UserTools[4].Path);
    PrfWriteProfileString(hini,"profsowl","Tool5Path",UserTools[5].Path);
    PrfWriteProfileString(hini,"profsowl","Tool6Path",UserTools[6].Path);
    PrfWriteProfileString(hini,"profsowl","Tool7Path",UserTools[7].Path);
    PrfWriteProfileString(hini,"profsowl","Tool8Path",UserTools[8].Path);
    //--
    PrfWriteProfileString(hini,"profsowl","Tool1Dir",UserTools[1].Dir);
    PrfWriteProfileString(hini,"profsowl","Tool2Dir",UserTools[2].Dir);
    PrfWriteProfileString(hini,"profsowl","Tool3Dir",UserTools[3].Dir);
    PrfWriteProfileString(hini,"profsowl","Tool4Dir",UserTools[4].Dir);
    PrfWriteProfileString(hini,"profsowl","Tool5Dir",UserTools[5].Dir);
    PrfWriteProfileString(hini,"profsowl","Tool6Dir",UserTools[6].Dir);
    PrfWriteProfileString(hini,"profsowl","Tool7Dir",UserTools[7].Dir);
    PrfWriteProfileString(hini,"profsowl","Tool8Dir",UserTools[8].Dir);
    PrfCloseProfile(hini);
}
Esempio n. 22
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;
 }
MRESULT EXPENTRY CDSettingsDlgProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
  FILEDLG fd = { 0 };
  char profileName[20];
  static HINI hini;
  ULONG keyLength;
  static  char chrPath[CCHMAXPATH];
  static  char chrOptions[CCHMAXPATH];

  switch( msg )
    {
    case WM_INITDLG:
      {
	WinSendMsg(WinWindowFromID(hwnd,EFID_CDRECORDPATH),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)CCHMAXPATH),0);
	WinSendMsg(WinWindowFromID(hwnd,EFID_CDRECORDOPTIONS),EM_SETTEXTLIMIT,MPFROMSHORT((SHORT)CCHMAXPATH),0);
	WinSetWindowText( WinWindowFromID(hwnd,EFID_CDRECORDPATH),chrCDRecord);
	WinSetWindowText( WinWindowFromID(hwnd,EFID_CDRECORDOPTIONS),chrCDROptions);
	sprintf(chrPath,"%s",chrCDRecord);
	sprintf(chrOptions,"%s",chrCDROptions);
	sprintf(profileName,"cdrecord.ini");		
	hini=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),profileName);
	if(!hini) {
	  WinMessageBox(  HWND_DESKTOP,
			HWND_DESKTOP,
			"Warning! Cannot open Ini-file!",
			"",
			0UL,
			MB_OK | MB_ICONEXCLAMATION );
	  WinDismissDlg(hwnd,DID_ERROR);
	}/* end of if(!hini) */				
      }
      return (MRESULT) TRUE;
    case WM_DESTROY:
      if(hini)PrfCloseProfile(hini);
      hini=NULLHANDLE;
      break;
    case WM_CLOSE:
      WinDismissDlg(hwnd,DID_ERROR);
      break;
    case WM_COMMAND:
      {			
	switch( SHORT1FROMMP( mp1 ) )
	  {
	  case PBID_CDRECORDBROWSE:
	    fd.cbSize = sizeof( fd );
	    fd.fl = FDS_OPEN_DIALOG|FDS_CENTER;
	    fd.pszTitle = "Search CDRecord/2";
	    sprintf(fd.szFullFile,"%s","*.exe");
	    
	    if( WinFileDlg( HWND_DESKTOP, hwnd, &fd ) == NULLHANDLE )
	      {
		break;
	      }
	    if( fd.lReturn == DID_OK )
	      {
		WinSetWindowText( WinWindowFromID(hwnd,EFID_CDRECORDPATH), fd.szFullFile );
		sprintf(chrCDRecord,"%s",fd.szFullFile);
	      }
	    break;
	  case DID_OK:
	    WinQueryWindowText(WinWindowFromID(hwnd,EFID_CDRECORDOPTIONS),sizeof(chrCDROptions),chrCDROptions);
	    if(!PrfWriteProfileString(hini,"CDWriter","cdrecord",chrCDRecord)){
	      WinMessageBox(  HWND_DESKTOP,
			    HWND_DESKTOP,
			    "Warning! Cannot write to Ini-file!",
			    "",
			    0UL,
			    MB_OK | MB_ICONEXCLAMATION );
	      WinDismissDlg(hwnd,DID_ERROR);
	    }
	    
	    if(!PrfWriteProfileString(hini,"CDWriter","cdroptions",chrCDROptions)){
	      WinMessageBox(  HWND_DESKTOP,
			    HWND_DESKTOP,
			    "Warning! Cannot write to Ini-file!",
			    "",
			    0UL,
			    MB_OK | MB_ICONEXCLAMATION );
	      WinDismissDlg(hwnd,DID_ERROR);
	    };
	    WinDismissDlg(hwnd,0);
	    break;
	  case DID_CANCEL:
	    sprintf(chrCDRecord,"%s",chrPath);
	    sprintf(chrCDROptions,"%s",chrOptions);
	    WinDismissDlg(hwnd,1);
	    break;
	    
	  default:
	    break;
	  }
      }
      return (MRESULT) TRUE;      
    }	
  return( WinDefDlgProc( hwnd, msg, mp1, mp2 ) );	
}
Esempio n. 24
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. 25
0
static  BOOL    loadProfile(HAB hab)
{
    HINI    hini ;
    BOOL    stat ;
    ULONG   len  ;
    int     i, id ;
    UCHAR   key[32] ;

#ifdef DEBUG
    TRACE("loadProfile [%s]\n", ProfilePath) ;
#endif

    /*
     * load host order
     */

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

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

        return FALSE ;
    }

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

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

#ifdef DEBUG
        TRACE("loadProfile - failed to read Order\n") ;
#endif

        return FALSE ;
    }

    /*
     * load host informations
     */

    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)) {
            PrfCloseProfile(hini) ;
            memset(profOrder, 0xff, sizeof(profOrder)) ;

#ifdef DEBUG
            TRACE("loadProfile - failed to read Host Data %d\n", id) ;
#endif

            return FALSE ;
        }
    }
    PrfCloseProfile(hini) ;

    /*
     * modified with command line arguments
     */

    for (i = 0 ; i < MAXHOSTS ; i++) {
        if ((id = profOrder[i]) == 0xff) {
            continue ;
        }
        if (argFormat32) {
            profHosts[id].format = PIXFMT_32 ;
        }
        if (argFormat8) {
            profHosts[id].format = PIXFMT_8 ;
        }
        if (argFormatTiny) {
            profHosts[id].format = PIXFMT_TINY ;
        }
        if (argFormatGray) {
            profHosts[id].format = PIXFMT_GRAY ;
        }
        if (argEncodeRaw) {
            profHosts[id].encode = rfbEncodingRaw ;
        }
        if (argEncodeRre) {
            profHosts[id].encode = rfbEncodingRRE ;
        }
        if (argEncodeCor) {
            profHosts[id].encode = rfbEncodingCoRRE ;
        }
        if (argEncodeHex) {
            profHosts[id].encode = rfbEncodingHextile ;
        }
        if (argOptShared) {
            profHosts[id].shared = TRUE ;
        }
        if (argOptViewonly) {
            profHosts[id].viewonly = TRUE ;
        }
        if (argOptDeiconify) {
            profHosts[id].deiconify = TRUE ;
        }
    }

    /*
     * also modify current session parameters
     */

    if (argServer) {
        strcpy(SessServerName, argServer) ;
    }
    if (argFormat32) {
        SessPixelFormat = PIXFMT_32 ;
    }
    if (argFormat8) {
        SessPixelFormat = PIXFMT_8 ;
    }
    if (argFormatTiny) {
        SessPixelFormat = PIXFMT_TINY ;
    }
    if (argFormatGray) {
        SessPixelFormat = PIXFMT_GRAY ;
    }
    if (argEncodeRaw) {
        SessPreferredEncoding = rfbEncodingRaw ;
    }
    if (argEncodeRre) {
        SessPreferredEncoding = rfbEncodingRRE ;
    }
    if (argEncodeCor) {
        SessPreferredEncoding = rfbEncodingCoRRE ;
    }
    if (argEncodeHex) {
        SessPreferredEncoding = rfbEncodingHextile ;
    }
    if (argOptShared) {
        SessOptShared = TRUE ;
    }
    if (argOptViewonly) {
        SessOptViewonly = TRUE ;
    }
    if (argOptDeiconify) {
        SessOptDeiconify = TRUE ;
    }

#ifdef DEBUG
    TRACE("loadProfile ... done\n") ;
#endif

    return TRUE ;
}
Esempio n. 26
0
/*--------------------------------------------------------------------------------------*\
 * Procedure opens the profile and reads the UPS structure from.                        *
 * 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    Read_Profile(HINI *pHini, HAB *pHab, UPS *pUps)
{
ULONG   ulSize;
UCHAR   *uc='\0';
                                        /* First open the profile */
*pHini=PrfOpenProfile(*pHab, pucSD2Profile);
while(TRUE)
    {
    ulSize=sizeof(UCHAR);
    if(PrfQueryProfileData(             /* Query binary data from profile */
        *pHini,                         /* Handle of profile */
        SD2_CLASSNAME,                  /* Application name */
        "IDUBC_Hours",                  /* Key name */
        &pUps->IDUBC_Hours,             /* Value data */
        &ulSize)==FALSE)                /* Size of value data */
        { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUBC_Minutes",
        &pUps->IDUBC_Minutes,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUAS_Hours",
        &pUps->IDUAS_Hours,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUAS_Minutes",
        &pUps->IDUAS_Minutes,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUASD_Hours",
        &pUps->IDUASD_Hours,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUASD_Minutes",
        &pUps->IDUASD_Minutes,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUS_Hours",
        &pUps->IDUS_Hours,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "IDUS_Minutes",
        &pUps->IDUS_Minutes,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    ulSize=sizeof(ULONG);
    if(PrfQueryProfileData(
        *pHini,
        SD2_CLASSNAME,
        "GRP_Mode",
        &pUps->GRP_Mode,
        &ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    ulSize=sizeof(Ups.IDS_PgmName);
    if(PrfQueryProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_PgmName",
        uc,
        pUps->IDS_PgmName,
        ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_PgmDirectory",
        uc,
        pUps->IDS_PgmDirectory,
        ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    if(PrfQueryProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_PgmInputs",
        uc,
        pUps->IDS_PgmInputs,
        ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    ulSize=sizeof(Ups.IDS_UserInfo);
    if(PrfQueryProfileString(
        *pHini,
        SD2_CLASSNAME,
        "IDS_UserInfo",
        uc,
        pUps->IDS_UserInfo,
        ulSize)==FALSE) { *pHini=NULLHANDLE; break; }
    return(PrfCloseProfile(*pHini));    /* Close and return result */
    }
if(*pHini==NULLHANDLE)
    {
                                        /* SHUTDOWN.INI missing logging into logfile */
    DosGetDateTime(&UPS_Current);
    UPS_LogfileIO(LF_INIFILE_MISSING, MPFROMP(&UPS_Current));
    pUps->IDUBC_Hours=0;                /* Assume default values */
    pUps->IDUBC_Minutes=10;
    pUps->IDUAS_Hours=0;
    pUps->IDUAS_Minutes=1;
    pUps->IDUASD_Hours=0;
    pUps->IDUASD_Minutes=4;
    pUps->IDUS_Hours=0;
    pUps->IDUS_Minutes=7;
    pUps->GRP_Mode=IDM_LPT1;
    strcpy(pUps->IDS_PgmName, "CMD.EXE");
    strcpy(pUps->IDS_PgmDirectory, "");
    strcpy(pUps->IDS_PgmInputs, "");
    strcpy(pUps->IDS_UserInfo, "An error occured accessing SHUTDOWN.INI, please correct "\
        "as soon as possible!");
    return(FALSE);
    }
}
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);
    }
}
Esempio n. 28
0
BOOL launchPad::lpBuildObjectList(char * chrFolderID)
{
  WPObject* wpObject;

  char chrText[200];  
  ULONG ul;

  SOMClass *folderClass;
  WPFolder *wpFolder;
  char chrPath[CCHMAXPATH];
  ULONG ulBufferSize;
  HINI hIni;
  char * memPtr;
  HOBJECT *hObjectArray;
  int a;
  LPObject *lpoTemp;
  WPObject * wpTempObject;


  /* Get toolbar folder */
  if(somIsObj(wpParentFolder)) {
    folderClass=wpParentFolder->somGetClass();
    if(somIsObj(folderClass))
      wpFolder=(WPFolder*)((M_WPFolder*)folderClass)->wpclsQueryFolder(chrFolderID, FALSE);
    if(!somIsObj(wpFolder))
      return FALSE;
  }
  
  /* Build ini name */
  ulBufferSize=sizeof(chrPath);
  wpFolder->wpQueryRealName(chrPath, &ulBufferSize, TRUE);
  strcat(chrPath,"\\objects.ini");/* Ini-File containing the hobjects */
  
  do{
    /* Open the ini-file */
    if((hIni=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),chrPath))==NULLHANDLE)
      break; 
 
    if(!PrfQueryProfileSize(hIni,"objects","handles", &ulBufferSize))
      break;

    if(ulBufferSize==0)
      break;/* No entries yet */

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

    if(!PrfQueryProfileData(hIni,"objects","handles", memPtr, &ulBufferSize)){
      free(memPtr);
      break;
    }

    hObjectArray=(HOBJECT*)memPtr;
    ulBufferSize=ulNumObjects;
    for(a=0;a<ulBufferSize && lpoTemp; a++)
      {
        wpTempObject=((M_WPObject*)folderClass)->wpclsQueryObject(hObjectArray[a]);
        if(somIsObj(wpTempObject)) {
          if((lpoTemp=new LPObject(wpTempObject->wpQueryIcon()))!=NULL) {
            lpoTemp->wpObject=wpTempObject;
            wpTempObject->wpLockObject();
            lpoTemp->hObject=hObjectArray[a];
            //            lpoTemp->hPtr=wpTempObject->wpQueryIcon();
            /* Title of the object */
            strncpy(lpoTemp->chrName, wpTempObject->wpQueryTitle(),sizeof(lpoTemp->chrName));
            lpoTemp->lpParent=this;
            
            lpoTemp->lpoNext=lpoObjectList;
            lpoObjectList=lpoTemp;
          }
        }
        else {
          ulNumObjects--;
        }
      }/* for */
    
    free(hObjectArray);
    
    PrfCloseProfile(hIni);
    return TRUE;
  }while(TRUE);

  if(hIni)
    PrfCloseProfile(hIni);
  return FALSE;

}
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;
}
main()
{
  HAB hab;
  HMQ hmq;
  ULONG keyLength;
  char profileName[20];
  
  hab = WinInitialize( 0 );
  if(hab) {
    hmq = WinCreateMsgQueue( hab, 100UL );
    if(hmq) {
      sprintf(profileName,"cdrecord.ini");		
      hini=PrfOpenProfile(WinQueryAnchorBlock(HWND_DESKTOP),profileName);
      if(!hini) {
        WinMessageBox(  HWND_DESKTOP,
                        HWND_DESKTOP,
                        "Warning! Cannot open Ini-file!",
                        "",
                        0UL,
                        MB_OK | MB_ICONEXCLAMATION );
        WinDestroyMsgQueue( hmq );
        WinTerminate( hab );
        return( 1 );
      }/* end of if(!hini) */
      
      keyLength=PrfQueryProfileString(hini,"CDWriter","cdrecord","",chrCDRecord,sizeof(chrCDRecord));
      if(keyLength==1){
        if( WinDlgBox( HWND_DESKTOP, NULLHANDLE, CDSettingsDlgProc, NULLHANDLE,DLGID_SETUP, 0 ) == DID_ERROR )
          {
            WinMessageBox(  HWND_DESKTOP,
                            HWND_DESKTOP,
                            "Warning! Cannot open Settings dialog!",
                            "",
                            0UL,
                            MB_OK | MB_ICONEXCLAMATION );
            WinDestroyMsgQueue( hmq );
            WinTerminate( hab );
            if(hini)PrfCloseProfile(hini);
            return( 1 );
          }
        if(!PrfWriteProfileString(hini,"CDWriter","cdrecord",chrCDRecord)){
          WinMessageBox(  HWND_DESKTOP,
                          HWND_DESKTOP,
                          "Warning! Cannot write to Ini-file!",
                          "",
                          0UL,
                          MB_OK | MB_ICONEXCLAMATION );
          WinDestroyMsgQueue( hmq );
          WinTerminate( hab );
          if(hini)PrfCloseProfile(hini);
          return( 1 );
        }
        
        if(!PrfWriteProfileString(hini,"CDWriter","cdroptions",chrCDROptions)){
          WinMessageBox(  HWND_DESKTOP,
                          HWND_DESKTOP,
                          "Warning! Cannot write to Ini-file!",
                          "",
                          0UL,
                          MB_OK | MB_ICONEXCLAMATION );
          WinDestroyMsgQueue( hmq );
          WinTerminate( hab );
          if(hini)PrfCloseProfile(hini);
          return( 1 );
        };
      }
      PrfQueryProfileString(hini,"CDWriter","cdroptions","",chrCDROptions,sizeof(chrCDROptions));
      
      if( WinDlgBox( HWND_DESKTOP, NULLHANDLE, CDToolsDlgProc, NULLHANDLE,DLGID_CDTOOLS, 0 ) == DID_ERROR )
        {
          WinDestroyMsgQueue( hmq );
          WinTerminate( hab );
          if(hini)PrfCloseProfile(hini);
          DosBeep(100,600);
          return( 1 );
        }
      if(hini)PrfCloseProfile(hini);
      WinDestroyMsgQueue( hmq );
    }
    WinTerminate( hab );
  }
  return( 0 );	
}