Subj : Re: BC++5.02 16bits application and folders To : borland.public.cpp.borlandcpp From : "Ed Mulroy [TeamB]" Date : Fri Feb 27 2004 05:24 pm Interrupt 0x21, function 0x7156 is a Windows 95 function for renaming a file. It is not a DOS function. The DOS functionality built into Windows 95 supports it but MSDOS does not support it. The MSDOS file system does not support long file names. The 12 and 16 bit file attribute table, FAT, used by MSDOS do not have the bits which are used as continuation flags for putting the remainder of the file names into subsequent FAT entries. That code may run on a machine with 32 bit Windows 95 installed but it will not work with an MSDOS machine. .. Ed > Sebastian Ledesma wrote in message > news:403fa4e0$1@newsgroups.borland.com... > > Try this, I used it for an old 16bit that runs with other 32bits > apps, some time ago I migrated this application to > Win32, but this function should work right now: > > Saludos > Sebastian > > PS: Sorry for a litle long post. > > #include > #include "longname.h" > #include > #include > #include > > #define CF 1 > > int winRename(const char _FAR *oldname, const char _FAR *newname) { > #if defined WIN32 > return MoveFile(oldname, newname); > #else > struct REGPACK regs; > regs.r_ax = 0x7156; > regs.r_ds = FP_SEG(oldname); > regs.r_dx = FP_OFF(oldname); > regs.r_es = FP_SEG(newname); > regs.r_di = FP_OFF(newname); > intr(0x21, ®s); > if (regs.r_flags & CF) > return regs.r_ax; > return 0; > #endif > > } > > BOOL GetDosName(char *longname, char *shortname) { > WIN32_FIND_DATA fd; > HANDLE hfind; > > hfind = FindFirstFile(longname, &fd); > if (hfind == INVALID_HANDLE_VALUE) > return FALSE; > > if (strlen(fd.cAlternateFileName) > 0) > strcpy(shortname, fd.cAlternateFileName); > else > strcpy(shortname, fd.cFileName); > FindClose(hfind); > return TRUE; > } > > BOOL GetWindowsName(char *shortname, char *longname) { > WIN32_FIND_DATA fd; > HANDLE hfind; > > hfind = FindFirstFile(shortname, &fd); > if (hfind == INVALID_HANDLE_VALUE) > return FALSE; > > strcpy(longname, fd.cFileName); > FindClose(hfind); > return TRUE; > } .