예제 #1
0
파일: remove2.c 프로젝트: swhobbit/UUPC
int removeOS2File( const char *fname, const char *file, const size_t line )
{

   APIRET rc;

/*--------------------------------------------------------------------*/
/*       If the user wants normal UNDELETE processing to proceed,     */
/*       we just use the regular UNIX system call                     */
/*--------------------------------------------------------------------*/

   if ( bflag[F_UNDELETE] )
      return unlink( fname );

   if ( fname == NULL )
   {
      errno = EINVAL;
      return -1;
   }

   rc = DosForceDelete( (PSZ) fname );

   if ( rc == 0 )
      return 0;

/*--------------------------------------------------------------------*/
/*       We had a problem.  Report the OS/2 error if unique,          */
/*       otherwise just translate the return code and pray.           */
/*--------------------------------------------------------------------*/

   switch( rc )
   {
      case ERROR_FILE_NOT_FOUND:
      case ERROR_PATH_NOT_FOUND:
         errno = ENOTEXIST;
         break;

      case ERROR_ACCESS_DENIED:
         errno = EACCESS;
         break;

      default:
         pOS2Err( line, file, fname, rc);
         errno = EOS2ERR;
         break;

   } /* switch */

   return (int) rc;

} /* removeOS2File */
예제 #2
0
파일: os_os2.c 프로젝트: 3rdexp/jezzitest
/*
** Close a file.
*/
int os2Close( OsFile **pld ){
  os2File *pFile;
  APIRET rc = NO_ERROR;
  if( pld && (pFile = (os2File*)*pld) != 0 ){
    OSTRACE2( "CLOSE %d\n", pFile->h );
    rc = DosClose( pFile->h );
    pFile->locktype = NO_LOCK;
    if( pFile->delOnClose != 0 ){
        rc = DosForceDelete( (PSZ)pFile->pathToDel );
    }
    *pld = 0;
    OpenCounter( -1 );
  }

  return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR;
}
예제 #3
0
/*
** Close a file.
*/
static int os2Close( sqlite3_file *id ){
  APIRET rc = NO_ERROR;
  os2File *pFile;
  if( id && (pFile = (os2File*)id) != 0 ){
    OSTRACE2( "CLOSE %d\n", pFile->h );
    rc = DosClose( pFile->h );
    pFile->locktype = NO_LOCK;
    if( pFile->pathToDel != NULL ){
      rc = DosForceDelete( (PSZ)pFile->pathToDel );
      free( pFile->pathToDel );
      pFile->pathToDel = NULL;
    }
    id = 0;
    OpenCounter( -1 );
  }

  return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR;
}
예제 #4
0
파일: os_os2.c 프로젝트: 3rdexp/jezzitest
/*
** Attempt to open a new file for exclusive access by this process.
** The file will be opened for both reading and writing.  To avoid
** a potential security problem, we do not allow the file to have
** previously existed.  Nor do we allow the file to be a symbolic
** link.
**
** If delFlag is true, then make arrangements to automatically delete
** the file when it is closed.
**
** On success, write the file handle into *id and return SQLITE_OK.
**
** On failure, return SQLITE_CANTOPEN.
*/
int sqlite3Os2OpenExclusive( const char *zFilename, OsFile **pld, int delFlag ){
  os2File  f;
  HFILE    hf;
  ULONG    ulAction;
  APIRET   rc = NO_ERROR;

  assert( *pld == 0 );
  rc = DosOpen( (PSZ)zFilename, &hf, &ulAction, 0L, FILE_NORMAL,
            OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_REPLACE_IF_EXISTS,
            OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_RANDOM |
                OPEN_SHARE_DENYREADWRITE | OPEN_ACCESS_READWRITE, (PEAOP2)NULL );
  if( rc != NO_ERROR ){
    return SQLITE_CANTOPEN;
  }

  f.h = hf;
  f.locktype = NO_LOCK;
  f.delOnClose = delFlag ? 1 : 0;
  f.pathToDel = delFlag ? sqlite3OsFullPathname( zFilename ) : NULL;
  OpenCounter( +1 );
  if( delFlag ) DosForceDelete( (PSZ)sqlite3OsFullPathname( zFilename ) );
  OSTRACE3( "OPEN EX %d \"%s\"\n", hf, sqlite3OsFullPathname ( zFilename ) );
  return allocateOs2File( &f, pld );
}
예제 #5
0
APIRET DeleteFile (PSZ          pszPath,
                   FILEFINDBUF3 *pFileInfo)
{
  APIRET     rc = NO_ERROR;                                /* API-Returncode */
  ULONG      ulAgeCurrent;             /* canonical file are of current file */
  FDATE      fdAgeCurrent;                             /* filedate structure */
  FILESTATUS fStat;                   /* filestatus structure for attributes */
  int        iAnswer;             /* user answer on the confirmation request */
  CHAR       szFileNameBuffer[MAXPATHLEN];         /* buffer for DosEditName */
  FILESTATUS3 fs3;   /* filestatus level 3 information from DosQueryPathInfo */
  CHAR       szFileDate[32];                     /* buffer for the file date */
  CHAR       szFileAttr[6];                /* buffer for the file attributes */
  CHAR       szTokenizerBuffer[MAXPATHLEN];               /* i hate strtok ! */

  if (!Options.fsDontDeleteFiles)              /* if we have to remove files */
  {
                                                            /* check for age */
    if (Options.fsFileAge)                 /* deletion selective on file age */
    {
      if (Options.fsFileAgeWrite)
      {
        fdAgeCurrent = pFileInfo->fdateLastWrite;
        ulAgeCurrent = ToolsDateToAge(fdAgeCurrent.day,
                                      fdAgeCurrent.month,
                                      fdAgeCurrent.year + 1980);
      }
      else
        if (Options.fsFileAgeAccess)
        {
          fdAgeCurrent = pFileInfo->fdateLastAccess;
          ulAgeCurrent = ToolsDateToAge(fdAgeCurrent.day,
                                   fdAgeCurrent.month,
                                   fdAgeCurrent.year + 1980);
        }
        else
          if (Options.fsFileAgeCreate)
          {
            fdAgeCurrent = pFileInfo->fdateCreation;
            ulAgeCurrent = ToolsDateToAge(fdAgeCurrent.day,
                                 fdAgeCurrent.month,
                                 fdAgeCurrent.year + 1980);
          }
          else
          {
                                     /* none specified, take last-write date */
            fdAgeCurrent = pFileInfo->fdateLastWrite;
            ulAgeCurrent = ToolsDateToAge(fdAgeCurrent.day,
                                     fdAgeCurrent.month,
                                     fdAgeCurrent.year + 1980);
          }

                                         /* now check if it is to be deleted */
      if (Options.fsFileAgeNewer)
      {
        if (ulAgeCurrent < Globals.ulFileDate)
          return (NO_ERROR);               /* abort processing for this file */
      }
      else
      {
        if (ulAgeCurrent > Globals.ulFileDate)
          return (NO_ERROR);               /* abort processing for this file */
      }
    }


                                            /* check with the file name mask */
    if (Options.fsFileNameMask)
    {
      PSZ  pszToken;  /* string pointer points to file token within filemask */
      BOOL fMatch;                         /* match - true, no match - false */

      strcpy (szTokenizerBuffer,                /* strtok is a real PITA !!! */
              Options.pszFileNameMask);

      pszToken = strtok(szTokenizerBuffer,                  /* tokenize this */
                        ",");
      fMatch   = FALSE;                               /* this is the default */

      while ( (pszToken != NULL) && /* as long as there is a name to process */
              (fMatch   == FALSE) )                /* and no match was found */
      {
        rc = DosEditName(1,                /* use OS/2 1.2 editing semantics */
                         pFileInfo->achName,                /* source string */
                         pszToken,                         /* editing string */
                         szFileNameBuffer,              /* local name buffer */
                         sizeof (szFileNameBuffer));        /* buffer length */
        if (rc != NO_ERROR)                              /* check for errors */
          return (rc);                              /* raise error condition */

        if (stricmp(pFileInfo->achName,     /* check if filename has changed */
                    szFileNameBuffer) == 0)
          fMatch = TRUE;                       /* the same, abort processing */

        pszToken = strtok(NULL,                    /* skip to the next token */
                          ",");
      }

      if (fMatch == FALSE)                           /* no match was found ! */
        return (NO_ERROR);                  /* then go not beyond this point */
    }


    StrFAttrToStringShort (pFileInfo->attrFile,        /* map the attributes */
                           szFileAttr);

    StrFDateTimeToString (pFileInfo->fdateLastWrite,   /* map the date       */
                          pFileInfo->ftimeLastWrite,
                          szFileDate);

    if (Options.fsSimulation)                    /* simulate deletion only ? */
      printf ("\n  %9u %s %s %s",
              pFileInfo->cbFile,
              szFileAttr,
              szFileDate,
              pFileInfo->achName);
    else
    {
      if (Options.fsVerbose ||                           /* verbose output ? */
          Options.fsShowFiles ||
          Options.fsConfirmationPrompt)
        printf ("\n  %9u %s %s %s",
                pFileInfo->cbFile,
                szFileAttr,
                szFileDate,
                pFileInfo->achName);

      if (Options.fsConfirmationPrompt)       /* prompt for every deletion ? */
      {
        iAnswer = ToolsConfirmationQuery();                  /* ask the user */
        switch (iAnswer)
        {
          case 0:                                                      /* no */
            return (NO_ERROR);                           /* abort processing */

          case 1:                                                     /* yes */
            break;                                           /* continue ... */

          case 2:                                                  /* escape */
            exit (1);                     /* PH: urgs, terminate the process */
        }
      }


      if (Options.fsForceDelete)
        rc = DosForceDelete(pszPath);        /* file will not be recoverable */
      else
        rc = DosDelete(pszPath);                  /* OK, remove that thing ! */

      if ( (rc == ERROR_ACCESS_DENIED) &&             /* check for READ-ONLY */
          Options.fsRemoveAttributes)
      {
        rc = DosQueryPathInfo (pszPath,            /* query file information */
                               FIL_STANDARD,
                               &fStat,
                               sizeof(fStat));
        if (rc != NO_ERROR)                              /* check for errors */
          return (rc);                              /* raise error condition */

        fStat.attrFile = FILE_NORMAL;                /* reset the attributes */

        rc = DosSetPathInfo (pszPath,                 /* set the information */
                             FIL_STANDARD,
                             &fStat,
                             sizeof(fStat),
                             0L);
        if (rc != NO_ERROR)                              /* check for errors */
          return (rc);                              /* raise error condition */

                                                            /* now try again */
        if (Options.fsForceDelete)
          rc = DosForceDelete(pszPath);      /* file will not be recoverable */
        else
          rc = DosDelete(pszPath);                /* OK, remove that thing ! */
      }
    }

    if (rc == NO_ERROR)             /* if the file has actually been deleted */
    {
      Globals.ulDeletedBytes += pFileInfo->cbFile;
      Globals.ulDeletedAlloc += pFileInfo->cbFileAlloc;
      Globals.ulFilesDeleted++;                     /* update the statistics */
    }
  }

  return (rc);                                                         /* ok */
}
예제 #6
0
int nextdir(int toplev)
{
#ifdef __OS2__
    FILEFINDBUF3 find;
    ULONG srch_cnt;
    HDIR dirhandle;
    APIRET findret;
#else
    struct ffblk find;
    ULONG srch_cnt;
    HDIR dirhandle;
    int findret;
#endif
    int retcode=TRUE, c, rc, nomore;

#ifdef DBG
    printf("entered nextdir %d\n", nextdirdepth++);
#endif

    srch_cnt = 1; dirhandle = HDIR_CREATE;
    findret =  DosFindFirst("*.*", &dirhandle, MUST_HAVE_DIRECTORY,
			     &find, sizeof(find), &srch_cnt,
			     FIL_STANDARD);
#ifdef __OS2__
    nomore = (findret == ERROR_NO_MORE_FILES);
#else
    nomore = ((findret == -1) && (_doserrno == ENMFILE));
    if (!nomore)
	dirhandle = 1;
#endif
#ifdef DBG
    printf("DosFindFirstDir returned %d(%d)\n", (int) findret, nomore);
    DOSFINDBAD(findret);
    assert(dirhandle != HDIR_CREATE);
#endif
    if (nomore)
	findret = 0;
    while (!nomore) {
	if ((findret == 0) && (FNAME != '.') && (FATTR & FILE_DIRECTORY)) {
	    /* descend next level */
	    if (toplev)
		printf("Deleting %s...\n", &FNAME);
#ifdef DBG
	    printf("descending to scan %s\n", &FNAME);
	    assert(0 == CHDIR(&FNAME));
	    retcode &= nextdir(FALSE);
	    /* ascend level and onto next directory */
	    assert(0 == CHDIR(".."));
	    printf("removing dir  %s\n", &FNAME);
#else
	    /* descend level */
	    if (CHDIR(&FNAME)) {
		/* descent impossible */
		retcode = FALSE;
		}
	    else {
		/* process next directory */
		retcode &= nextdir(FALSE);
		/* ascend level */
		if (CHDIR("..")) {
		    /* Something woefully wrong ... */
		    if (dirhandle != HDIR_CREATE) {
			DosFindClose(dirhandle);
			dirhandle = HDIR_CREATE;
			}
		    return(FALSE);
		    }
		else {
		    /* delete empty directory */
		    retcode &= (0 == DosDeleteDir(&FNAME));
		    }
		}
#endif
	    }
	/* Position to next entry */
	findret = DosFindNext(dirhandle, &find, sizeof(find), &srch_cnt);
#ifdef __OS2__
	nomore = (findret == ERROR_NO_MORE_FILES);
#else
	nomore = ((findret == -1) && (_doserrno == ENMFILE));
#endif
#ifdef DBG
	printf("DosFindNextDir returned %d(%d)\n", (int) findret, nomore);
	DOSFINDBAD(findret);
#endif
	if (nomore)
	    findret = 0;
	/* Process next entry */
	continue;
	}
    if (dirhandle != HDIR_CREATE) {
	DosFindClose(dirhandle);
	dirhandle = HDIR_CREATE;
	}
    srch_cnt = 1;

/* Now delete the files */
    findret = DosFindFirst("*.*",&dirhandle, FILE_ABNORMAL, &find,
			    sizeof(find), &srch_cnt, FIL_STANDARD);
#ifdef __OS2__
    nomore = (findret == ERROR_NO_MORE_FILES);
#else
    nomore = ((findret == -1) && (_doserrno == ENMFILE));
    if (!nomore)
	dirhandle = 1;
#endif
#ifdef DBG
    printf("DosFindFirstFile returned %d(%d)\n", (int) findret, nomore);
    DOSFINDBAD(findret);
#endif
    if (nomore)
	findret = 0;

     while (!nomore) {
	 if (findret == 0) {
	    /* Process if file OK */
	    if (toplev)
		printf("Deleting %s...\n", &FNAME);
#ifdef DBG
	    if (!findret && (FATTR & FILE_ABNORMAL))
		printf("making normal and %sdeleting %s\n",
		       dbgdel[forcedel], &FNAME);
	    else
		printf("%sdeleting %s\n",
		       dbgdel[forcedel], &FNAME);
#else
	    if (!findret && (FATTR & FILE_ABNORMAL))
		rc = _chmod(&FNAME, 1, 0);
	    if (!rc) {
#ifdef __OS2__
		if (forcedel)
		    retcode &= (0 == DosForceDelete(&FNAME));
		else
#endif
		    retcode &= (0 == DosDelete(&FNAME));
		}
	    else
		retcode = FALSE;
#endif
	    }
	/* Advance to next file */
	findret = DosFindNext(dirhandle, &find, sizeof(find), &srch_cnt);
#ifdef __OS2__
	nomore = (findret == ERROR_NO_MORE_FILES);
#else
	nomore = ((findret == -1) && (_doserrno == ENMFILE));
#endif
#ifdef DBG
	printf("DosFindNextFile returned %d(%d)\n", (int) findret, nomore);
	DOSFINDBAD(findret);
#endif
	if (nomore)
	    findret = 0;
	/* Process next file */
	continue;
	}
    if (dirhandle != HDIR_CREATE)
	DosFindClose(dirhandle);
#ifdef DBG
    printf("leaving nextdir %d\n", --nextdirdepth);
#endif
    return(retcode);
    }
