Пример #1
0
VOID WriteProfileInt ( char* key, int value )
{
    char buf[80];

    sprintf(buf, "%i", value);
    PrfWriteProfileString( hini, szAppName, key, buf );
}
Пример #2
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;
}
Пример #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 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);
}
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);
}
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);
}
Пример #7
0
ZExport (ZProfile &) ZProfile::deleteValue (const ZString & aValueName)
{
  ZFUNCTRACE_DEVELOP ("ZProfile::deleteValue(const ZString& aValueName)");
#ifdef ZC_WIN
  openPath (zFalse);
  RegDeleteValue ((HKEY) iPathHandle, aValueName);
#endif
#ifdef ZC_OS2
  if (!iPath.size ())
    ZTHROWEXC (MissingPath);
  if (!aValueName.size ())
    ZTHROWEXC (MissingValueName);
  openRoot ();
  if (!PrfWriteProfileString (iRootHandle, iPath, aValueName, 0))
    throwSysErr (PrfWriteProfileStringName);
#endif
  return *this;
}                               // deleteValue
Пример #8
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
Пример #9
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);
    }
}
Пример #10
0
int IniFile::write( const char *section, const char *key, const char *string)
{
    return( PrfWriteProfileString( _handle, (PSZ)section, (PSZ)key, (PSZ)string ) );
}
//----------------------------------------------------------------------------------------
void nsSpecialSystemDirectory::operator = (SystemDirectories aSystemSystemDirectory)
//----------------------------------------------------------------------------------------
{
    SystemDirectoriesKey dirKey(aSystemSystemDirectory);
    SystemDirectoriesKey mozBinDirKey(Moz_BinDirectory);

    // This flag is used to tell whether or not we need to append something
    // onto the *this.  Search for needToAppend to how it's used.
    // IT's VERY IMPORTANT that needToAppend is initialized to PR_TRUE.
    PRBool needToAppend = PR_TRUE;

    *this = (const char*)nsnull;
    switch (aSystemSystemDirectory)
    {
        
        case OS_DriveDirectory:
#if defined (XP_WIN)
        {
            char path[_MAX_PATH];
            PRInt32 len = GetWindowsDirectory( path, _MAX_PATH );
            if (len)
            {
                if ( path[1] == ':' && path[2] == '\\' )
                    path[3] = 0;
            }
            *this = MakeUpperCase(path);
        }
#elif defined(XP_OS2)
        {
            // printf( "*** Warning warning OS_DriveDirectory called for");
            
            ULONG ulBootDrive = 0;
            char  buffer[] = " :\\OS2\\";
            DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
                             &ulBootDrive, sizeof ulBootDrive);
            buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index...
            *this = buffer;
#ifdef DEBUG
            printf( "Got OS_DriveDirectory: %s\n", buffer);
#endif
        }
#else
        *this = "/";
#endif
        break;

            
        case OS_TemporaryDirectory:
#if defined (WINCE)
            {
                *this = "\\TEMP";
            }
#elif defined (XP_WIN)
        {
            char path[_MAX_PATH];
            DWORD len = GetTempPath(_MAX_PATH, path);
            *this = MakeUpperCase(path);
        }
#elif defined(XP_OS2)
          {
             char buffer[CCHMAXPATH] = "";
             char *c = getenv( "TMP");
             if( c) strcpy( buffer, c);
             else
             {
                c = getenv( "TEMP");
                if( c) strcpy( buffer, c);
             }
             if( c) *this = buffer;
             // use exe's directory if not set
             else GetCurrentProcessDirectory(*this);
          }        
#elif defined(XP_UNIX) || defined(XP_BEOS)
		{
			static const char *tPath = nsnull;
			if (!tPath) {
				tPath = PR_GetEnv("TMPDIR");
				if (!tPath || !*tPath) {
					tPath = PR_GetEnv("TMP");
					if (!tPath || !*tPath) {
						tPath = PR_GetEnv("TEMP");
						if (!tPath || !*tPath) {
							tPath = "/tmp/";
						}
					}
				}
			}
			
			*this = tPath;
		}
#endif
        break;

        case OS_CurrentProcessDirectory:
            GetCurrentProcessDirectory(*this);
            break;

        case OS_CurrentWorkingDirectory:
            GetCurrentWorkingDirectory(*this);
            break;

        case XPCOM_CurrentProcessComponentRegistry:
            {
                nsFileSpec *dirSpec = NULL;

                // if someone has called nsSpecialSystemDirectory::Set()
                if (systemDirectoriesLocations) {
                    // look for the value for the argument key
                    if (!(dirSpec = (nsFileSpec *)systemDirectoriesLocations->Get(&dirKey))) {
                        // if not found, try Moz_BinDirectory
                        dirSpec = (nsFileSpec *)
                            systemDirectoriesLocations->Get(&mozBinDirKey);
                    }
                    else {
                        // if the value is found for the argument key,
                        // we don't need to append.
                        needToAppend = PR_FALSE;
                    }
                }
                
                if (dirSpec)
                {
                    *this = *dirSpec;
                }
                else
                {
                    GetCurrentProcessDirectory(*this);
                }

                if (needToAppend) {
                    // XXX We need to unify these names across all platforms
                    *this += "component.reg";
                }
            }
            break;

        case XPCOM_CurrentProcessComponentDirectory:
            {
                nsFileSpec *dirSpec = NULL;
                // if someone has called nsSpecialSystemDirectory::Set()
                if (systemDirectoriesLocations) {
                    // look for the value for the argument key
                    if (!(dirSpec = (nsFileSpec *)systemDirectoriesLocations->Get(&dirKey))) {
                        // if not found, try Moz_BinDirectory
                        dirSpec = (nsFileSpec *)
                            systemDirectoriesLocations->Get(&mozBinDirKey);
                    }
                    else {
                        // if the value is found for the argument key,
                        // we don't need to append.
                        needToAppend = PR_FALSE;
                    }
                }
                if (dirSpec)
                {
                    *this = *dirSpec;
                }
                else
                {
                    // <exedir>/Components
                    GetCurrentProcessDirectory(*this);
                }

                if (needToAppend) {
                    // XXX We need to unify these names across all platforms
                    *this += "components";
                }
            }
            break;

        case Moz_BinDirectory:
            {
                nsFileSpec *dirSpec = NULL;
                // if someone has called nsSpecialSystemDirectory::Set()
                if (systemDirectoriesLocations) {
                    // look for the value for the argument key
                    dirSpec = (nsFileSpec *)
                        systemDirectoriesLocations->Get(&dirKey);
                }
                if (dirSpec) {
                    *this = *dirSpec;
                }
                else {
                    GetCurrentProcessDirectory(*this);
                }
            }
            break;
            
#if defined (XP_WIN)
        case Win_SystemDirectory:
        {    
            char path[_MAX_PATH];
            PRInt32 len = GetSystemDirectory( path, _MAX_PATH );
        
            // Need enough space to add the trailing backslash
            if (len > _MAX_PATH-2)
                break;
            path[len]   = '\\';
            path[len+1] = '\0';

            *this = MakeUpperCase(path);

            break;
        }

        case Win_WindowsDirectory:
        {    
            char path[_MAX_PATH];
            PRInt32 len = GetWindowsDirectory( path, _MAX_PATH );
            
            // Need enough space to add the trailing backslash
            if (len > _MAX_PATH-2)
                break;
            
            path[len]   = '\\';
            path[len+1] = '\0';

            *this = MakeUpperCase(path);
            break;
        }

        case Win_HomeDirectory:
        {    
            char path[_MAX_PATH];
            if (GetEnvironmentVariable(TEXT("HOME"), path, _MAX_PATH) > 0)
            {
                PRInt32 len = PL_strlen(path);
                // Need enough space to add the trailing backslash
                if (len > _MAX_PATH - 2)
                    break;
               
                path[len]   = '\\';
                path[len+1] = '\0';
                
                *this = MakeUpperCase(path);
                break;
            }

            if (GetEnvironmentVariable(TEXT("HOMEDRIVE"), path, _MAX_PATH) > 0)
            {
                char temp[_MAX_PATH];
                if (GetEnvironmentVariable(TEXT("HOMEPATH"), temp, _MAX_PATH) > 0)
                   PL_strcatn(path, _MAX_PATH, temp);
        
                PRInt32 len = PL_strlen(path);

                // Need enough space to add the trailing backslash
                if (len > _MAX_PATH - 2)
                    break;
            
                path[len]   = '\\';
                path[len+1] = '\0';
                
                *this = MakeUpperCase(path);
                break;
            }
        }
        case Win_Desktop:
        {
            GetWindowsFolder(CSIDL_DESKTOP, *this);
            break;
        }
        case Win_Programs:
        {
            GetWindowsFolder(CSIDL_PROGRAMS, *this);
            break;
        }
        case Win_Controls:
        {
            GetWindowsFolder(CSIDL_CONTROLS, *this);
            break;
        }
        case Win_Printers:
        {
            GetWindowsFolder(CSIDL_PRINTERS, *this);
            break;
        }
        case Win_Personal:
        {
            GetWindowsFolder(CSIDL_PERSONAL, *this);
            break;
        }
        case Win_Favorites:
        {
            GetWindowsFolder(CSIDL_FAVORITES, *this);
            break;
        }
        case Win_Startup:
        {
            GetWindowsFolder(CSIDL_STARTUP, *this);
            break;
        }
        case Win_Recent:
        {
            GetWindowsFolder(CSIDL_RECENT, *this);
            break;
        }
        case Win_Sendto:
        {
            GetWindowsFolder(CSIDL_SENDTO, *this);
            break;
        }
        case Win_Bitbucket:
        {
            GetWindowsFolder(CSIDL_BITBUCKET, *this);
            break;
        }
        case Win_Startmenu:
        {
            GetWindowsFolder(CSIDL_STARTMENU, *this);
            break;
        }
        case Win_Desktopdirectory:
        {
            GetWindowsFolder(CSIDL_DESKTOPDIRECTORY, *this);
            break;
        }
        case Win_Drives:
        {
            GetWindowsFolder(CSIDL_DRIVES, *this);
            break;
        }
        case Win_Network:
        {
            GetWindowsFolder(CSIDL_NETWORK, *this);
            break;
        }
        case Win_Nethood:
        {
            GetWindowsFolder(CSIDL_NETHOOD, *this);
            break;
        }
        case Win_Fonts:
        {
            GetWindowsFolder(CSIDL_FONTS, *this);
            break;
        }
        case Win_Templates:
        {
            GetWindowsFolder(CSIDL_TEMPLATES, *this);
            break;
        }
#ifndef WINCE
        case Win_Common_Startmenu:
        {
            GetWindowsFolder(CSIDL_COMMON_STARTMENU, *this);
            break;
        }
        case Win_Common_Programs:
        {
            GetWindowsFolder(CSIDL_COMMON_PROGRAMS, *this);
            break;
        }
        case Win_Common_Startup:
        {
            GetWindowsFolder(CSIDL_COMMON_STARTUP, *this);
            break;
        }
        case Win_Common_Desktopdirectory:
        {
            GetWindowsFolder(CSIDL_COMMON_DESKTOPDIRECTORY, *this);
            break;
        }
        case Win_Printhood:
        {
            GetWindowsFolder(CSIDL_PRINTHOOD, *this);
            break;
        }
        case Win_Cookies:
        {
            GetWindowsFolder(CSIDL_COOKIES, *this);
            break;
        }
#endif // WINCE

        case Win_Appdata:
        {
            GetWindowsFolder(CSIDL_APPDATA, *this);
            break;
        }
#endif  // XP_WIN

#if defined(XP_UNIX)
        case Unix_LocalDirectory:
            *this = "/usr/local/netscape/";
            break;

        case Unix_LibDirectory:
            *this = "/usr/local/lib/netscape/";
            break;

        case Unix_HomeDirectory:
#ifdef VMS
	    {
	        char *pHome;
	        pHome = getenv("HOME");
		if (*pHome == '/')
        	    *this = pHome;
		else
        	    *this = decc$translate_vms(pHome);
	    }
#else
            *this = PR_GetEnv("HOME");
#endif
            break;

#endif        

#ifdef XP_BEOS
        case BeOS_SettingsDirectory:
		{
            char path[MAXPATHLEN];
			find_directory(B_USER_SETTINGS_DIRECTORY, 0, 0, path, MAXPATHLEN);
            // Need enough space to add the trailing backslash
			int len = strlen(path);
            if (len > MAXPATHLEN-2)
                break;
            path[len]   = '/';
            path[len+1] = '\0';
			*this = path;
            break;
		}

        case BeOS_HomeDirectory:
		{
            char path[MAXPATHLEN];
			find_directory(B_USER_DIRECTORY, 0, 0, path, MAXPATHLEN);
            // Need enough space to add the trailing backslash
			int len = strlen(path);
            if (len > MAXPATHLEN-2)
                break;
            path[len]   = '/';
            path[len+1] = '\0';
			*this = path;
            break;
		}

        case BeOS_DesktopDirectory:
		{
            char path[MAXPATHLEN];
			find_directory(B_DESKTOP_DIRECTORY, 0, 0, path, MAXPATHLEN);
            // Need enough space to add the trailing backslash
			int len = strlen(path);
            if (len > MAXPATHLEN-2)
                break;
            path[len]   = '/';
            path[len+1] = '\0';
			*this = path;
            break;
		}

        case BeOS_SystemDirectory:
		{
            char path[MAXPATHLEN];
			find_directory(B_BEOS_DIRECTORY, 0, 0, path, MAXPATHLEN);
            // Need enough space to add the trailing backslash
			int len = strlen(path);
            if (len > MAXPATHLEN-2)
                break;
            path[len]   = '/';
            path[len+1] = '\0';
			*this = path;
            break;
		}
#endif        
#ifdef XP_OS2
        case OS2_SystemDirectory:
        {
            ULONG ulBootDrive = 0;
            char  buffer[] = " :\\OS2\\System\\";
            DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
                             &ulBootDrive, sizeof ulBootDrive);
            buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index...
            *this = buffer;
#ifdef DEBUG
            printf( "Got OS2_SystemDirectory: %s\n", buffer);
#endif
            break;
        }

     case OS2_OS2Directory:
        {
            ULONG ulBootDrive = 0;
            char  buffer[] = " :\\OS2\\";
            DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
                             &ulBootDrive, sizeof ulBootDrive);
            buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index...
            *this = buffer;
