I’m working with the NetShareEnum function in the Windows API. It can return the SHARE_INFO_2 structure. That structure contains the shi2_type member, which is defined as “a bitmask of flags that specify the type of the shared resource”. The values of the bitmask are defined in LMSHare.h
#define STYPE_DISKTREE 0 // Disk drive.
#define STYPE_PRINTQ 1 // Print queue.
#define STYPE_DEVICE 2 // Communication device.
#define STYPE_IPC 3 // Interprocess communication (IPC).
I don’t know how to interpret STYPE_DISKTREE. Since it is a bitmask of zero, I can’t use a bitwise AND on the mask and compare it against the mask to see if it is set. That is,
(shi2_type & STYPE_DISKTREE) == STYPE_DISKTREE
is always true. Is this intended to mean that all shares are inherently disk shares? Or, should I make this a special case and use the following comparison to check if the share is a disk share,
shi2_type == STYPE_DISKTREE
which is to say that a disk share is exclusively a disk share and nothing else.
From the documentation:
So the low part of shi2_type will be one of DISKTREE, PRINTQ, DEVICE, or IPC and the high part may contain SPECIAL and/or TEMPORARY. Sadly the documentation is not explicit about the size of the parts, but since there’s only 4 types you can just take the low byte. You could also just drop the high byte as that is where the 2 flags are defined.