Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #7224 > unrolled thread
| Started by | <jean_ray67@hotmail.com> |
|---|---|
| First post | 2014-09-21 11:13 -0400 |
| Last post | 2014-09-22 10:19 +0100 |
| Articles | 6 — 3 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
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
| From | <jean_ray67@hotmail.com> |
|---|---|
| Date | 2014-09-21 11:13 -0400 |
| Subject | How setting enumerator in cavo code |
| Message-ID | <lvmpum$7fr$1@dont-email.me> |
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-"
/--------------------------------------------------------
[toc] | [next] | [standalone]
| From | "Uwe Heyer" <uwe.heyer@aristik.de> |
|---|---|
| Date | 2014-09-21 23:49 +0000 |
| Message-ID | <c896g6F41apU1@mid.individual.net> |
| In reply to | #7224 |
> My problem is how to set an enumerator into a structure
>
> In WinAPI they say:
> typedef enum _STORAGE_BUS_TYPE {
Hi Jean,
an enum isn't a structure. It is an integer for VO.
This INT can hold one and only one value of the underlying members.
(see it like a UNION of INT's)
e.g.
typeded enum WEEK
{
Sunday = 1, // assigned first value, or zero if nothing assigned
Monday, // +1
other days, // +1, or new value assigned
Saturday // +1 == 7
}
For one another language you can code something like
WEEK day;
day can hold the enum value from 1 to 7, nothing more
day = GetDayOfWeek(Date()); // return enum 2
if ( day == Monday )
doThis();
VO Code
day = GetDayOfWeek(Date()); // return 2
if day = 2
doThis()
endif
Ahoj
-Uwe
[toc] | [prev] | [next] | [standalone]
| From | "Uwe Heyer" <uwe.heyer@aristik.de> |
|---|---|
| Date | 2014-09-22 00:18 +0000 |
| Message-ID | <c8986aF4cspU1@mid.individual.net> |
| In reply to | #7225 |
Uwe Heyer wrote: > typeded enum WEEK sorry, read it as typedef enum WEEK my gamer pc is more usefull for joysticks, rudder, mouse, gamepads and TrackIR. Keyboard is only for logon... No training for using it ;-) --
[toc] | [prev] | [next] | [standalone]
| From | <jean_ray67@hotmail.com> |
|---|---|
| Date | 2014-09-21 23:52 -0400 |
| Message-ID | <lvo6dm$98n$1@dont-email.me> |
| In reply to | #7225 |
Uwe Heyer
Thank for your answer...
The problem is if I put the member [BusType] as int, it returns = 302350336
(0x12058000)
If I put it as dword, it returns also = 302350336 (0x12058000)
if I put it as shortint, it return = -32768 (0xFFFF8000)
if I put it as word, it return = 32768 (0x8000)
If i put it as BYTE , it returns = 0 (0x00)
The return value should be... [ BusTypeUsb = 0x7,]
What the hell i am doing wrong?
Jean Raymond
rayonline.com
//////
"Uwe Heyer" wrote in message news:c896g6F41apU1@mid.individual.net...
> My problem is how to set an enumerator into a structure
>
> In WinAPI they say:
> typedef enum _STORAGE_BUS_TYPE {
Hi Jean,
an enum isn't a structure. It is an integer for VO.
This INT can hold one and only one value of the underlying members.
(see it like a UNION of INT's)
e.g.
typeded enum WEEK
{
Sunday = 1, // assigned first value, or zero if nothing assigned
Monday, // +1
other days, // +1, or new value assigned
Saturday // +1 == 7
}
For one another language you can code something like
WEEK day;
day can hold the enum value from 1 to 7, nothing more
day = GetDayOfWeek(Date()); // return enum 2
if ( day == Monday )
doThis();
VO Code
day = GetDayOfWeek(Date()); // return 2
if day = 2
doThis()
endif
Ahoj
-Uwe
[toc] | [prev] | [next] | [standalone]
| From | "Uwe Heyer" <uwe.heyer@aristik.de> |
|---|---|
| Date | 2014-09-22 15:32 +0000 |
| Message-ID | <c8atnmFhfb8U1@mid.individual.net> |
| In reply to | #7227 |
second look (I can't try your code) you should align api structures to 1 STRUCT WIN_STORAGE_DEVICE_DESCRIPTOR -> ALIGN 1 <- MEMBER Version AS DWORD MEMBER Size AS DWORD MEMBER DeviceType AS BYTE MEMBER DeviceTypeModifier AS BYTE MEMBER RemovableMedia AS LOGIC -> BOOLEAN == BYTE <- MEMBER CommandQueueing AS LOGIC -> see above <- MEMBER VendorIdOffset AS DWORD MEMBER ProductIdOffset AS DWORD MEMBER ProductRevisionOffset AS DWORD MEMBER SerialNumberOffset AS DWORD MEMBER BusType -> enum == VO INT <- MEMBER RawPropertiesLength AS DWORD -> set this to 1 <- MEMBER DIM RawDeviceProperties[1024] AS BYTE -> [1] AS BYTE <- sizeof(above struc) should give you 40 (allign 1 == 37 + struct is bound on multiple of 4 == 40) Ahoj -Uwe
[toc] | [prev] | [next] | [standalone]
| From | Malcolm G <malcolm-news2012delete@delete.jobstream.com> |
|---|---|
| Date | 2014-09-22 10:19 +0100 |
| Message-ID | <oQRTv.563649$7b1.540809@fx01.am4> |
| In reply to | #7224 |
On 21/09/2014 16:13, jean_ray67@hotmail.com wrote: > 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 You are saying your problem with the enum - are you sure all the other items are right? (I know in the SDK many of the structures use the format STRUCT _WinPhoneCaps ALIGN 1 and I thought that was a choice you had to make based on the packing rules used - byt I would expect items like VendorIdOffset to already be going wrong if the alignment was wrong.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web