MoveFileEx Not Supported in Windows 95 But Functionality Is
  
PSS ID Number: Q129532
Article last modified on 09-25-1995
 
4.00
 
WINDOWS
 

-------------------------------------------------------------------------
The information in this article applies to:
 
 - Microsoft Win32 Application Programming Interface (API) included with:
 
    - Microsoft Windows 95 version 4.0
-------------------------------------------------------------------------
 
SUMMARY
=======
 
Win32 applications running on Windows NT use MoveFileEx() with the
DELAY_UNTIL_REBOOT flag to move, replace, or delete the files currently
being used. Examples of such files include device drivers and setup
programs. To replace a file that is in use, you would do something like
this:
 
   MoveFileEx(szDstFile, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
   MoveFileEx(szSrcFile, szDstFile, MOVEFILE_DELAY_UNTIL_REBOOT);
 
Windows 95 does not implement MoveFileEx() but does provide an alternate
way for all Win32-, Win16-, and MS-DOS-based applications to move, replace,
or delete files that are currently in use. To replace a file that is in
use, you would do something like this:
 
   GetWindowsDirectory(szTmpName, cchpFullPathBuf);
   lstrcat(szTmpName, "\\WININIT.INI");
   WritePrivateProfileString("Rename", "NUL", szDstFile, szTmpName);
   WritePrivateProfileString("Rename", szDstFile, szSrcFile, szTmpname);
 
MORE INFORMATION
================
 
Although Windows 95 does not implement MoveFileEx(), it provides similar
functionality to the DELAY_UNTIL_REBOOT flag through the [rename] section
of WININIT.INI. If WININIT.INI is present in the Windows directory,
WININIT.EXE processes it when the system boots. Once WININIT.INI has been
processed, WININIT.EXE renames it to WININIT.BAK.
 
The syntax of the [rename] section is:
 
   DestinationFileName=SourceFileName
 
NOTE: The source and destination filenames in WININIT.INI must be 8.3 file
names. Long filenames are not processed.
 
The [rename] section can have multiple lines with one file per line. To
delete a file, specify NUL as the DestinationFileName.
 
NOTE: DestinationFileName and SourceFileName cannot be long filenames,
because WININIT.INI is processed before the protected mode disk system is
loaded, and long filenames are only available when the protected mode disk
system is running.
 
Here are some example entries:
 
   [rename]
   NUL=C:\TEMP.TXT
   C:\NEW_DIR\EXISTING.TXT=C:\EXISTING.TXT
   C:\NEW_DIR\NEWNAME.TXT=C:\OLDNAME.TXT
   C:\EXISTING.TXT=C:\TEMP\NEWFILE.TXT
 
The first line causes TEMP.TXT to be deleted. The second line causes
EXISTING.TXT to be moved to a new directory. The third line causes
OLDNAME.TXT to be moved and renamed. The fourth line causes an existing
file to be overwritten by NEWFILE.TXT.
 
Applications should not use WritePrivateProfileString() to write entries to
the [rename] section because there can be multiple lines with the same
DestinationFileName, especially if DestinationFileName is "NUL." Instead,
they should add entries by parsing WININIT.INI and appending them to the
end of the [rename] section.
 
Applications that use WININIT.INI should check for its existence in the
Windows directory. If WININIT.INI is present, then another application has
written to it since the system was last restarted. Therefore, the
application should open it, and add entries to the [rename] section. If
WININIT.INI isn't present, the application should create it and add to the
[rename] section. Doing so ensures that entries from other applications
won't be deleted accidentally by your application.
 
NOTE: WININIT.INI is not processed until Windows 95 is restarted.
 
Additional reference words: 4.00
KBCategory: kbprg
KBSubcategory: BseFileio
=============================================================================
Copyright Microsoft Corporation 1995.
