Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #7224

How setting enumerator in cavo code

From <jean_ray67@hotmail.com>
Newsgroups comp.lang.clipper.visual-objects
Subject How setting enumerator in cavo code
Date 2014-09-21 11:13 -0400
Organization A noiseless patient Spider
Message-ID <lvmpum$7fr$1@dont-email.me> (permalink)

Show all headers | View raw


Hello all..
/-----------------------------------------------------
Since sandisk have decided to manufacture there USB stick as HDD drive ( win
8 compliance)
ref:
http://answers.microsoft.com/en-us/windows/forum/windows_8-hardware/usb-detected-as-a-hdd-and-not-as-a-removable/2b765c19-6460-4fe6-a200-9a1238c77310

see
PEROUX François replied on aug 7, 2013
/--------------------------------------------------------------------------
I want to force my user to use USB stick or USB drive

I made a function, which give me if the drive is removable, even if this
drive is set as HDD by the manufacturer
see function isMediaUSB() below:

My problem is how to set an enumerator into a structure

In WinAPI they say:
typedef enum _STORAGE_BUS_TYPE {
  BusTypeUnknown      = 0x00,
  BusTypeScsi         = 0x01,
  BusTypeAtapi        = 0x02,
  BusTypeAta          = 0x03,
  BusType1394         = 0x04,
  BusTypeSsa          = 0x05,
  BusTypeFibre        = 0x06,
  BusTypeUsb          = 0x07,
  BusTypeRAID         = 0x08,
  BusTypeiSCSI        = 0x09,
  BusTypeSas          = 0x0A,
  BusTypeSata         = 0x0B,
  BusTypeMaxReserved  = 0x7F
} STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;

/-----------------------------------------------------------------------
I made it as structure, the removable value is true (good value), but I
cannot get the [  BusTypeUsb        = 0x07,]

Any help will be greathly appreciated

Thank in advance

Jean Raymond
rayonline.com



STRUCT  WIN_STORAGE_DEVICE_DESCRIPTOR
MEMBER  Version AS DWORD
MEMBER Size  AS DWORD
MEMBER DeviceType AS BYTE
MEMBER DeviceTypeModifier AS BYTE
MEMBER  RemovableMedia  AS LOGIC
MEMBER CommandQueueing AS LOGIC
MEMBER VendorIdOffset AS DWORD
MEMBER ProductIdOffset AS DWORD
MEMBER ProductRevisionOffset AS DWORD
MEMBER SerialNumberOffset AS DWORD
MEMBER BusType     IS  WIN_STORAGE_BUS_TYPE  //the problem is here, it is an
enumeration
MEMBER RawPropertiesLength AS DWORD
MEMBER DIM RawDeviceProperties[1024] AS BYTE
/-------------------------------------------------------------------------------------------------
STRUCT   WIN_STORAGE_PROPERTY_QUERY
MEMBER PropertyId AS DWORD
MEMBER QueryType AS DWORD
MEMBER  DIM  AdditionalParameters[10] AS BYTE

/------------------------------------------------------------------------------------------------------

STRUCT WIN_STORAGE_BUS_TYPE
MEMBER  BusTypeUnknown AS BYTE
MEMBER  BusTypeScsi AS BYTE
MEMBER  BusTypeAtapi AS BYTE
MEMBER  BusTypeAta AS BYTE
MEMBER  BusType1394 AS BYTE
MEMBER  BusTypeSsa AS BYTE
MEMBER  BusTypeFibre AS BYTE
MEMBER  BusTypeUsb AS BYTE
MEMBER  BusTypeRAID AS BYTE
MEMBER  BusTypeiScsi AS BYTE
MEMBER  BusTypeSas AS BYTE
MEMBER  BusTypeSata AS BYTE
MEMBER  BusTypeSd AS BYTE
MEMBER  BusTypeMmc AS BYTE
MEMBER  BusTypeVirtual AS BYTE
MEMBER  BusTypeFileBackedVirtual AS BYTE
MEMBER  BusTypeMax AS BYTE
MEMBER  BusTypeMaxReserved AS BYTE

/------------------------------------------------------------------------

FUNCTION isMediaUSB( cDrive AS STRING ) AS LOGIC PASCAL

        LOCAL  ptrDriveHandle AS PTR
      LOCAL hp IS   WIN_STORAGE_DEVICE_DESCRIPTOR
      LOCAL  lOK , lRemovable AS LOGIC
      LOCAL  nSend ,rlen AS DWORD  , nSize AS DWORD
      LOCAL hQ IS Win_STORAGE_PROPERTY_QUERY

       /*  NOTES:
        values of all ioctl defines
              REF:     http://www.ioctls.net/
               IOCTL_STORAGE_QUERY_PROPERTY =  0x2d1400
          */

      hp.Size:= _SIZEOF(WIN_STORAGE_DEVICE_DESCRIPTOR)
      hQ.PropertyId:=0
      hQ.QueryType:=0
      nSize:= _SIZEOF(WIN_STORAGE_PROPERTY_QUERY)
      nSend:= 0x2d1400   //IOCTL_STORAGE_QUERY_PROPERTY =  0x2d1400
      //Format('\\.\%s:', [ADriveLetter])
      ptrDriveHandle:=  CreateFile(String2Psz("\\.\"+cDrive+":"),
DWORD(_CAST,GENERIC_READ), _OR(FILE_SHARE_WRITE,FILE_SHARE_READ),  NULL,
OPEN_EXISTING, 0, 0)
      IF ptrDriveHandle == NULL_PTR .OR.  ptrDriveHandle == F_ERROR
            WinErrMsg("",GetLastError())
      ENDIF
      lOK:= DeviceIoControl(ptrDriveHandle, nSend, @hQ,nSize, @hp,
hp.Size, @rlen, NULL)
      lRemovable:=hp.RemovableMedia
      CloseHandle(ptrDriveHandle)

       RETURN lRemovable

/-----------------------------------------------------------------

FUNCTION WinErrMsg(cTemp AS STRING, dwError AS DWORD) AS VOID PASCAL
    LOCAL sError AS PSZ

~"ONLYEARLY+"

    sError:=StringAlloc(Space(255))

    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL_PTR, dwError, ;
            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), sError, 255,
NULL_PTR)
    MessageBox(0, String2Psz(cTemp+". "+Psz2String(sError)),
String2Psz("Error # "+NTrim(dwError)),;
                        MB_ICONERROR)

    MemFree(sError)

    RETURN

~"ONLYEARLY-"

/--------------------------------------------------------  

Back to comp.lang.clipper.visual-objects | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

How setting enumerator in cavo code <jean_ray67@hotmail.com> - 2014-09-21 11:13 -0400
  Re: How setting enumerator in cavo code "Uwe Heyer" <uwe.heyer@aristik.de> - 2014-09-21 23:49 +0000
    Re: How setting enumerator in cavo code "Uwe Heyer" <uwe.heyer@aristik.de> - 2014-09-22 00:18 +0000
    Re: How setting enumerator in cavo code <jean_ray67@hotmail.com> - 2014-09-21 23:52 -0400
      Re: How setting enumerator in cavo code "Uwe Heyer" <uwe.heyer@aristik.de> - 2014-09-22 15:32 +0000
  Re: How setting enumerator in cavo code Malcolm G <malcolm-news2012delete@delete.jobstream.com> - 2014-09-22 10:19 +0100

csiph-web