Page 1 of 1

long file names

Posted: Wed Mar 29, 2006 5:34 pm
by Peterg
Hello
I am trying to use lcreat to create long file names but each time i try i get a truncated name 8 characters long.

I can use the clfn.dll and this seems to work but occassionally it writes truncated file names aswell

Anybody any ideas

Peter

Posted: Wed Mar 29, 2006 5:36 pm
by Antonio Linares
Peter,

Please review samples\LongName.prg

Posted: Thu Mar 30, 2006 8:06 am
by Peterg
I have used this but I just get truncated file names

Peter

Posted: Thu Mar 30, 2006 9:48 am
by Antonio Linares
Peter,

It looks as a 16 bits limitation. With Harbour and FWH it works ok.

Posted: Thu Mar 30, 2006 9:59 am
by Peterg
Yes it does work with fwh and gradually moving over to this

thanks
Peter

Posted: Fri Mar 31, 2006 8:50 am
by dbSoft
REDEFINE GET oGetXls VAR cGetXls ID 102 OF oDlg ;
FONT oFont
REDEFINE BTNBMP ID 106 FILENAME lCUR + "\openXls.bmp" OF oDlg ;
ACTION ( cGetXls := cGetDir32("Select folder") , oGetXls:Refresh() )

Code: Select all

//-------------------------------------------
//  DLGS32.PRG
//-------------------------------------------
// 32 bits common dialogs from 16 bits apps

#include "FiveWin.ch"

#define INIFILE GetWinDir()+"\rundlg32.ini"

static nFilterIndex := 0

//----------------------------------------------------------------------------//

Function cGetFile32(cFileMask, cTitle, nDefaultMask, cInitDir, lSave, nFlags)

   local cSection, cFile
   local nRet

   DEFAULT lSave := .f.

   // On cGetFile() that parameter is a boolean for long filenames

   if nFlags != Nil .and. Valtype(nFlags) != "N"
      nFlags := Nil
   endif

   if !lSave
      cSection := "GetOpenFileName"
   else
      cSection := "GetSaveFileName"
   endif

   if File(INIFILE)
      Ferase(INIFILE)
   endif

   if cFileMask != Nil
      if "|"$cFileMask
         cFileMask := StrTran(cFileMask, " |", "|")
         cFileMask := StrTran(cFileMask, "| ", "|")
         WritePProString( cSection, "lpstrFilter", cFileMask, INIFILE )
      else
         WritePProString( cSection, "lpstrFile", cFileMask, INIFILE )
      endif
   endif

   if cTitle != Nil
      WritePProString( cSection, "lpstrTitle", cTitle, INIFILE )
   endif

   if nDefaultMask != Nil
      WritePProString( cSection, "nFilterIndex", ltrim(Str(nDefaultMask)), INIFILE )
   endif

   if cInitDir != Nil
      WritePProString( cSection, "lpstrInitialDir", cInitDir, INIFILE )
   endif

   if nFlags != Nil
      WritePProString( cSection, "Flags", ltrim(Str(nFlags)), INIFILE )
   endif

   WritePProString( cSection, "hwndOwner", lTrim(Str( GetActiveWindow()) ),;
                    INIFILE )
   if IsWin2000()
     nRet := WinExec( "rundlg32 "+iif( lSave, "2", "1") )
   else
     nRet := 0
   endif
   if nRet > 21 .or. nRet < 0
      StopUntil( {|| GetPvProfString( cSection, "working", "0", INIFILE ) != "1"} )
      /*while GetPvProfString( cSection, "working", "0", INIFILE ) == "1"
         SysRefresh()
      end*/

      cFile        := GetPvProfString( cSection, "lpstrFile", "", INIFILE )
      nFilterIndex := Val(GetPvProfString( cSection, "nFilterIndex", "", INIFILE ))
   else
       cFile := cGetFile(cFileMask, cTitle, nDefaultMask, cInitDir, lSave,, nFlags)
   endif

   Ferase(INIFILE)

return cFile

//----------------------------------------------------------------------------//

Function nGetFilter32()

Return nFilterIndex

//----------------------------------------------------------------------------//

Function cGetDir32(cTitle)

   local cDir
   local nRet

   if File(INIFILE)
      Ferase(INIFILE)
   endif

   if cTitle != Nil
      WritePProString( "GetDirectory", "lpstrTitle", cTitle, INIFILE )
   endif

   WritePProString( "GetDirectory", "hwndOwner", lTrim(Str( GetActiveWindow()) ),;
                    INIFILE )

   nRet := WinExec( "rundlg32 3" )

   if nRet > 21 .or. nRet < 0
      StopUntil( {|| GetPvProfString( "GetDirectory", "working", "0", INIFILE ) != "1"} )
      /*while GetPvProfString( "GetDirectory", "working", "0", INIFILE ) == "1"
         SysRefresh()
      end*/
      cDir := GetPvProfString( "GetDirectory", "lpstrDirectory", "", INIFILE )
   else
      cDir := cGetDir(cTitle)
   endif

   Ferase(INIFILE)

return cDir

//----------------------------------------------------------------------------//

FUNCTION IsWin2000() ; RETURN IsWinNT() .and. GetWinVer()[2] == 95


[quote][/quote]

Posted: Sat Apr 01, 2006 12:27 am
by Mdandrea
You could create it with a temp file name using 8.3 convention, and use the movefile api call to move it to a long file name.

Movefile ( "c:\temp\temp.fil" +chr(0) , "c:\folder\long file name.fil" +chr(0))
DLL32 FUNCTION MOVEFILE( cOldName AS LPSTR, cNewName AS LPSTR ) AS BOOL;
PASCAL FROM "MoveFileA" LIB "kernel32.dll"

Posted: Mon Apr 03, 2006 7:51 am
by Peterg
I have found a tfln on Patrick Mast old pages which works very well. Only needs an extra obj linked in and very simple

Peter