API SHFileOperation() in 64 Bit App

323 views
Skip to first unread message

Auge & Ohr

unread,
Jul 4, 2021, 2:51:12 PM7/4/21
to Harbour Users
hi,

i use API SHFileOperation() to "backup" Files from HDD/SSD to USB-Stick.

i have to use CODEPAGE and "A"nsi API Function else i got Problem with German "Umlaute"
now this work fine as 32 Bit App and it "seems" to work in 64 Bit App ...

64 Bit App does work ... but if have a "big" Number of Files i got

DE_ERROR_MAX     0xB7     MAX_PATH was exceeded during the operation.

! Note : 32 Bit App does work on same big" Number of Files

so what does Error mean ? how to fix it ?

greetings Jimmy

used Structure


HB_FUNC ( SHELLFILEOPERATION )
{
   SHFILEOPSTRUCT sh;
   ZeroMemory (&sh, sizeof(SHFILEOPSTRUCT));

   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) );
}


Klas Engwall

unread,
Jul 5, 2021, 3:04:50 PM7/5/21
to harbou...@googlegroups.com
Hi Jimmy,
That looks like a HMG question rather than a "plain Harbour" question,
right? Anyway, there is a path size limit in Windows, and a MAX_PATH
error is returned for combinations of path and file name that exceed
that limit. It is described in various places on the web, for example:

https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd

You can search for MAX_PATH for additional results

As far as I can see from those docs the number of files is irrelevant as
long as the path + file name of each file does not break the MAX_PATH limit.

Regards,
Klas

Auge & Ohr

unread,
Jul 6, 2021, 9:55:11 PM7/6/21
to Harbour Users
hi Klas,

thx for Answer
i have solved Problem with 64 Bit App ...
i had to enhance Parameter Type for 64 Bit SHFileOperation :)

so i had to change harbour
   hb_parnl( 1 );
   hb_***

into HMG
  HMG_parnl( 1 );
  HMG_***
and use Unicode Version

---

#include "HMG_UNICODE.h"

#include <hbapi.h>
#include <Windows.h>
#include <ShellApi.h>
#include <ShlObj.h>


HB_FUNC ( SHELLFILEOPERATION )
{
   SHFILEOPSTRUCT sh;
   ZeroMemory (&sh, sizeof(SHFILEOPSTRUCT));

   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;

   hb_retnl( SHFileOperation (&sh) );
}

now this HMG Code work for both Version 32 / 64 Bit

Jimmy
Reply all
Reply to author
Forward
0 new messages