예제 #7
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);
  }
INT main( INT argc, PCHAR argv[] )
{
 // Сбрасываем свойства приложения.
 bzero( &Enhancer, sizeof( ENHANCER ) );

 // Определяем приложение в системе.
 Enhancer.Application = WinInitialize( 0 );

 // Если это сделать не удалось - выход.
 if( Enhancer.Application == NULLHANDLE )
  {
   // Звук - ошибка.
   WinAlarm( HWND_DESKTOP, WA_ERROR );
   // Выход.
   DosExit( EXIT_PROCESS, 0 );
  }

 // Создаем очередь сообщений.
 HMQ Message_queue = WinCreateMsgQueue( Enhancer.Application, 0 );

 // Если очередь создать не удалось - выход.
 if( Message_queue == NULLHANDLE )
  {
   // Звук - ошибка.
   WinAlarm( HWND_DESKTOP, WA_ERROR );
   // Выход.
   WinTerminate( Enhancer.Application );
   DosExit( EXIT_PROCESS, 0 );
  }

 // Проверяем системные настройки.
 CheckSystemConfig();

 // Запускаем составляющие приложения.
 StdLib_Start();
 Strings_Start();
 Files_Start();

 Environment_Start();
 EnhancerProperties_Start();

 Loader_Start();
 Launcher_Start();

 // Узнаем, что надо сделать.
 if( argc == 2 )
  {
   if( stristr( "hide",    argv[ 1 ] ) ) Enhancer.Launcher_mode = 1;
   if( stristr( "mini",    argv[ 1 ] ) ) Enhancer.Launcher_mode = 1;
   if( stristr( "launch",  argv[ 1 ] ) ) Enhancer.Launcher_mode = 1;
   if( stristr( "enhance", argv[ 1 ] ) ) Enhancer.Enhancer_mode = 1;
  }

 // Возможно, надо вызвать окно настроек.
 if( argc == 2 )
  {
   if( strstr( "ControlCenter", argv[ 1 ] ) )
    {
     CHAR Path_to_ControlCenter[ SIZE_OF_PATH ] = "";
     GetCurrentPath( Path_to_ControlCenter );
     strcat( Path_to_ControlCenter, "\\Nice-eCS.exe" );

     Execute( Path_to_ControlCenter, argv[ 1 ] );

     WinDestroyMsgQueue( Message_queue );
     WinTerminate( Enhancer.Application );
     DosExit( EXIT_PROCESS, 0 );
    }
  }

 // Если действие не распознано - выход.
 if( !Enhancer.Enhancer_mode && !Enhancer.Launcher_mode )
  {
   WinDestroyMsgQueue( Message_queue );
   WinTerminate( Enhancer.Application );
   DosExit( EXIT_PROCESS, 0 );
  }

 // Если окно приложения уже есть - выход.
 {
  CHAR Semaphore_name[] = "\\SEM32\\NICE-OS2!L"; HMTX hmtxAlreadyRunning = NULLHANDLE;
  if( Enhancer.Enhancer_mode ) Semaphore_name[ strlen( Semaphore_name ) - 1 ] = 'E';

  if( DosOpenMutexSem( Semaphore_name, &hmtxAlreadyRunning ) == NO_ERROR )
   {
    WinDestroyMsgQueue( Message_queue );
    WinTerminate( Enhancer.Application );
    DosExit( EXIT_PROCESS, 0 );
   }
  else
   {
    DosCreateMutexSem( Semaphore_name, &hmtxAlreadyRunning, DC_SEM_SHARED, 1 );
   }
 }

 // Загрузчик должен запускаться до расширителя.
 if( Enhancer.Launcher_mode )
  {
   CHAR Semaphore_name[] = "\\SEM32\\NICE-OS2!E"; HMTX hmtxAlreadyRunning = NULLHANDLE;

   if( DosOpenMutexSem( Semaphore_name, &hmtxAlreadyRunning ) == NO_ERROR )
    {
     WinDestroyMsgQueue( Message_queue );
     WinTerminate( Enhancer.Application );
     DosExit( EXIT_PROCESS, 0 );
    }
  }

 // Расширитель должен запускаться после загрузчика
 if( Enhancer.Enhancer_mode )
  {
   CHAR Semaphore_name[] = "\\SEM32\\NICE-OS2!L"; HMTX hmtxAlreadyRunning = NULLHANDLE;

   if( DosOpenMutexSem( Semaphore_name, &hmtxAlreadyRunning ) != NO_ERROR )
    {
     WinDestroyMsgQueue( Message_queue );
     WinTerminate( Enhancer.Application );
     DosExit( EXIT_PROCESS, 0 );
    }
  }

 // Если надо вызвать загрузчик:
 if( Enhancer.Launcher_mode )
  {
   // Создаем поток для запуска расширителя.
   DosCreateThread( &Threads.Launcher, (PFNTHREAD) LauncherThread, 0, 0, STACK_SIZE );
  }

 // Если надо вызвать расширитель:
 if( Enhancer.Enhancer_mode )
  {
   // Пробуем найти окно загрузчика.
   HWND Launcher_window = NULLHANDLE; CHAR Launcher_title[] = "Nice-OS2!L";

   {
    // Перебираем окна в окне рабочего стола.
    HENUM Enumeration = WinBeginEnumWindows( WinQueryDesktopWindow( Enhancer.Application, NULLHANDLE ) ); HWND Window = NULLHANDLE;
    while( ( Window = WinGetNextWindow( Enumeration ) ) != NULLHANDLE )
     {
      // Узнаем заголовок окна.
      CHAR Window_title[ SIZE_OF_TITLE ] = "";
      WinQueryWindowText( WinWindowFromID( Window, FID_TITLEBAR ), SIZE_OF_TITLE, Window_title );

      // Если это окно расширителя - запоминаем его.
      if( strc( Window_title, Launcher_title ) )
       {
        Launcher_window = Window;
        break;
       }
     }
    WinEndEnumWindows( Enumeration );
   }

   // Если загрузчика нет - выход.
   // Вообще-то он должен быть, раз найден семафор, но кто знает...
   if( !Launcher_window )
    {
     WinTerminate( Enhancer.Application );
     DosExit( EXIT_PROCESS, 0 );
    }

   // Создаем потоки, устанавливаем обработчики событий.
   BYTE Success = NiceLoadEnhancer( Enhancer.Application, 0, Launcher_window );

   // Если это сделать не удалось - выход.
   if( !Success )
    {
     WinTerminate( Enhancer.Application );
     DosExit( EXIT_PROCESS, 0 );
    }

   // Читаем настройки и загружаем изображения в расширитель.
   // Этот метод выполняется внутри Nice-os2.dll, но так как DLL использует
   // адресное пространство приложения, все данные остаются в этом приложении.
   NiceReadSettings( 0 );

   // Включаем слежение за сообщениями.
   NiceRunEnhancer();
  }

 // Создаем окно рабочей области.
 CHAR Class_name[] = "NiceOS2WndClass!L";
 if( Enhancer.Enhancer_mode ) Class_name[ strlen( Class_name ) - 1 ] = 'E';
 WinRegisterClass( Enhancer.Application, Class_name, (PFNWP) Enhancer_MainWindowProc, 0, 0 );

 // Создаем окно рамки.
 CHAR MainWindow_title[] = "Nice-OS2!L";
 if( Enhancer.Enhancer_mode ) Class_name[ strlen( Class_name ) - 1 ] = 'E';

 ULONG Creation_flags = FCF_TITLEBAR | FCF_SYSMENU;
 Enhancer.Frame_window = WinCreateStdWindow( HWND_DESKTOP, CS_FRAME, &Creation_flags, Class_name, MainWindow_title, 0, NULLHANDLE, 0, &Enhancer.Client_window );
 WinShowWindow( Enhancer.Frame_window, 0 );

 // Выбираем сообщения из очереди.
 QMSG Message; bzero( &Message, sizeof( QMSG ) );
 while( WinGetMsg( Enhancer.Application, &Message, 0, 0, 0 ) ) WinDispatchMsg( Enhancer.Application, &Message );

 // Закрываем окна.
 WinDestroyWindow( Enhancer.Client_window );
 WinDestroyWindow( Enhancer.Frame_window );

 // Если вызван расширитель:
 if( Enhancer.Enhancer_mode )
  {
   // Отключаем обработчики событий, завершаем работу потоков.
   NiceReleaseEnhancer( Enhancer.Application, 0 );
  }

 // Удаляем файлы отладочной версии.
 DosForceDelete( "_log.txt" ); DosForceDelete( "XTest.exe" );

 // Сбрасываем очередь сообщений.
 WinDestroyMsgQueue( Message_queue );

 // Выход.
 WinTerminate( Enhancer.Application );
 DosExit( EXIT_PROCESS, 0 );
}
예제 #9
0
 int main(VOID) {



 UCHAR       uchFileName[]   = "DOSFDEL.DAT";   /* File we want to delete    */

 HFILE       fhDelFile       = 0;               /* File handle from DosOpen  */

 FILESTATUS3 fsts3FileInfo   = {{0}};  /* Information associated with file   */

 ULONG       ulBufferSize    = sizeof(FILESTATUS3); /* File info buffer size */

 ULONG       ulOpenAction    = 0;                 /* Action taken by DosOpen */

 APIRET      rc              = NO_ERROR;          /* Return code             */

 FHLOCK      FHLock          = 0;                 /* File handle lock        */



                 /* Create a read-only file */



  rc = DosProtectOpen(uchFileName, &fhDelFile,

               &ulOpenAction, 10L, FILE_READONLY,

               OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,

               OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE, 0L, &FHLock);

  if (rc != NO_ERROR) {

     printf("DosProtectOpen error: return code = %u\n", rc);

     return 1;

  }



  rc = DosProtectQueryFileInfo(fhDelFile, FIL_STANDARD,

               &fsts3FileInfo, ulBufferSize, FHLock);   /* Get standard info */

  if (rc != NO_ERROR) {

      printf("DosProtectQueryFileInfo error: return code = %u\n", rc);

      return 1;

  } else { printf("File %s created read-only.\n",uchFileName); }



    /*   Change the file attributes to be "normal"  */



    fsts3FileInfo.attrFile  = FILE_NORMAL;

    rc = DosProtectSetFileInfo(fhDelFile, FIL_STANDARD,

                        &fsts3FileInfo, ulBufferSize, FHLock);

    if (rc != NO_ERROR) {

        printf("DosProtectSetFileInfo error: return code = %u\n", rc);

        return 1;

    }



    rc = DosProtectClose(fhDelFile, FHLock);

    /* Should verify that (rc != NO_ERROR) here... */



           /* Delete the file */



    rc = DosForceDelete(uchFileName);

    if (rc != NO_ERROR) {

        printf("DosForceDelete error: return code = %u\n", rc);

        return 1;

    } else {

        printf("File %s has been deleted.\n",uchFileName);

    }  /* endif */



   return NO_ERROR;

}
예제 #10
0
VOID main( VOID )
{
 // ********************************************************** //

 // Можно создать приложение, *.dll или *.obj.
 CHAR Target[] = "/Ge+ /Ss+";    // Приложение.
 // CHAR Target[] = "/C /Ss+";   // Object.
 // CHAR Target[] = "/Ge- /Ss+"; // Library.

 // Процессор - Pentium.
 CHAR Processor[] = "/G5 /Gf+ /Gi+";

 // Оптимизация - по скорости.
 CHAR Optimization[] = "/Gs+ /O+ /Oi+";

 // Размер стека - как и у всех потоков.
 CHAR Stack_size[] = "/B\"/ST:32768\"";

 // Имена файлов.
 CHAR CPP_Name[] = "Nice-os2.cpp";
 CHAR DEF_Name[] = "Nice-os2.def";
 CHAR LIB_Name[] = "..\\Shared\\DosCalls\\Doscalls.lib";

 CHAR RC_Name[] =  "Resources\\Resources.rc";
 CHAR RES_Name[] = "Resources\\Resources.res";

 CHAR OBJ_Name[] = "Nice-os2.obj";
 CHAR TGT_Name[] = "Nice-os2.exe ";

 // ********************************************************** //

 // Задаем параметры.
 CHAR Compiler[] = "Icc.exe"; CHAR Parameters[ 255 ] = "";
 strcpy( Parameters, Compiler );     strcat( Parameters, "|" );
 strcat( Parameters, Target );       strcat( Parameters, " " );
 strcat( Parameters, CPP_Name );     strcat( Parameters, " " );
 strcat( Parameters, DEF_Name );     strcat( Parameters, " " );
 strcat( Parameters, LIB_Name );     strcat( Parameters, " " );
 strcat( Parameters, Processor );    strcat( Parameters, " " );
 strcat( Parameters, Optimization ); strcat( Parameters, " " );
 strcat( Parameters, Stack_size );
 strchg( Parameters, '|', 0x00 );

 // Удаляем файлы, которые требуется получить.
 DosForceDelete( TGT_Name );

 // Вызываем IBM VA C++.
 CHAR Error_string[ 1 ]; RESULTCODES Return_codes;
 DosResetBuffer( -1 ); DosExecPgm( Error_string, sizeof( Error_string ), EXEC_SYNC, Parameters, NULL, &Return_codes, Compiler );

 // Задаем параметры для Resource Compiler.
 // RC.exe - 16-разрядное приложение, и его надо вызвать как "Cmd /C RC.exe".
 CHAR RC_starter[] = "Cmd.exe"; Parameters[ 0 ] = 0;
 strcpy( Parameters, RC_starter );   strcat( Parameters, "|" );
 strcat( Parameters, "/C RC.exe" );  strcat( Parameters, " " );
 strcat( Parameters, RC_Name );      strcat( Parameters, " " );
 strcat( Parameters, TGT_Name );
 strchg( Parameters, '|', 0x00 );

 // Вызываем Resource Compiler.
 DosResetBuffer( -1 ); DosExecPgm( Error_string, sizeof( Error_string ), EXEC_SYNC, Parameters, NULL, &Return_codes, RC_starter );

 // Удаляем временные файлы.
 DosForceDelete( OBJ_Name ); DosForceDelete( RES_Name );

 // Звук.
 WinAlarm( HWND_DESKTOP, WA_NOTE );

 // Выход.
 return;
}