FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to disable msg about empty USB-drives ? (solved)
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
How to disable msg about empty USB-drives ? (solved)
Posted: Fri Jul 29, 2016 01:43 PM
Hello,

on all FWH-samles about drive-informations, there are messages about empty USB-drives.
Is it possible to disable these messages, because selecting 1 of 4 USB-drives,
I get these messages for the 3 unused drives before a dialog opens calliing aDrives().



aDrives()
It returns an array with all the valid drives ids.
Syntax:
aDrives( [<nType>] ) --> aDrives
This function Returns an array with all the units valid of our system.
Parameters:
<nType> 0 = All drives (default), 1 = Floppy drives only, 2 = Hard drives only
Returns:
<aDrives> The array with the drives ids
Sample:
SAMPLES\TESTDRVS.PRG


regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to disable messages about empty USB-drives ?
Posted: Fri Jul 29, 2016 02:49 PM

Please show a compilable and runnable sample of the problem. I think it can be solved.

EMG

Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to disable messages about empty USB-drives ?
Posted: Fri Jul 29, 2016 03:18 PM
Enrico,

just compiled the original sample TESTDRVS.prg

before the dialog opens, I get 4 Messages about empty USB-drives of O, P, Q, R
USB < T > is in use
It happens as soon aDrives() is called :

@ 1, 1 LISTBOX cDrive ITEMS aDrives() SIZE 100, 100 OF oDlg ;
ON DBLCLICK oDlg:End()

Windows 10 installed

The result of TESTDRVS.prg



regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: How to disable messages about empty USB-drives ?
Posted: Fri Jul 29, 2016 03:42 PM

I could not reproduce the problem. How can I get the messages you are talking about?

EMG

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: How to disable messages about empty USB-drives ?
Posted: Fri Jul 29, 2016 04:53 PM
Uwe, this code not is perfect, but .....

Code (fw): Select all Collapse
function Main()

   local oDlg, cDrive
   local aDrives   := {}  //aDrives()
   local i

   // Execute as an administrator
   // Ejecutar como administrador

   for i = Asc( "C" ) to Asc( "Z" )

      if GetDriveType( Chr( i ) + ":\" ) > 1  .and. File( Chr( i ) + ":\NUL" )
         //? Chr( i ) + ":\"
         if Memowrit( Chr( i ) + ":\A1A2A3A4.txt", "Test" )
             FErase( Chr( i ) + ":\A1A2A3A4.txt" )

             // Unidad disponible
             // Drive available

             AADD( aDrives, CHR( i ) + ":" )
         else

             // Dummy condition
             // Unidad no disponible
             // Protegido contra escritura ?
             // Drive not available
             // Drive write protected?

         endif
      endif
   Next i

   DEFINE DIALOG oDlg FROM 5, 5 TO 20, 60 TITLE "Select a drive"

   @ 1, 1 LISTBOX cDrive ITEMS aDrives SIZE 100, 100 OF oDlg ;
      ON DBLCLICK oDlg:End()

   @ 1, 20 BUTTON "&Ok" OF oDlg ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED
Cristobal Navarro

Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo

El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to disable messages about empty USB-drives ?
Posted: Fri Jul 29, 2016 05:24 PM
Cristobal,
thank You very much

it seems all USB-ports are checked calling aDrives()
If the USB is empty, a message is shown < please insert a data-medium >.
Maybe there is somethig like a < autocheck > for USB inside the system-settings ( I don't know )
I'm wondering <A:\> and the <DVD-burner> is empty as well, but NO message.

The message is shown also 4 times, before the MsgAlert is executed.

function Test()
local aDrives := aDrives()

MsgAlert( len(aDrives) )

return( nil )

------------------------

That works ( drive-selection with included USB ) NO messages !!!

AEval( GetLogicalDriveStrings(), { | c | MsgInfo( c ) } )

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 99
Joined: Thu Aug 02, 2012 03:21 PM
Re: How to disable messages about empty USB-drives ?
Posted: Fri Jul 29, 2016 05:54 PM
ukoenig wrote:Cristobal,
thank You very much

it seems all USB-ports are checked calling aDrives()
If the USB is empty, a message is shown < please insert a data-medium >.
Maybe there is somethig like a < autocheck > for USB inside the system-settings ( I don't know )
I'm wondering <A:\> and the <DVD-burner> is empty as well but NO message.

The message is shown also 4 times, before the MsgAlert is executed.

function Test()
local aDrives := aDrives()

MsgAlert( len(aDrives) )

return( nil )

------------------------

That works ( drive-selection with included USB ) NO messages !!!

AEval( GetLogicalDriveStrings(), { | c | MsgInfo( c ) } )

regards
Uwe :-)


Uwe, this code work's for me
Code (fw): Select all Collapse
   
FUNC Main()
        LOCAL nError := SetErrorMode(1)
        aDrives  := GetALLDrives()  // All disks
        SetErrorMode( nError)
        Xbrowse( aDrives )
RETU
//------------------------------------//
FUNC GetALLDrives( nType )
     LOCAL aDrives := {}
     LOCAL nBitDrives := GetLogicalDrives(), n, cDrive

     FOR n = 1 to 32
         IF lAnd( nBitDrives, 2 ^ ( n - 1 ) )
            cDrive = Chr( Asc( "A" ) - 1 + n ) + ":\"
            IF Empty( nType )
               IF n != 1 .and. Empty( nType ) //.and. GetDriveType( cDrive ) == 2
                  AAdd( aDrives, cDrive )
               ENDIF
            ELSE
               IF n !=1 .and. GetDriveType( cDrive ) = nType
                  AAdd( aDrives, cDrive )
               ENDIF
            ENDIF
         ENDIF
     NEXT
RETU aDrives
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20141106)

FiveWin Version: FWHX 15.01

BCC 5.8.2
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to disable messages about empty USB-drives ?
Posted: Fri Jul 29, 2016 06:15 PM

Hebert,
thank You very much

that WORKS
NO messages !!

regards
Uwe :D

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to disable msg about empty USB-drives ? (solved)
Posted: Mon Aug 01, 2016 03:45 PM
Hello,

I finished the one-click BACKUP-section and noticed the following :



Only connected USB-ports are visible. That is OK
But why a harddisk connected to the USB-port < T > changes the type to < 3 >.
I changed the harddisk against a USB-stick and get < 2 >
It seems the return-value is the connected medium and not the port-value.

regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 99
Joined: Thu Aug 02, 2012 03:21 PM
Re: How to disable msg about empty USB-drives ? (solved)
Posted: Wed Aug 03, 2016 12:27 PM
ukoenig wrote:Hello,

I finished the one-click BACKUP-section and noticed the following :



Only connected USB-ports are visible. That is OK
But why a harddisk connected to the USB-port < T > changes the type to < 3 >.
I changed the harddisk against a USB-stick and get < 2 >
It seems the return-value is the connected medium and not the port-value.

regards
Uwe :-)


Uwe, you're right function give you media type, not port value. :-)
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20141106)

FiveWin Version: FWHX 15.01

BCC 5.8.2

Continue the discussion