How to disable msg about empty USB-drives ? (solved)

Post Reply
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

How to disable msg about empty USB-drives ? (solved)

Post by ukoenig »

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().

Image

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 :?:
Last edited by ukoenig on Fri Jul 29, 2016 8:15 pm, edited 2 times in total.
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.
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: How to disable messages about empty USB-drives ?

Post by ukoenig »

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

Image

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.
User avatar
cnavarro
Posts: 5792
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: How to disable messages about empty USB-drives ?

Post by cnavarro »

Uwe, this code not is perfect, but .....

Code: Select all


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

C. Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
Si alguien te dice que algo no se puede hacer, recuerda que esta hablando de sus limitaciones, no de las tuyas.
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: How to disable messages about empty USB-drives ?

Post by ukoenig »

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 :roll:
Last edited by ukoenig on Fri Jul 29, 2016 8:16 pm, edited 1 time in total.
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.
User avatar
hebert_j_vargas
Posts: 94
Joined: Thu Aug 02, 2012 3:21 pm

Re: How to disable messages about empty USB-drives ?

Post by hebert_j_vargas »

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 :roll:
Uwe, this code work's for me

Code: Select all

   
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
Last edited by hebert_j_vargas on Fri Jul 29, 2016 6:54 pm, edited 1 time in total.
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20141106)
FiveWin Version: FWHX 15.01
BCC 5.8.2
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: How to disable messages about empty USB-drives ?

Post by ukoenig »

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.
User avatar
ukoenig
Posts: 3981
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany
Contact:

Re: How to disable msg about empty USB-drives ? (solved)

Post by ukoenig »

Hello,

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

Image

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.
User avatar
hebert_j_vargas
Posts: 94
Joined: Thu Aug 02, 2012 3:21 pm

Re: How to disable msg about empty USB-drives ? (solved)

Post by hebert_j_vargas »

ukoenig wrote:Hello,

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

Image

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. :wink:
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20141106)
FiveWin Version: FWHX 15.01
BCC 5.8.2
Post Reply