ReactOS  0.4.13-dev-479-gec9c8fd
enumlist.cpp File Reference
#include "precomp.h"
Include dependency graph for enumlist.cpp:

Go to the source code of this file.

Classes

struct  tagENUMLIST
 
class  CEnumIDList
 

Typedefs

typedef struct tagENUMLIST ENUMLIST
 
typedef struct tagENUMLISTLPENUMLIST
 

Functions

PNETCONIDSTRUCT ILGetConnData (PCITEMID_CHILD pidl)
 
PWCHAR ILGetConnName (PCITEMID_CHILD pidl)
 
PWCHAR ILGetDeviceName (PCITEMID_CHILD pidl)
 
PITEMID_CHILD ILCreateNetConnectItem (INetConnection *pItem)
 
HRESULT ILGetConnection (PCITEMID_CHILD pidl, INetConnection **pItem)
 
HRESULT CEnumIDList_CreateInstance (HWND hwndOwner, DWORD dwFlags, REFIID riid, LPVOID *ppv)
 

Typedef Documentation

◆ ENUMLIST

◆ LPENUMLIST

Function Documentation

◆ CEnumIDList_CreateInstance()

HRESULT CEnumIDList_CreateInstance ( HWND  hwndOwner,
DWORD  dwFlags,
REFIID  riid,
LPVOID ppv 
)

Definition at line 329 of file enumlist.cpp.

330 {
331  return ShellObjectCreatorInit<CEnumIDList>(riid, ppv);
332 }
REFIID riid
Definition: precomp.h:44
REFIID LPVOID * ppv
Definition: atlbase.h:39

Referenced by CNetworkConnections::EnumObjects().

◆ ILCreateNetConnectItem()

PITEMID_CHILD ILCreateNetConnectItem ( INetConnection pItem)

Definition at line 33 of file enumlist.cpp.

34 {
35  PITEMID_CHILD pidl;
37  NETCON_PROPERTIES * pProperties;
38  PNETCONIDSTRUCT pnetid;
39  PWCHAR pwchName;
40 
41  if (pItem->GetProperties(&pProperties) != S_OK)
42  return NULL;
43 
44  size = sizeof(WORD); /* nr of bytes in this item */
45  size += sizeof(NETCONIDSTRUCT);
46  size += (wcslen(pProperties->pszwName) + 1) * sizeof(WCHAR);
47  size += (wcslen(pProperties->pszwDeviceName) + 1) * sizeof(WCHAR);
48 
49  /* Allocate enough memory for the trailing id which will indicate that this is a simple id */
50  pidl = static_cast<LPITEMIDLIST>(SHAlloc(size + sizeof(SHITEMID)));
51  pidl->mkid.cb = (WORD)size;
52  pidl->mkid.abID[0] = 0x99;
53 
54  /* Copy the connection properties */
55  pnetid = ILGetConnData(pidl);
56  pnetid->guidId = pProperties->guidId;
57  pnetid->Status = pProperties->Status;
58  pnetid->MediaType = pProperties->MediaType;
59  pnetid->dwCharacter = pProperties->dwCharacter;
60  pnetid->uNameOffset = sizeof(NETCONIDSTRUCT);
61  pnetid->uDeviceNameOffset = pnetid->uNameOffset + (wcslen(pProperties->pszwName) + 1) * sizeof(WCHAR);
62 
63  pwchName = ILGetConnName(pidl);
64  wcscpy(pwchName, pProperties->pszwName);
65 
66  pwchName = ILGetDeviceName(pidl);
67  wcscpy(pwchName, pProperties->pszwDeviceName);
68 
69  /* Set the trailing id to null */
70  memset((void*)((ULONG_PTR)pidl + size), 0, sizeof(SHITEMID));
71 
72  NcFreeNetconProperties(pProperties);
73 
74  return pidl;
75 }
NETCON_MEDIATYPE MediaType
Definition: precomp.h:63
LPWSTR pszwDeviceName
Definition: netcon.h:85
NETCON_STATUS Status
Definition: precomp.h:62
ULONG_PTR uDeviceNameOffset
Definition: precomp.h:66
HRESULT GetProperties([out] NETCON_PROPERTIES **ppProps)
PWCHAR ILGetConnName(PCITEMID_CHILD pidl)
Definition: enumlist.cpp:17
uint16_t * PWCHAR
Definition: typedefs.h:54
VOID WINAPI NcFreeNetconProperties(NETCON_PROPERTIES *pProps)
Definition: netshell.cpp:119
WORD cb
Definition: shtypes.idl:27
DWORD dwCharacter
Definition: precomp.h:64
uint32_t ULONG_PTR
Definition: typedefs.h:63
BYTE abID[1]
Definition: shtypes.idl:28
smooth NULL
Definition: ftsmooth.c:416
PWCHAR ILGetDeviceName(PCITEMID_CHILD pidl)
Definition: enumlist.cpp:25
PNETCONIDSTRUCT ILGetConnData(PCITEMID_CHILD pidl)
Definition: enumlist.cpp:10
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned short WORD
Definition: ntddk_ex.h:93
ULONG_PTR uNameOffset
Definition: precomp.h:65
struct tagNETCONIDSTRUCT NETCONIDSTRUCT
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define S_OK
Definition: intsafe.h:59
NETCON_MEDIATYPE MediaType
Definition: netcon.h:87
NETCON_STATUS Status
Definition: netcon.h:86
SHITEMID mkid
Definition: shtypes.idl:34
#define memset(x, y, z)
Definition: compat.h:39
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:309
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by CEnumIDList::Initialize(), and CNetworkConnections::SetNameOf().

◆ ILGetConnData()

◆ ILGetConnection()

HRESULT ILGetConnection ( PCITEMID_CHILD  pidl,
INetConnection **  pItem 
)

Definition at line 77 of file enumlist.cpp.

78 {
79  HRESULT hr;
83  ULONG Count;
84  NETCON_PROPERTIES * pProperties;
85 
87  if (!pdata)
88  return E_FAIL;
89 
90  /* get an instance to of IConnectionManager */
91  hr = CNetConnectionManager_CreateInstance(IID_PPV_ARG(INetConnectionManager, &pNetConMan));
93  return hr;
94 
95  hr = pNetConMan->EnumConnections(NCME_DEFAULT, &pEnumCon);
97  return hr;
98 
99  while (TRUE)
100  {
101  hr = pEnumCon->Next(1, &INetCon, &Count);
102  if (hr != S_OK)
103  return E_FAIL;
104 
105  hr = INetCon->GetProperties(&pProperties);
106  if (FAILED_UNEXPECTEDLY(hr))
107  continue;
108 
109  BOOL bSame = !memcmp(&pProperties->guidId, &pdata->guidId, sizeof(GUID));
110 
111  NcFreeNetconProperties(pProperties);
112 
113  if (bSame)
114  {
115  *pItem = INetCon.Detach();
116  return S_OK;
117  }
118  }
119 
120  return E_FAIL;
121 }
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
HRESULT hr
Definition: shlfolder.c:183
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
VOID WINAPI NcFreeNetconProperties(NETCON_PROPERTIES *pProps)
Definition: netshell.cpp:119
unsigned int BOOL
Definition: ntddk_ex.h:94
PNETCONIDSTRUCT ILGetConnData(PCITEMID_CHILD pidl)
Definition: enumlist.cpp:10
static PROTOCOLDATA * pdata
Definition: protocol.c:157
LONG HRESULT
Definition: typedefs.h:77
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:35
#define S_OK
Definition: intsafe.h:59
HRESULT WINAPI CNetConnectionManager_CreateInstance(REFIID riid, LPVOID *ppv)
unsigned int ULONG
Definition: retypes.h:1
T * Detach()
Definition: atlcomcli.h:156

Referenced by CNetConUiObject::InvokeCommand(), and CNetworkConnections::SetNameOf().

◆ ILGetConnName()

PWCHAR ILGetConnName ( PCITEMID_CHILD  pidl)

Definition at line 17 of file enumlist.cpp.

18 {
20  if (!pdata)
21  return NULL;
22  return (PWCHAR)&pidl->mkid.abID[pdata->uNameOffset];
23 }
uint16_t * PWCHAR
Definition: typedefs.h:54
BYTE abID[1]
Definition: shtypes.idl:28
smooth NULL
Definition: ftsmooth.c:416
PNETCONIDSTRUCT ILGetConnData(PCITEMID_CHILD pidl)
Definition: enumlist.cpp:10
static PROTOCOLDATA * pdata
Definition: protocol.c:157
SHITEMID mkid
Definition: shtypes.idl:34

Referenced by CNetworkConnections::GetDetailsOf(), CNetworkConnections::GetDisplayNameOf(), and ILCreateNetConnectItem().

◆ ILGetDeviceName()

PWCHAR ILGetDeviceName ( PCITEMID_CHILD  pidl)

Definition at line 25 of file enumlist.cpp.

26 {
28  if (!pdata)
29  return NULL;
30  return (PWCHAR)&pidl->mkid.abID[pdata->uDeviceNameOffset];
31 }
uint16_t * PWCHAR
Definition: typedefs.h:54
BYTE abID[1]
Definition: shtypes.idl:28
smooth NULL
Definition: ftsmooth.c:416
PNETCONIDSTRUCT ILGetConnData(PCITEMID_CHILD pidl)
Definition: enumlist.cpp:10
static PROTOCOLDATA * pdata
Definition: protocol.c:157
SHITEMID mkid
Definition: shtypes.idl:34

Referenced by CNetworkConnections::GetDetailsOf(), and ILCreateNetConnectItem().