FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour HB_FUNC Error using FWh24.07 and BCC77 0/64
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
HB_FUNC Error using FWh24.07 and BCC77 0/64
Posted: Tue Sep 10, 2024 07:09 PM
hi,
i got some Error in my HB:func when using FWH24.07 an BCC77 0/64
Warning W8004 HB_FUNC.PRG 132: 'fAutoEject' is assigned a value that is never used in function EjectVolume
Warning W8004 HB_FUNC.PRG 132: 'fRemoveSafely' is assigned a value that is never used in function EjectVolume

Warning W8075 HB_FUNC.PRG 136: Suspicious pointer conversion in function HB_FUN_EJECTREMOVABLE
*** 1 errors in Compile ***
Code (fw): Select all Collapse
OOL EjectVolume( TCHAR cDriveLetter )
{
   HANDLE hVolume;
   BOOL fRemoveSafely ; //  = FALSE;
   BOOL fAutoEject    ; //  = FALSE;

   hVolume = OpenVolume(cDriveLetter);
   if( hVolume == INVALID_HANDLE_VALUE )
     return FALSE;

   if( LockVolume(hVolume) && DismountVolume(hVolume) )
     fRemoveSafely = TRUE;
   {
     if (PreventRemovalOfVolume(hVolume, FALSE) && AutoEjectVolume(hVolume))
           fAutoEject = TRUE;
   }

   if( ! CloseVolume(hVolume) )
     return FALSE;

   return TRUE;
}
Code (fw): Select all Collapse
HB_FUNC( EJECTREMOVABLE )
{
   char * szDrive = hb_parc( 1 );
   hb_retl( EjectVolume( ( TCHAR ) *szDrive ) );
   return;
}
what is wrong :?:

it have be working before with 23.07 and BCC7
need some help please
greeting,

Jimmy
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: HB_FUNC Error using FWh24.07 and BCC77 0/64
Posted: Wed Sep 11, 2024 03:08 AM
Dear Jimmy,

Try it this way:
Code (fw): Select all Collapse
#include <tchar.h>
#include <windows.h>

HB_FUNC( EJECTREMOVABLE )
{
    const char* szDrive = hb_parc(1);
    TCHAR tszDrive[3] = TEXT("\0\0");

    if (szDrive && szDrive[0] != '\0')
    {
        #ifdef UNICODE
            MultiByteToWideChar(CP_ACP, 0, szDrive, 1, tszDrive, 1);
        #else
            tszDrive[0] = szDrive[0];
        #endif
        tszDrive[1] = TEXT(':');
    }

    hb_retl(EjectVolume(tszDrive));
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: HB_FUNC Error using FWh24.07 and BCC77 0/64
Posted: Wed Sep 11, 2024 04:15 AM
hi Antonio,

THX for Answer.
Warning W8004 HB_FUNC.PRG 132: 'fAutoEject' is assigned a value that is never used in function EjectVolume
Warning W8004 HB_FUNC.PRG 132: 'fRemoveSafely' is assigned a value that is never used in function EjectVolume

Error E2342 HB_FUNC.PRG 152: Type mismatch in parameter 'cDriveLetter' (wanted 'signed char', got 'signed char *')
in function HB_FUN_EJECTREMOVABLE
*** 1 errors in Compile ***
hbmk2[test32]: Error: Running C/C++ compiler. 2
Code (fw): Select all Collapse
111 BOOL EjectVolume( TCHAR cDriveLetter )
112 {
113  HANDLE hVolume;
114   BOOL fRemoveSafely ; //  = FALSE;
115   BOOL fAutoEject    ; //  = FALSE;
116
117  hVolume = OpenVolume(cDriveLetter);
118   if( hVolume == INVALID_HANDLE_VALUE )
119     return FALSE;
120
121   if( LockVolume(hVolume) && DismountVolume(hVolume) )
122     fRemoveSafely = TRUE;
123   {
124     if (PreventRemovalOfVolume(hVolume, FALSE) && AutoEjectVolume(hVolume))
125          fAutoEject = TRUE;
126   }
127
128   if( ! CloseVolume(hVolume) )
129     return FALSE;
130
131  return TRUE;
132}
there is NO cDriveLetter in line 152, it is in line 111 and 117
Code (fw): Select all Collapse
152    hb_retl(EjectVolume(tszDrive));
153        }
greeting,

Jimmy
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: HB_FUNC Error using FWh24.07 and BCC77 0/64
Posted: Wed Sep 11, 2024 06:47 AM

Please modify this line:

BOOL EjectVolume( TCHAR cDriveLetter )

this way:

BOOL EjectVolume( TCHAR * cDriveLetter )

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion