scrrun: Implement Count() property for drive collection.

This commit is contained in:
Nikolay Sivov 2014-03-11 00:21:03 +04:00 committed by Alexandre Julliard
parent a30a2abbc4
commit 863a761426
2 changed files with 17 additions and 6 deletions

View File

@ -54,6 +54,7 @@ struct drivecollection {
IDriveCollection IDriveCollection_iface;
LONG ref;
DWORD drives;
LONG count;
};
struct enumdata {
@ -1675,8 +1676,13 @@ static HRESULT WINAPI drivecoll_get__NewEnum(IDriveCollection *iface, IUnknown *
static HRESULT WINAPI drivecoll_get_Count(IDriveCollection *iface, LONG *count)
{
struct drivecollection *This = impl_from_IDriveCollection(iface);
FIXME("(%p)->(%p): stub\n", This, count);
return E_NOTIMPL;
TRACE("(%p)->(%p)\n", This, count);
if (!count) return E_POINTER;
*count = This->count;
return S_OK;
}
static const IDriveCollectionVtbl drivecollectionvtbl = {
@ -1695,6 +1701,7 @@ static const IDriveCollectionVtbl drivecollectionvtbl = {
static HRESULT create_drivecoll(IDriveCollection **drives)
{
struct drivecollection *This;
DWORD mask;
*drives = NULL;
@ -1703,7 +1710,10 @@ static HRESULT create_drivecoll(IDriveCollection **drives)
This->IDriveCollection_iface.lpVtbl = &drivecollectionvtbl;
This->ref = 1;
This->drives = GetLogicalDrives();
This->drives = mask = GetLogicalDrives();
/* count set bits */
for (This->count = 0; mask; This->count++)
mask &= mask - 1;
*drives = &This->IDriveCollection_iface;
return S_OK;

View File

@ -1157,12 +1157,14 @@ static void test_DriveCollection(void)
hr = IDriveCollection_get__NewEnum(drives, (IUnknown**)&enumvar);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IDriveCollection_get_Count(drives, NULL);
ok(hr == E_POINTER, "got 0x%08x\n", hr);
count = 0;
hr = IDriveCollection_get_Count(drives, &count);
todo_wine {
ok(hr == S_OK, "got 0x%08x\n", hr);
ok(count > 0, "got %d\n", count);
}
V_VT(&var) = VT_EMPTY;
fetched = -1;
hr = IEnumVARIANT_Next(enumvar, 0, &var, &fetched);
@ -1176,7 +1178,6 @@ todo_wine {
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IEnumVARIANT_Skip(enumvar, 1);
todo_wine
ok(hr == S_FALSE, "got 0x%08x\n", hr);
IEnumVARIANT_Release(enumvar);