ReactOS 0.4.15-dev-5667-ged97270
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: atlbase.h:39
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}
#define NULL
Definition: types.h:112
struct tagNETCONIDSTRUCT NETCONIDSTRUCT
LPVOID WINAPI SHAlloc(SIZE_T len)
Definition: shellole.c:304
PWCHAR ILGetDeviceName(PCITEMID_CHILD pidl)
Definition: enumlist.cpp:25
PNETCONIDSTRUCT ILGetConnData(PCITEMID_CHILD pidl)
Definition: enumlist.cpp:10
PWCHAR ILGetConnName(PCITEMID_CHILD pidl)
Definition: enumlist.cpp:17
unsigned short WORD
Definition: ntddk_ex.h:93
GLsizeiptr size
Definition: glext.h:5919
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
HRESULT GetProperties([out] NETCON_PROPERTIES **ppProps)
#define S_OK
Definition: intsafe.h:52
VOID WINAPI NcFreeNetconProperties(NETCON_PROPERTIES *pProps)
Definition: netshell.cpp:119
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define memset(x, y, z)
Definition: compat.h:39
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
BYTE abID[1]
Definition: shtypes.idl:28
WORD cb
Definition: shtypes.idl:27
SHITEMID mkid
Definition: shtypes.idl:34
ULONG_PTR uDeviceNameOffset
Definition: precomp.h:66
DWORD dwCharacter
Definition: precomp.h:64
NETCON_MEDIATYPE MediaType
Definition: precomp.h:63
ULONG_PTR uNameOffset
Definition: precomp.h:65
NETCON_STATUS Status
Definition: precomp.h:62
NETCON_STATUS Status
Definition: netcon.h:86
LPWSTR pszwDeviceName
Definition: netcon.h:85
NETCON_MEDIATYPE MediaType
Definition: netcon.h:87
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint16_t * PWCHAR
Definition: typedefs.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180

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;
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);
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}
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
T * Detach()
Definition: atlcomcli.h:163
HRESULT WINAPI CNetConnectionManager_CreateInstance(REFIID riid, LPVOID *ppv)
#define E_FAIL
Definition: ddrawi.h:102
#define TRUE
Definition: types.h:120
unsigned int BOOL
Definition: ntddk_ex.h:94
static PROTOCOLDATA * pdata
Definition: protocol.c:158
@ NCME_DEFAULT
Definition: netcon.h:10
int Count
Definition: noreturn.cpp:7
#define FAILED_UNEXPECTEDLY(hr)
Definition: shellutils.h:82
HRESULT hr
Definition: shlfolder.c:183
uint32_t ULONG
Definition: typedefs.h:59
#define IID_PPV_ARG(Itype, ppType)

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}

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}

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