Link to home
Start Free TrialLog in
Avatar of stevetr
stevetr

asked on

'rename' function in Win3.1, WinNT vs. Win95 OS

I am somewhat at an end with the rename(), _chdir() and _chdrive() run-time functions. (I am developing a 16-bit program, MSVC 1.5) Function calls within NT 4.0 and Windows 3.1 works great. My return value is zero. When I call the very same functions in Windows 95, all three fail

Does anyone have a suggestion or comment on this??

Please respond to struax@compuserve.com
Avatar of cph
cph

INT 21 7156 - Windows95 - LONG FILENAME - RENAME FILE
Inp.:
      AX = 7156h
      DS:DX -> ASCIZ old file or directory name (long names allowed)
      ES:DI -> ASCIZ new name (long names allowed)
Return: CF clear if successful
      CF set on error
          AX = error code
            7100h if function not supported
Note:      the file may be renamed into a different directory, but not across disks

INT 21 56-- - DOS 2+ - "RENAME" - RENAME FILE
Inp.:
      AH = 56h
      DS:DX -> ASCIZ filename of existing file (no wildcards, but see below)
      ES:DI -> ASCIZ new filename (no wildcards)
      CL = attribute mask (server call only, see below)
Return: CF clear if successful
      CF set on error
          AX = error code (02h,03h,05h,11h) (see #1332)
Notes:      allows move between directories on same logical volume
      this function does not set the archive attribute
        (see #1073 at AX=4301h), which results in incremental backups not backing up the file under its new name open files should not be renamed (DOS 2.x only) this function renames file by creating a new directory entry with the new name,then marking the old entry deleted (DOS 3.0+) allows renaming of directories
(DOS 3.1+) wildcards are allowed if invoked via AX=5D00h, in which case  error 12h (no more files) is returned on success, and both source and destination specs must be canonical (as returned by AH=60h).

That's a kernel point of view.
My opinion is that under windows 95 before you want to do anything you got to lock the file....

Hope this help,

CpH
Avatar of stevetr

ASKER

Edited text of question
If have no problems what so ever with rename() etc. under Borland 5.0 and Win95.
.luc.

Long Filenames Functions
The long filename functions match the following Win32 file management functions.

Long filename function Win32 function
Interrupt 21h Function 5704h
Get Last Access Date and Time GetFileTime
Interrupt 21h Function 5705h
Set Last Access Date and Time SetFileTime
Interrupt 21h Function 5706h
Get Creation Date and Time GetFileTime
Interrupt 21h Function 5707h
Set Creation Date and Time SetFileTime
Interrupt 21h Function 7139h
Make Directory CreateDirectory
Interrupt 21h Function 713Ah
Remove Directory RemoveDirectory
Interrupt 21h Function 713Bh
Change Directory SetCurrentDirectory
Interrupt 21h Function 7141h
Delete File DeleteFile
Interrupt 21h Function 7143h
Get or Set File Attributes GetFileAttributes, SetFileAttributes
Interrupt 21h Function 7147h
Get Current Directory GetCurrentDirectory
Interrupt 21h Function 714Eh
Find First File FindFirstFile
Interrupt 21h Function 714Fh
Find Next File FindNextFile
Interrupt 21h Function 7156h
Rename File MoveFile
Interrupt 21h Function 7160h Minor Code 0h
Get Full Path Name GetFullPathName
Interrupt 21h Function 7160h Minor Code 1h
Get Short Path Name GetShortPathName
Interrupt 21h Function 7160h Minor Code 2h
Get Long Path Name No Win32 function equivalent
Interrupt 21h Function 716Ch
Create or Open File CreateFile, OpenFile
Interrupt 21h Function 71A0h
Get Volume Information GetVolumeInformation
Interrupt 21h Function 71A1h
Find Close FindClose
Interrupt 21h Function 71A6h
Get File Info By Handle GetFileInformationByHandle
Interrupt 21h Function 71A7h Minor Code 0h
File Time To DOS Time FileTimeToDOSDateTime
Interrupt 21h Function 71A7h Minor Code 1h
DOS Time To File Time DOSDateTimeToFileTime
Interrupt 21h Function 71A8h
Generate Short Name No Win32 function equivalent
Interrupt 21h Function 71A9h
Server Create or Open File No Win32 function equivalent
Interrupt 21h Function 71AAh Minor Code 0h
Create Subst No Win32 function equivalent
Interrupt 21h Function 71AAh Minor Code 1h
Terminate Subst No Win32 function equivalent
Interrupt 21h Function 71AAh Minor Code 2h
Query Subst No Win32 function equivalent


Note that Interrupt 21h Functions 71A2h through 71A5h exist, but they are for internal use by Windows 95 only.

Use network driver to deal with long file name :

The network driver can provide a variety of long-filename functions. The long-filename functions give access to files with names that do not fit the MS-DOS standard filename convention on network drives. These are the following long filename functions.
 
Function      Description

LFNCopy      Copies a file.
LFNDelete      Deletes a file.
LFNFindClose      Ends the search for matching files.
LFNFindFirst      Searches for the first file with a matching name.
LFNFindNext      Searches for the next file with a matching name.
LFNGetAttributes      Retrieves file attributes.
LFNGetVolumeLabel      Retrieves the volume label.
LFNMKDir      Creates a directory.
LFNMove      Moves a file.
LFNParse      Parses paths.
LFNRMDir      Removes a directory.
LFNSetAttributes      Sets file attributes.
LFNSetVolumeLabel      Sets the volume label.
LFNVolumeType      Specifies volume type.
Typically, these functions are called only when a network drive with long filenames is detected. In other words, they do not need to support local drives. The exception is the LFNCopy function, which must be able to copy to or from any type of volume.
The return value is typically an MS-DOS error function (as returned from MS-DOS functions when the carry flag is set, or from Interrupt 21h Function 59h, Get Extended Error Information). If a function returns the special error value 0xFFFF, then the network error message functions will be called to retrieve error message text.
The maximum length of any long filename will be assumed to be 260 characters, including the terminator.
File-attribute values are identical to MS-DOS file-attribute fields.


Avatar of stevetr

ASKER

Disregard this question. I had to create a new file, B, use
_lread() to read file A and _lwrite() to file B. Then I deleted file A.

Thanks for your input,

Steve
ASKER CERTIFIED SOLUTION
Avatar of AlFa
AlFa

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial