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

Limit of SHELLFILEOPERATION ?

Post by AUGE_OHR »

hi,

i use SHELLFILEOPERATION in HBFM to Copy/Move/Delete Files/Folder and it work fine
now i use same Code for "Backup" and it work with "some Files" but fail when have 30000 :o

is there a Limit of SHELLFILEOPERATION :?:

---

i got FullPathNameW from "Everything" and store it in Array
i pass Array to Function ShellFiles() which made a "large String" ( LIMIT :?: )

Code is from c:\MiniGUI\SOURCE\shell32\Shell32.prg

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 CHR( 0 )
   IF VALTYPE( acFiles ) == "A"
      cTemp := ""
      FOR cx := 1 TO LEN( acFiles )
         cTemp += acFiles[ cx ] + CHR( 0 )
      NEXT
      ccFiles := cTemp
   ENDIF
   ccFiles += CHR( 0 )

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

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

RETURN lRet
---

Code: Select all

#pragma BEGINDUMP

#include <windows.h>
#include "hbapi.h"

HB_FUNC ( SHELLFILEOPERATION )
{
   SHFILEOPSTRUCT sh;

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

   hb_retnl( SHFileOperation (&sh) );
}

#pragma ENDDUMP
have fun
Jimmy
User avatar
gfilatov
Posts: 1116
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Limit of SHELLFILEOPERATION ?

Post by gfilatov »

AUGE_OHR wrote: Fri Jul 02, 2021 7:08 am hi,
...
Code is from c:\MiniGUI\SOURCE\shell32\Shell32.prg
Hi Jimmy,

Please note that the above C-code was NOT updated for the UNICODE charset which you are used.

:o
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
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 »

gfilatov wrote: Fri Jul 02, 2021 7:32 am Please note that the above C-code was NOT updated for the UNICODE charset which you are used.
do you mean this

Code: Select all

#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
it does produce same Problem ...
have fun
Jimmy
User avatar
gfilatov
Posts: 1116
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Limit of SHELLFILEOPERATION ?

Post by gfilatov »

AUGE_OHR wrote: Fri Jul 02, 2021 5:58 pm
gfilatov wrote: Fri Jul 02, 2021 7:32 am Please note that the above C-code was NOT updated for the UNICODE charset which you are used.
do you mean this

Code: Select all

#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
it does produce same Problem ...
No.
I means

Code: Select all

#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  = hb_parnl(4);
   sh.fFlags = hb_parnl(5);
   sh.hNameMappings = 0;
   sh.lpszProgressTitle = NULL;

   hb_retnl( SHFileOperation (&sh) );
}
#pragma ENDDUMP
:idea:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
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 »

gfilatov wrote: Fri Jul 02, 2021 6:14 pm No.
I means
i have take your Code and it make same Problem : SHELLFILEOPERATION does open but close after < 1 Sec :(
---
i can "copy" hole Directory with > 10000 Files but it seems i can´t "copy" 10000 "single Files"
i got those Files with "A" Attribute from "fresh" installed C:\HMG35

it work when have less File ... not sure how much.
i will try to make a Sample (without "Everything" )
have fun
Jimmy
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,

found out that it have to do with OS Error 2 when run SHELLFILEOPERATION
2 ERROR_FILE_NOT_FOUND The system cannot find the file specified.
this is when Filename have "German Umlaut" like "Verknüpfung" ( = Shortcut )
hb_ShellOP_Umlaut.jpg
hb_ShellOP_Umlaut.jpg (28.85 KiB) Viewed 1638 times
hm ... i can "copy" these Files in HBFM ... and it is the "same" Code

...

my Xbase++ Version use ANSI and, as i know, SHELLFILEOPERATION will use "A" or "W" depend on "shellapi.h"
how can i be sure to use "W" Version under HMG

Code: Select all

LOCAL nCountry := HB_bitAND( GETKEYBOARDLAYOUT(), 0xFFFF )

   SET EPOCH TO YEAR( DATE() ) - 50
   SET CENTURY ON

   IF nCountry = 1031
      SET LANGUAGE TO GERMAN
      //    SET CODEPAGE TO GERMAN
      SET DATE GERMAN
   ELSE
      SET LANGUAGE TO ENGLISH
      //    SET CODEPAGE TO ENGLISH
      SET DATE AMERICAN
   ENDIF
   // use UTF8 -> "W" instead of "A" API Function
   SET( _SET_CODEPAGE, "UTF8" )
have fun
Jimmy
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,

i got it run under 32 Bit ... but i´m confused

now i use

Code: Select all

   IF nCountry = 1031
      SET LANGUAGE TO GERMAN
      SET CODEPAGE TO GERMAN
      SET DATE GERMAN
   ELSE
      SET LANGUAGE TO ENGLISH
      SET CODEPAGE TO ENGLISH
      SET DATE AMERICAN
   ENDIF
   // use UTF8 -> "W" instead of "A" API Function
   // SET( _SET_CODEPAGE, "UTF8" )
in my UNICODE IDE and tell "Everything" to use "A" API Function
Result is send to ShellFileOperation() and it work :)

---

i did same with DIRECTORY() and it also work fine

so i can use "A" API Function in UNICIDE-IDE, or is it only for Shell Function :?:
have fun
Jimmy
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,

new Problem ... :cry:

32 Bit App Version work fine, also on 64 Bit OS
64 Bit App Version "seems" to work ...

but ShellFileOperation() fail with "big" Number of Files
MAX_PATH.jpg
MAX_PATH.jpg (13.93 KiB) Viewed 1560 times
DE_ERROR_MAX 0xB7 MAX_PATH was exceeded during the operation.
what does this Message mean :idea:

---

i do try to "test" LEN() of Filename before

Code: Select all

      IF LEN( cPath + cFile ) > 255
         System.Clipboard := cPath + cFile
         MsgInfo( "Filename > 255 (Filename was copy to Clipboard)", "Error MAX_PATH" )
         LOOP
      ENDIF
but i did not get into that Code ... but later got MAX_PATH exceeded :(
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 »

AUGE_OHR wrote: Fri Jul 02, 2021 5:58 pm
gfilatov wrote: Fri Jul 02, 2021 7:32 am Please note that the above C-code was NOT updated for the UNICODE charset which you are used.
do you mean this

Code: Select all

#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
it does produce same Problem ...
Hi,
In Unicode try change CHR( 0 ) for HB_UCHR( 0 )
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,
srvet_claudio wrote: Sun Jul 04, 2021 10:54 pm In Unicode try change CHR( 0 ) for HB_UCHR( 0 )
THX for Answer
what do i have to include for HB_UCHR( 0 ) :?:
R:/Temp/hbmk_c45pjh.dir/SHELLOP.o:SHELLOP.c:(.data+0x1c8): undefined reference to `HB_FUN_HB_UCHR'
collect2.exe: error: ld returned 1 exit status
have fun
Jimmy
Post Reply