#ifdef DEBUG
            printf( "Got OS2_OS2Directory: %s\n", buffer);
#endif
            break;
        }

     case OS2_HomeDirectory:
        {
            char *tPath = PR_GetEnv("MOZILLA_HOME");
            /* If MOZILLA_HOME is not set, use GetCurrentProcessDirectory */
            /* To ensure we get a long filename system */
            if (!tPath || !*tPath)
              GetCurrentProcessDirectory(*this);
            else
              *this = tPath;
            PrfWriteProfileString(HINI_USERPROFILE, "Mozilla", "Home", *this);
            break;
        }

        case OS2_DesktopDirectory:
        {
            char szPath[CCHMAXPATH + 1];        
            BOOL fSuccess;
            fSuccess = WinQueryActiveDesktopPathname (szPath, sizeof(szPath));
            int len = strlen (szPath);   
            if (len > CCHMAXPATH -1)
               break;
            szPath[len] = '\\';     
            szPath[len + 1] = '\0';
#ifdef DEBUG
            if (fSuccess) {
               printf ("Got OS2_DesktopDirectory: %s\n", szPath);
            } else {
               printf ("Failed getting OS2_DesktopDirectory: %s\n", szPath);
            }
#endif
            break;           
        }

#endif
        default:
            break;    
    }
}
/*����������������������������������������������������������������������������*/
BOOL WriteSpyINI(HWND      hFrame,   /* HWND(Agent's frame) */
                 LONG      Agent,    /* one-origin "agent" */
                 PINI_DATA pIni)     /* INI data to write */
{
  CHAR szAgent[32],
       szData[128];

  HINI hINI          = NULLH;
  BOOL bOK           = BOOL_FALSE;

  /*������������������������������������������������������������������������Ŀ*/
  /*� Open the PMSPY "profile"                                               �*/
  /*��������������������������������������������������������������������������*/
  if ( (hINI = PrfOpenProfile( WinQueryAnchorBlock(hFrame),
                               szINI)) != NULLH )
  {
    /*����������������������������������������������������������������������Ŀ*/
    /*� Determine which "agent" this data is for                             �*/
    /*������������������������������������������������������������������������*/
    sprintf(szAgent, Strings[IDS_FMT_AGENT], Agent);

    /*����������������������������������������������������������������������Ŀ*/
    /*� Write Agent's FONT to the PMSPY "profile"                            �*/
    /*������������������������������������������������������������������������*/
    PrfWriteProfileString(hINI, szAgent, szKeyFont, pIni->szListFont);

    /*����������������������������������������������������������������������Ŀ*/
    /*� Write Agent's LOG to the PMSPY "profile"                             �*/
    /*������������������������������������������������������������������������*/
    PrfWriteProfileString(hINI, szAgent, szKeyLog, pIni->szLog);

    /*����������������������������������������������������������������������Ŀ*/
    /*� Write Agent's PROFILE to the PMSPY "profile"                         �*/
    /*������������������������������������������������������������������������*/
    PrfWriteProfileString(hINI, szAgent, szKeyPro, pIni->szProfile);

    /*����������������������������������������������������������������������Ŀ*/
    /*� Write Agent's WINDOW POSITION to the PMSPY "profile"                 �*/
    /*������������������������������������������������������������������������*/
    if ( WinQueryWindowPos(hFrame, &pIni->swpAgent) )
    {
       sprintf(szData, "%d", pIni->swpAgent.x);
       PrfWriteProfileString(hINI, szAgent, szKeyPosX,   szData);

       sprintf(szData, "%d", pIni->swpAgent.y);
       PrfWriteProfileString(hINI, szAgent, szKeyPosY,   szData);

       sprintf(szData, "%d", pIni->swpAgent.cx);
       PrfWriteProfileString(hINI, szAgent, szKeySizeCX, szData);

       sprintf(szData, "%d", pIni->swpAgent.cy);
       PrfWriteProfileString(hINI, szAgent, szKeySizeCY, szData);
    }

    /*����������������������������������������������������������������������Ŀ*/
    /*� Close the PMSPY "profile"                                            �*/
    /*������������������������������������������������������������������������*/
    PrfCloseProfile(hINI);

    bOK = BOOL_TRUE;
  }

  return( bOK );
}
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);
}
Пример #14
0
static void FindSwapperDat (char *SwapperDat) {

  char        *filename = "C:\\CONFIG.SYS",*p,*pp;
  char        *input = NULL;
  FILE        *fp;
  FILEFINDBUF3 ffb;
  ULONG        nm = 1L,size = sizeof(SwapperDat);
  HDIR         hdir = HDIR_CREATE;
  APIRET       rc = 1L;

  input = malloc(8192);
  if(input) {
    *input = 0;
    *SwapperDat = 0;
    PrfQueryProfileData(prof,
                        appname,
                        "SwapperDat",
                        (PVOID)SwapperDat,
                        &size);
    if(*SwapperDat) {
      rc = DosFindFirst(SwapperDat,
                        &hdir,
                        FILE_NORMAL | FILE_ARCHIVED |
                        FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
                        &ffb,
                        sizeof(ffb),
                        &nm,
                        FIL_STANDARD);
      if(!rc) {
        DosFindClose(hdir);
        fp = fopen(SwapperDat,"r");
        if(fp) {
          fclose(fp);
          *SwapperDat = 0;
          rc = 1L;
        }
      }
      else
        *SwapperDat = 0;
    }
    if(rc) {
      if(DosQuerySysInfo(QSV_BOOT_DRIVE,
                         QSV_BOOT_DRIVE,
                         (PVOID)&nm,
                         (ULONG)sizeof(ULONG)))
        nm = 3L;
      *filename = (char)nm + '@';
      fp = fopen(filename,"r");
      if(fp) {
        while(!feof(fp)) {
          if(!fgets(input,8192,fp))
            break;
          input[8191] = 0;
          lstrip(input);
          if(!strnicmp(input,"SWAPPATH",8)) {
            p = input + 8;
            while(*p == ' ')
              p++;
            if(*p == '=') {
              p++;
              stripcr(p);
              rstrip(p);
              while(*p == ' ')
                p++;
              if(*p == '\"') {
                p++;
                pp = p;
                while(*pp && *pp != '\"')
                  *pp++;
                if(*pp)
                  *pp = 0;
              }
              else {
                pp = strchr(p,' ');
                if(pp)
                  *pp = 0;
              }
              if(*p) {
                strncpy(SwapperDat,p,CCHMAXPATH);
                SwapperDat[CCHMAXPATH - 1] = 0;
                if(SwapperDat[strlen(SwapperDat) - 1] != '\\')
                  strcat(SwapperDat,"\\");
                strcat(SwapperDat,"SWAPPER.DAT");
                hdir = HDIR_CREATE;
                nm = 1L;
                if(!DosFindFirst(SwapperDat,
                                 &hdir,
                                 FILE_NORMAL | FILE_ARCHIVED |
                                 FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
                                 &ffb,
                                 sizeof(ffb),
                                 &nm,
                                 FIL_STANDARD)) {
                  DosFindClose(hdir);
                  PrfWriteProfileString(prof,
                                        appname,
                                        "SwapperDat",
                                        SwapperDat);
                }
                else
                  *SwapperDat = 0;
                break;
              }
            }
          }
        }
        fclose(fp);
      }
    }
    if(!*SwapperDat) {
      if(DosQuerySysInfo(QSV_BOOT_DRIVE,
                         QSV_BOOT_DRIVE,
                         (PVOID)&nm,
                         (ULONG)sizeof(ULONG)))
        nm = 3L;
      sprintf(SwapperDat,
              "%c:\\OS2\\SYSTEM\\SWAPPER.DAT",
              (char)nm + '@');
      hdir = HDIR_CREATE;
      nm = 1L;
      if(!DosFindFirst(SwapperDat,
                       &hdir,
                       FILE_NORMAL | FILE_ARCHIVED |
                       FILE_HIDDEN | FILE_SYSTEM | FILE_READONLY,
                       &ffb,
                       sizeof(ffb),
                       &nm,
                       FIL_STANDARD)) {
        DosFindClose(hdir);
        PrfWriteProfileString(prof,
                              appname,
                              "SwapperDat",
                              SwapperDat);
      }
      else
        *SwapperDat = 0;
    }
    free(input);
  }
}
Пример #15
0
/* ------------------------------------------------------------------------- */
int main ( int argc, char *argv[] )
{
    HMQ    hmq;                     // PM message-queue handle
    PTIB   ptib;                    // thread info block pointer
    ULONG  ulLen;                   // font key length
    BOOL   fOK;
    PSZ    psz;
    CHAR   szFontFile[ CCHMAXPATH ],
           szFontKey[ CCHMAXPATH ];
    APIRET rc;                      // return code


    // Get input options
    if ( argc < 2 ) {
        printf("%s - Install a font in Presentation Manager.\n", strupr(argv[0]) );
        printf("Syntax: %s <font filename>\n", argv[0] );
        return 0;
    }
    strupr( argv[1] );

    // Determine the fully-qualified name
    rc = DosQueryPathInfo( argv[1], FIL_QUERYFULLNAME, (PVOID) szFontFile, CCHMAXPATH );
    if ( rc ) {
        printf("Failed to resolve filename %s (RC=%u)\n", argv[1], rc );
        return rc;
    }

    // Get the filename-only portion
    psz = strrchr( szFontFile, '\\');
    if ( !psz ) {
        psz = strchr( szFontFile, ':');
        if ( !psz ) psz = szFontFile;
        else psz++;
    }
    else psz++;
    strncpy( szFontKey, psz, sizeof(szFontKey) );

    // If the font filename ends in .FON, strip it off
    ulLen = strlen( szFontKey );
    psz = szFontKey + (ulLen - 4);
    if ( stricmp( psz, ".FON") == 0 ) *psz = 0;

    // Initialize PM
    DosGetInfoBlocks( &ptib, &ppib );
    ulPType = ppib->pib_ultype;
    ppib->pib_ultype = 3;

    hab = WinInitialize( 0 );
    WinCreateMsgQueue( hab, 0 );

    fOK = GpiLoadPublicFonts( hab, szFontFile );
    if ( !fOK )
        MorphOutput("Failed to register font: GpiLoadPublicFonts() failed.\n");
    else {
        fOK = PrfWriteProfileString( HINI_USERPROFILE, "PM_Fonts", szFontKey, szFontFile );
        if ( !fOK )
            MorphOutput("Failed to register font: PrfWriteProfileString() failed.\n");
    }

    // Clean up and exit
    WinDestroyMsgQueue( hmq );
    WinTerminate( hab );
    ppib->pib_ultype = ulPType;

    return fOK;
}
Пример #16
0
ZExport (ZProfile &) ZProfile::deleteKey (const ZString & aKeyName)
{
  ZFUNCTRACE_DEVELOP ("ZProfile::deleteKey(const ZString& aKeyName)");
#ifdef ZC_WIN
  // delete all values and subkeys first
  ZString oldPath (iPath);
  try
  {
    setPath (iPath + (char) ZC_PATHSEPARATOR + aKeyName);
    openPath (zFalse);

    ZStringlist list;
    int i;

    // delete all values
    setValue (ZString ());      // just clear out default value
    getValues (list);
    for (i = 0; i < list.count (); i++)
      if (list[i].size ())
          {
            deleteValue (list[i]);
          }                     // if

    // delete all subkeys
    getKeys (list);
    for (i = 0; i < list.count (); i++)
      deleteKey (list[i]);
  }                             // try
  catch (const ZException & exc)
  {
    setPath (oldPath);
    throw;
  }                             // catch

  setPath (oldPath);
  openPath (zFalse);
  RegDeleteKey ((HKEY) iPathHandle, aKeyName);
#endif
#ifdef ZC_OS2
  if (iPath.size () && aKeyName.size ())
    return *this;               // no keys at this level

  openRoot ();

  if (!iPath.size () && !aKeyName.size ())
      {
        // delete all applications:

        // will only do this if not the system- or user profile!
        if (iRootHandle == HINI_SYSTEMPROFILE ||
            iRootHandle == HINI_USERPROFILE)
          return *this;

        ZStringlist apps;
        getKeys (apps);
        for (long i = 0; i < apps.count (); i++)
          if (!PrfWriteProfileString (iRootHandle, apps[i], 0, 0))
            throwSysErr (PrfWriteProfileStringName);
      }
  else
      {
        if (!PrfWriteProfileString (iRootHandle,
                                    iPath.size ()? iPath : aKeyName, 0, 0))
          throwSysErr (PrfWriteProfileStringName);
      }                         // if
#endif
  return *this;
}                               // deleteKey
Пример #17
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);
  }
