HB_FUNC Error using FWh24.07 and BCC77 0/64

HB_FUNC Error using FWh24.07 and BCC77 0/64

Postby Jimmy » Tue Sep 10, 2024 7: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: Select all  Expand view
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: Select all  Expand view
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
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: HB_FUNC Error using FWh24.07 and BCC77 0/64

Postby Antonio Linares » Wed Sep 11, 2024 3:08 am

Dear Jimmy,

Try it this way:
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: HB_FUNC Error using FWh24.07 and BCC77 0/64

Postby Jimmy » Wed Sep 11, 2024 4: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: Select all  Expand view
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: Select all  Expand view
152    hb_retl(EjectVolume(tszDrive));
153        }
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: HB_FUNC Error using FWh24.07 and BCC77 0/64

Postby Antonio Linares » Wed Sep 11, 2024 6:47 am

Please modify this line:

BOOL EjectVolume( TCHAR cDriveLetter )

this way:

BOOL EjectVolume( TCHAR * cDriveLetter )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 60 guests