//+-------------------------------------------------------------------------
//
//  Microsoft Windows
//  Copyright (c) Microsoft Corporation. All rights reserved.
//
//  File: shtypes.idl
//
//  Contents: This interface definition contains typedefs for remotable
//            shell data types.
//
//  History:  18-JUN-99 ZekeL - created file
//
//--------------------------------------------------------------------------

cpp_quote("//+-------------------------------------------------------------------------")
cpp_quote("//")
cpp_quote("//  Microsoft Windows")
cpp_quote("//  Copyright (c) Microsoft Corporation. All rights reserved.")
cpp_quote("//")
cpp_quote("//--------------------------------------------------------------------------")

//
// Import definitions of the base types related to the 64b porting effort.
//
import "wtypes.idl";

cpp_quote("//===========================================================================")
cpp_quote("//")
cpp_quote("// Object identifiers in the explorer's name space (ItemID and IDList)")
cpp_quote("//")
cpp_quote("//  All the items that the user can browse with the explorer (such as files,")
cpp_quote("// directories, servers, work-groups, etc.) has an identifier which is unique")
cpp_quote("// among items within the parent folder. Those identifiers are called item")
cpp_quote("// IDs (SHITEMID). Since all its parent folders have their own item IDs,")
cpp_quote("// any items can be uniquely identified by a list of item IDs, which is called")
cpp_quote("// an ID list (ITEMIDLIST).")
cpp_quote("//")
cpp_quote("//  ID lists are almost always allocated by the task allocator (see some")
cpp_quote("// description below as well as OLE 2.0 SDK) and may be passed across")
cpp_quote("// some of shell interfaces (such as IShellFolder). Each item ID in an ID list")
cpp_quote("// is only meaningful to its parent folder (which has generated it), and all")
cpp_quote("// the clients must treat it as an opaque binary data except the first two")
cpp_quote("// bytes, which indicates the size of the item ID.")
cpp_quote("//")
cpp_quote("//  When a shell extension -- which implements the IShellFolder interace --")
cpp_quote("// generates an item ID, it may put any information in it, not only the data")
cpp_quote("// with that it needs to identifies the item, but also some additional")
cpp_quote("// information, which would help implementing some other functions efficiently.")
cpp_quote("// For example, the shell's IShellFolder implementation of file system items")
cpp_quote("// stores the primary (long) name of a file or a directory as the item")
cpp_quote("// identifier, but it also stores its alternative (short) name, size and date")
cpp_quote("// etc.")
cpp_quote("//")
cpp_quote("//  When an ID list is passed to one of shell APIs (such as SHGetPathFromIDList),")
cpp_quote("// it is always an absolute path -- relative from the root of the name space,")
cpp_quote("// which is the desktop folder. When an ID list is passed to one of IShellFolder")
cpp_quote("// member function, it is always a relative path from the folder (unless it")
cpp_quote("// is explicitly specified).")
cpp_quote("//")
cpp_quote("//===========================================================================")

cpp_quote("//")
cpp_quote("// SHITEMID -- Item ID  (mkid)")
cpp_quote("//     USHORT      cb;             // Size of the ID (including cb itself)")
cpp_quote("//     BYTE        abID[];         // The item ID (variable length)")
cpp_quote("//")
cpp_quote("#include <pshpack1.h>")
typedef struct _SHITEMID        
{
    USHORT      cb;             
    BYTE        abID[];         
} SHITEMID;
cpp_quote("#include <poppack.h>")

cpp_quote("#if defined(_M_IX86)")
cpp_quote("#define __unaligned")
cpp_quote("#endif // __unaligned")

//  WARNING: SHITEMID's have no marshalling support
typedef SHITEMID __unaligned *LPSHITEMID;
typedef const SHITEMID __unaligned *LPCSHITEMID;

cpp_quote("//")
cpp_quote("// ITEMIDLIST -- List if item IDs (combined with 0-terminator)")
cpp_quote("//")
cpp_quote("#include <pshpack1.h>")
typedef struct _ITEMIDLIST      // idl
{
    SHITEMID    mkid;
} ITEMIDLIST;
cpp_quote("#include <poppack.h>")


typedef [unique] BYTE_BLOB * wirePIDL;
typedef [wire_marshal(wirePIDL)] ITEMIDLIST __unaligned * LPITEMIDLIST;
typedef [wire_marshal(wirePIDL)] const ITEMIDLIST __unaligned * LPCITEMIDLIST;

#ifndef MAX_PATH
#define MAX_PATH 260
#endif

// make midl see a def of this stuct, but when the marshallers are built
// the defs of these get pulled from winbase.h
typedef struct _WINBASE_DEFINED_STRUCT { int dummy; } WINBASE_DEFINED_STRUCT ;

#define WINBASE_DEFINED_MIDL
cpp_quote("#ifdef WINBASE_DEFINED_MIDL")
typedef WINBASE_DEFINED_STRUCT WIN32_FIND_DATAA;
typedef WINBASE_DEFINED_STRUCT WIN32_FIND_DATAW;
cpp_quote("#endif // WINBASE_DEFINED_MIDL")

cpp_quote("//-------------------------------------------------------------------------")
cpp_quote("//")
cpp_quote("// struct STRRET")
cpp_quote("//")
cpp_quote("// structure for returning strings from IShellFolder member functions")
cpp_quote("//")
cpp_quote("//-------------------------------------------------------------------------")
cpp_quote("//")
cpp_quote("//  uType indicate which union member to use ")
cpp_quote("//    STRRET_WSTR    Use STRRET.pOleStr     must be freed by caller of GetDisplayNameOf")
cpp_quote("//    STRRET_OFFSET  Use STRRET.uOffset     Offset into SHITEMID for ANSI string ")
cpp_quote("//    STRRET_CSTR    Use STRRET.cStr        ANSI Buffer")
cpp_quote("//")

typedef [v1_enum] enum tagSTRRET_TYPE{
    STRRET_WSTR    = 0x0000,          // Use STRRET.pOleStr
    STRRET_OFFSET  = 0x0001,          // Use STRRET.uOffset to Ansi
    STRRET_CSTR    = 0x0002,          // Use STRRET.cStr
} STRRET_TYPE;

cpp_quote("#include <pshpack8.h>")
typedef struct _STRRET 
{
    UINT uType;
    [switch_type(UINT), switch_is(uType)] union 
    {
    [case(STRRET_WSTR)][string]    LPWSTR    pOleStr;        
    [case(STRRET_OFFSET)]          UINT      uOffset;        
    [case(STRRET_CSTR)]            char      cStr[MAX_PATH]; 
    } DUMMYUNIONNAME;
} STRRET;
cpp_quote("#include <poppack.h>")

typedef STRRET *LPSTRRET;


cpp_quote("//-------------------------------------------------------------------------")
cpp_quote("//")
cpp_quote("// struct SHELLDETAILS")
cpp_quote("//")
cpp_quote("// structure for returning strings from IShellDetails")
cpp_quote("//")
cpp_quote("//-------------------------------------------------------------------------")
cpp_quote("//")
cpp_quote("//  fmt;            // LVCFMT_* value (header only)")
cpp_quote("//  cxChar;         // Number of 'average' characters (header only)")
cpp_quote("//  str;            // String information")
cpp_quote("//")
cpp_quote("#include <pshpack1.h>")
typedef struct _SHELLDETAILS
{
    int     fmt;            // LVCFMT_* value (header only)
    int     cxChar;         // Number of "average" characters (header only)
    STRRET  str;            // String information
} SHELLDETAILS, *LPSHELLDETAILS;
cpp_quote("#include <poppack.h>")