nsresult
GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory,
                          nsIFile** aFile)
{
#if defined(XP_WIN)
    WCHAR path[MAX_PATH];
#else
    char path[MAXPATHLEN];
#endif

    switch (aSystemSystemDirectory)
    {
        case OS_CurrentWorkingDirectory:
#if defined(XP_WIN)
            if (!_wgetcwd(path, MAX_PATH))
                return NS_ERROR_FAILURE;
            return NS_NewLocalFile(nsDependentString(path),
                                   true,
                                   aFile);
#elif defined(XP_OS2)
            if (DosQueryPathInfo( ".", FIL_QUERYFULLNAME, path, MAXPATHLEN))
                return NS_ERROR_FAILURE;
#else
            if(!getcwd(path, MAXPATHLEN))
                return NS_ERROR_FAILURE;
#endif

#if !defined(XP_WIN)
            return NS_NewNativeLocalFile(nsDependentCString(path),
                                         true,
                                         aFile);
#endif

        case OS_DriveDirectory:
#if defined (XP_WIN)
        {
            PRInt32 len = ::GetWindowsDirectoryW(path, MAX_PATH);
            if (len == 0)
                break;
            if (path[1] == PRUnichar(':') && path[2] == PRUnichar('\\'))
                path[3] = 0;

            return NS_NewLocalFile(nsDependentString(path),
                                   true,
                                   aFile);
        }
#elif defined(XP_OS2)
        {
            ULONG ulBootDrive = 0;
            char  buffer[] = " :\\OS2\\";
            DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
                             &ulBootDrive, sizeof ulBootDrive);
            buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index...

            return NS_NewNativeLocalFile(nsDependentCString(buffer),
                                         true,
                                         aFile);
        }
#else
        return NS_NewNativeLocalFile(nsDependentCString("/"),
                                     true,
                                     aFile);

#endif

        case OS_TemporaryDirectory:
#if defined (XP_WIN)
            {
            DWORD len = ::GetTempPathW(MAX_PATH, path);
            if (len == 0)
                break;
            return NS_NewLocalFile(nsDependentString(path, len),
                                   true,
                                   aFile);
        }
#elif defined(XP_OS2)
        {
            char *tPath = PR_GetEnv("TMP");
            if (!tPath || !*tPath) {
                tPath = PR_GetEnv("TEMP");
                if (!tPath || !*tPath) {
                    // if an OS/2 system has neither TMP nor TEMP defined
                    // then it is severely broken, so this will never happen.
                    return NS_ERROR_UNEXPECTED;
                }
            }
            nsCString tString = nsDependentCString(tPath);
            if (tString.Find("/", false, 0, -1)) {
                tString.ReplaceChar('/','\\');
            }
            return NS_NewNativeLocalFile(tString, true, aFile);
        }
#elif defined(MOZ_WIDGET_COCOA)
        {
            return GetOSXFolderType(kUserDomain, kTemporaryFolderType, aFile);
        }

#elif defined(XP_UNIX)
        {
            static const char *tPath = nullptr;
            if (!tPath) {
                tPath = PR_GetEnv("TMPDIR");
                if (!tPath || !*tPath) {
                    tPath = PR_GetEnv("TMP");
                    if (!tPath || !*tPath) {
                        tPath = PR_GetEnv("TEMP");
                        if (!tPath || !*tPath) {
                            tPath = "/tmp/";
                        }
                    }
                }
            }
            return NS_NewNativeLocalFile(nsDependentCString(tPath),
                                         true,
                                         aFile);
        }
#else
        break;
#endif
#if defined (XP_WIN)
        case Win_SystemDirectory:
        {
            PRInt32 len = ::GetSystemDirectoryW(path, MAX_PATH);

            // Need enough space to add the trailing backslash
            if (!len || len > MAX_PATH - 2)
                break;
            path[len]   = L'\\';
            path[++len] = L'\0';

            return NS_NewLocalFile(nsDependentString(path, len),
                                   true,
                                   aFile);
        }

        case Win_WindowsDirectory:
        {
            PRInt32 len = ::GetWindowsDirectoryW(path, MAX_PATH);

            // Need enough space to add the trailing backslash
            if (!len || len > MAX_PATH - 2)
                break;

            path[len]   = L'\\';
            path[++len] = L'\0';

            return NS_NewLocalFile(nsDependentString(path, len),
                                   true,
                                   aFile);
        }

        case Win_ProgramFiles:
        {
            return GetWindowsFolder(CSIDL_PROGRAM_FILES, aFile);
        }

        case Win_HomeDirectory:
        {
            nsresult rv = GetWindowsFolder(CSIDL_PROFILE, aFile);
            if (NS_SUCCEEDED(rv))
                return rv;

            PRInt32 len;
            if ((len = ::GetEnvironmentVariableW(L"HOME", path, MAX_PATH)) > 0)
            {
                // Need enough space to add the trailing backslash
                if (len > MAX_PATH - 2)
                    break;

                path[len]   = L'\\';
                path[++len] = L'\0';

                rv = NS_NewLocalFile(nsDependentString(path, len),
                                     true,
                                     aFile);
                if (NS_SUCCEEDED(rv))
                    return rv;
            }

            len = ::GetEnvironmentVariableW(L"HOMEDRIVE", path, MAX_PATH);
            if (0 < len && len < MAX_PATH)
            {
                WCHAR temp[MAX_PATH];
                DWORD len2 = ::GetEnvironmentVariableW(L"HOMEPATH", temp, MAX_PATH);
                if (0 < len2 && len + len2 < MAX_PATH)
                    wcsncat(path, temp, len2);

                len = wcslen(path);

                // Need enough space to add the trailing backslash
                if (len > MAX_PATH - 2)
                    break;

                path[len]   = L'\\';
                path[++len] = L'\0';

                return NS_NewLocalFile(nsDependentString(path, len),
                                       true,
                                       aFile);
            }
        }
        case Win_Desktop:
        {
            return GetWindowsFolder(CSIDL_DESKTOP, aFile);
        }
        case Win_Programs:
        {
            return GetWindowsFolder(CSIDL_PROGRAMS, aFile);
        }

        case Win_Downloads:
        {
            // Defined in KnownFolders.h.
            GUID folderid_downloads = {0x374de290, 0x123f, 0x4565, {0x91, 0x64,
                                       0x39, 0xc4, 0x92, 0x5e, 0x46, 0x7b}};
            nsresult rv = GetKnownFolder(&folderid_downloads, aFile);
            // On WinXP, there is no downloads folder, default
            // to 'Desktop'.
            if(NS_ERROR_FAILURE == rv)
            {
              rv = GetWindowsFolder(CSIDL_DESKTOP, aFile);
            }
            return rv;
        }

        case Win_Controls:
        {
            return GetWindowsFolder(CSIDL_CONTROLS, aFile);
        }
        case Win_Printers:
        {
            return GetWindowsFolder(CSIDL_PRINTERS, aFile);
        }
        case Win_Personal:
        {
            return GetWindowsFolder(CSIDL_PERSONAL, aFile);
        }
        case Win_Favorites:
        {
            return GetWindowsFolder(CSIDL_FAVORITES, aFile);
        }
        case Win_Startup:
        {
            return GetWindowsFolder(CSIDL_STARTUP, aFile);
        }
        case Win_Recent:
        {
            return GetWindowsFolder(CSIDL_RECENT, aFile);
        }
        case Win_Sendto:
        {
            return GetWindowsFolder(CSIDL_SENDTO, aFile);
        }
        case Win_Bitbucket:
        {
            return GetWindowsFolder(CSIDL_BITBUCKET, aFile);
        }
        case Win_Startmenu:
        {
            return GetWindowsFolder(CSIDL_STARTMENU, aFile);
        }
        case Win_Desktopdirectory:
        {
            return GetWindowsFolder(CSIDL_DESKTOPDIRECTORY, aFile);
        }
        case Win_Drives:
        {
            return GetWindowsFolder(CSIDL_DRIVES, aFile);
        }
        case Win_Network:
        {
            return GetWindowsFolder(CSIDL_NETWORK, aFile);
        }
        case Win_Nethood:
        {
            return GetWindowsFolder(CSIDL_NETHOOD, aFile);
        }
        case Win_Fonts:
        {
            return GetWindowsFolder(CSIDL_FONTS, aFile);
        }
        case Win_Templates:
        {
            return GetWindowsFolder(CSIDL_TEMPLATES, aFile);
        }
        case Win_Common_Startmenu:
        {
            return GetWindowsFolder(CSIDL_COMMON_STARTMENU, aFile);
        }
        case Win_Common_Programs:
        {
            return GetWindowsFolder(CSIDL_COMMON_PROGRAMS, aFile);
        }
        case Win_Common_Startup:
        {
            return GetWindowsFolder(CSIDL_COMMON_STARTUP, aFile);
        }
        case Win_Common_Desktopdirectory:
        {
            return GetWindowsFolder(CSIDL_COMMON_DESKTOPDIRECTORY, aFile);
        }
        case Win_Common_AppData:
        {
            return GetWindowsFolder(CSIDL_COMMON_APPDATA, aFile);
        }
        case Win_Printhood:
        {
            return GetWindowsFolder(CSIDL_PRINTHOOD, aFile);
        }
        case Win_Cookies:
        {
            return GetWindowsFolder(CSIDL_COOKIES, aFile);
        }
        case Win_Appdata:
        {
            nsresult rv = GetWindowsFolder(CSIDL_APPDATA, aFile);
            if (NS_FAILED(rv))
                rv = GetRegWindowsAppDataFolder(false, aFile);
            return rv;
        }
        case Win_LocalAppdata:
        {
            nsresult rv = GetWindowsFolder(CSIDL_LOCAL_APPDATA, aFile);
            if (NS_FAILED(rv))
                rv = GetRegWindowsAppDataFolder(true, aFile);
            return rv;
        }
#endif  // XP_WIN

#if defined(XP_UNIX)
        case Unix_LocalDirectory:
            return NS_NewNativeLocalFile(nsDependentCString("/usr/local/netscape/"),
                                         true,
                                         aFile);
        case Unix_LibDirectory:
            return NS_NewNativeLocalFile(nsDependentCString("/usr/local/lib/netscape/"),
                                         true,
                                         aFile);

        case Unix_HomeDirectory:
            return GetUnixHomeDir(aFile);

        case Unix_XDG_Desktop:
        case Unix_XDG_Documents:
        case Unix_XDG_Download:
        case Unix_XDG_Music:
        case Unix_XDG_Pictures:
        case Unix_XDG_PublicShare:
        case Unix_XDG_Templates:
        case Unix_XDG_Videos:
            return GetUnixXDGUserDirectory(aSystemSystemDirectory, aFile);
#endif

#ifdef XP_OS2
        case OS2_SystemDirectory:
        {
            ULONG ulBootDrive = 0;
            char  buffer[] = " :\\OS2\\System\\";
            DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
                             &ulBootDrive, sizeof ulBootDrive);
            buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index...

            return NS_NewNativeLocalFile(nsDependentCString(buffer),
                                         true,
                                         aFile);
        }

     case OS2_OS2Directory:
        {
            ULONG ulBootDrive = 0;
            char  buffer[] = " :\\OS2\\";
            DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE,
                             &ulBootDrive, sizeof ulBootDrive);
            buffer[0] = 'A' - 1 + ulBootDrive; // duh, 1-based index...

            return NS_NewNativeLocalFile(nsDependentCString(buffer),
                                         true,
                                         aFile);
        }

     case OS2_HomeDirectory:
        {
            nsresult rv;
            char *tPath = PR_GetEnv("MOZILLA_HOME");
            char buffer[CCHMAXPATH];
            /* If MOZILLA_HOME is not set, use GetCurrentProcessDirectory */
            /* To ensure we get a long filename system */
            if (!tPath || !*tPath) {
                PPIB ppib;
                PTIB ptib;
                DosGetInfoBlocks( &ptib, &ppib);
                DosQueryModuleName( ppib->pib_hmte, CCHMAXPATH, buffer);
                *strrchr( buffer, '\\') = '\0'; // XXX DBCS misery
                tPath = buffer;
            }
            rv = NS_NewNativeLocalFile(nsDependentCString(tPath),
                                       true,
                                       aFile);

            PrfWriteProfileString(HINI_USERPROFILE, "Mozilla", "Home", tPath);
            return rv;
        }

        case OS2_DesktopDirectory:
        {
            char szPath[CCHMAXPATH + 1];
            BOOL fSuccess;
            fSuccess = WinQueryActiveDesktopPathname (szPath, sizeof(szPath));
            if (!fSuccess) {
                // this could happen if we are running without the WPS, return
                // the Home directory instead
                return GetSpecialSystemDirectory(OS2_HomeDirectory, aFile);
            }
            int len = strlen (szPath);
            if (len > CCHMAXPATH -1)
                break;
            szPath[len] = '\\';
            szPath[len + 1] = '\0';

            return NS_NewNativeLocalFile(nsDependentCString(szPath),
                                         true,
                                         aFile);
        }
#endif
        default:
            break;
    }
    return NS_ERROR_NOT_AVAILABLE;
}
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 ) );	
}
Пример #20
0
void  h2font_save( HWND hwndWnd, HINI hiniPrf, PSZ pszApp )
{
   PrfWriteProfileString( hiniPrf, pszApp, szPrfKeyFont, achFont );
}
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 );	
}