Limit of SHELLFILEOPERATION ?

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Limit of SHELLFILEOPERATION ?

Post by AUGE_OHR »

hi,

instead of HB_UCHR() i have found HB_UCHAR() where i need to
SET( _SET_CODEPAGE, "UTF8" )
but now i got back Problem with Filename from DIRECTORY() while SHFileOperation() return 2 ( files not found )

... and on my "big" Sample i got
DE_ERROR_MAX 0xB7 MAX_PATH was exceeded during the operation.
which my 32 Bit App now :(
have fun
Jimmy
User avatar
srvet_claudio
Posts: 2224
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Limit of SHELLFILEOPERATION ?

Post by srvet_claudio »

Hi,
try this code.
Note: call ShellFiles function

Code: Select all

FUNCTION ShellFiles( hWnd, acFiles, acTarget, nFunc, fFlag )
LOCAL cTemp
LOCAL cx
LOCAL lRet := .F.
LOCAL ccFiles, ccTarget

   // Parent Window
   IF EMPTY( hWnd )
      hWnd := GetActiveWindow()
   ENDIF

   // Operation Flag
   IF nFunc == NIL
      nFunc := FO_DELETE
   ENDIF

   // Options Flag
   IF fFlag == NIL
      fFlag := FOF_ALLOWUNDO
   ENDIF

   // SourceFiles, convert Array to String
   DEFAULT acFiles TO HB_UCHAR( 0 )
   IF VALTYPE( acFiles ) == "A"
      cTemp := ""
      FOR cx := 1 TO LEN( acFiles )
         cTemp += acFiles[ cx ] + HB_UCHAR( 0 )
      NEXT
      ccFiles := cTemp
   ENDIF
   ccFiles += HB_UCHAR( 0 )

   // TargetFiles, convert Array to String
   DEFAULT acTarget TO HB_UCHAR( 0 )
   IF VALTYPE( acTarget ) == "A"
      cTemp := ""
      FOR cx := 1 TO LEN( acTarget )
         cTemp += acTarget[ cx ] + HB_UCHAR( 0 )
      NEXT
      ccTarget := cTemp
   ENDIF
   ccTarget += HB_UCHAR( 0 )

   // now call SHFileOperation
   lRet := ShellFileOperation( hWnd, ccFiles, ccTarget, nFunc, fFlag )

RETURN lRet


#pragma BEGINDUMP
#include "HMG_UNICODE.h"
#include <windows.h>
#include "hbapi.h"

HB_FUNC ( SHELLFILEOPERATION )
{
   SHFILEOPSTRUCT sh;

   sh.hwnd   = ( HWND ) HMG_parnl( 1 );
   sh.pFrom  = HMG_parc(2);
   sh.pTo    = HMG_parc(3);
   sh.wFunc  = HMG_parnl(4);
   sh.fFlags = HMG_parnl(5);
   sh.hNameMappings = 0;
   sh.lpszProgressTitle = NULL;

   HMG_retnl( SHFileOperation (&sh) );
}
#pragma ENDDUMP
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
AUGE_OHR
Posts: 2117
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: Limit of SHELLFILEOPERATION ?

Post by AUGE_OHR »

hi,

YES !
now 64 Bit App work :)

---

there is a small Problem with DIRECTORY() which seems to need CODEPAGE <> UTF-8
when use UTF-8 i got Problem with German "Umlaute" :(
it will transfer to ShFileOperation but say "file not found"
UMLAUTE.ZIP
(44.64 KiB) Downloaded 63 times
so i have to use CODEPAGE German with DIRECTORY() and SET UTF8 before call ShFileOperation.

p.s. Unicode is much faster when use right.
instead of 250 Sec. with ANSI Version it need 71 Sec. in Unicode
if use wrong Unicode Code it increase to > 500 Sec
have fun
Jimmy
Post Reply