Home > Archive > VC Language > June 2005 > COM question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| David Crow [MCSD] 2005-06-01, 8:59 pm |
| This might be considered an elementary question for those with COM
emblazened upon their belt buckles, but I know just enough about it to be
dangerous! Here goes...
If I include <dskquota.h>, I can use the following code just fine:
IDiskQuotaControl *lpDiskQuotaControl;
IEnumDiskQuotaUsers *lpEnumDiskQuotaUsers;
HRESULT hr = CoCreateInstance(CLSID_DiskQuotaControl,
NULL,
CLSCTX_INPROC_SERVER,
IID_IDiskQuotaControl,
(LPVOID*)&lpDiskQuotaControl);
if (SUCCEEDED(hr))
{
hr = lpDiskQuotaControl->Initialize(_bstr_t("c:\\"), TRUE);
if (SUCCEEDED(hr))
{
hr = lpDiskQuotaControl->CreateEnumUsers(NULL, 0,
DISKQUOTA_USERNAME_RESOLVE_SYNC,
&lpEnumDiskQuotaUsers);
...
}
lpDiskQuotaControl->Release();
}
If, however, I wanted to use smart pointers instead with #import
<dskquota.dll> then the CreateEnumUsers() method does not show up in the
..tlh or .tli file. There also does not appear to be an interface for the
users (plural). Is it supposed to be this way, or what am I doing wrong?
Thanks,
DC
| |
| Simon Trew 2005-06-02, 4:02 am |
| "David Crow [MCSD]" <david.no.spam.crow@pbsnow.no.spam.com> wrote in message
news:OOhp1dtZFHA.3144@TK2MSFTNGP12.phx.gbl...
> If, however, I wanted to use smart pointers instead with #import
> <dskquota.dll> then the CreateEnumUsers() method does not show up in the
> .tlh or .tli file. There also does not appear to be an interface for the
> users (plural). Is it supposed to be this way, or what am I doing wrong?
It doesn't show up in mine either. I imported the library into VB6 and it
doesn't have that method or users (plural), nor CreateUserBatch. dskquota.h
in VC98\Include is pretty obviously handcrafted as it contains numerous
comments. I note that there is a version of the DLL in
\Windows\$NTServicePackUninstall; I have:
Directory of C:\WINDOWS\$NtServicePackUninstall$
23/08/2001 13:00 84,992 dskquota.dll
1 File(s) 84,992 bytes
Directory of C:\WINDOWS\ServicePackFiles\i386
04/08/2004 08:56 92,672 dskquota.dll
1 File(s) 92,672 bytes
Directory of C:\WINDOWS\system32
04/08/2004 08:56 92,672 dskquota.dll
1 File(s) 92,672 bytes
(I'm running XP SP2)
| |
| Sergei 2005-06-02, 9:06 am |
| "David Crow [MCSD]" <david.no.spam.crow@pbsnow.no.spam.com> сообщил/сообщила в новостях следующее:
news:OOhp1dtZFHA.3144@TK2MSFTNGP12.phx.gbl...
> This might be considered an elementary question for those with COM
> emblazened upon their belt buckles, but I know just enough about it to be
> dangerous! Here goes...
>
> If I include <dskquota.h>, I can use the following code just fine:
>
> IDiskQuotaControl *lpDiskQuotaControl;
> IEnumDiskQuotaUsers *lpEnumDiskQuotaUsers;
> HRESULT hr = CoCreateInstance(CLSID_DiskQuotaControl,
> NULL,
> CLSCTX_INPROC_SERVER,
> IID_IDiskQuotaControl,
> (LPVOID*)&lpDiskQuotaControl);
> if (SUCCEEDED(hr))
> {
> hr = lpDiskQuotaControl->Initialize(_bstr_t("c:\\"), TRUE);
> if (SUCCEEDED(hr))
> {
> hr = lpDiskQuotaControl->CreateEnumUsers(NULL, 0,
>
> DISKQUOTA_USERNAME_RESOLVE_SYNC,
> &lpEnumDiskQuotaUsers);
> ...
> }
> lpDiskQuotaControl->Release();
> }
>
> If, however, I wanted to use smart pointers instead with #import
> <dskquota.dll> then the CreateEnumUsers() method does not show up in the
> .tlh or .tli file. There also does not appear to be an interface for the
> users (plural). Is it supposed to be this way, or what am I doing wrong?
It looks like the type library only has dispatch interfaces.
You still can use smart pointers though:
// begin
#include <dskquota.h>
#include <comdef.h>
_COM_SMARTPTR_TYPEDEF(IDiskQuotaControl,
IID_IDiskQuotaControl);
_COM_SMARTPTR_TYPEDEF(IEnumDiskQuotaUser
s, IID_IEnumDiskQuotaUsers);
void test()
{
IDiskQuotaControlPtr spDiskQuotaControl;
HRESULT hr = spDiskQuotaControl.CreateInstance(CLSID_DiskQuotaControl);
if (FAILED(hr)) _com_raise_error(hr);
hr = spDiskQuotaControl->Initialize(_bstr_t("c:\\"), TRUE);
if (FAILED(hr)) _com_raise_error(hr);
IEnumDiskQuotaUsersPtr spEnumDiskQuotaUsers;
hr = spDiskQuotaControl->CreateEnumUsers(NULL, 0, DISKQUOTA_USERNAME_RESOLVE_SYNC, &spEnumDiskQuotaUsers);
if (FAILED(hr)) _com_raise_error(hr);
}
// end
Sergei
| |
| thatsalok 2005-06-02, 9:06 am |
|
"Sergei" <sergei@nospam.summertime.mtu-net.ru> wrote in message
news:#H7L150ZFHA.2308@TK2MSFTNGP14.phx.gbl...
> "David Crow [MCSD]" <david.no.spam.crow@pbsnow.no.spam.com>
сообщил/сообщила в новостях следующее:
> news:OOhp1dtZFHA.3144@TK2MSFTNGP12.phx.gbl...
be[color=darkred]
the[color=darkred]
wrong?[color=darkred]
>
> It looks like the type library only has dispatch interfaces.
> You still can use smart pointers though:
>
> // begin
> #include <dskquota.h>
> #include <comdef.h>
>
> _COM_SMARTPTR_TYPEDEF(IDiskQuotaControl,
IID_IDiskQuotaControl);
> _COM_SMARTPTR_TYPEDEF(IEnumDiskQuotaUser
s, IID_IEnumDiskQuotaUsers);
>
> void test()
> {
> IDiskQuotaControlPtr spDiskQuotaControl;
> HRESULT hr = spDiskQuotaControl.CreateInstance(CLSID_DiskQuotaControl);
> if (FAILED(hr)) _com_raise_error(hr);
>
> hr = spDiskQuotaControl->Initialize(_bstr_t("c:\\"), TRUE);
> if (FAILED(hr)) _com_raise_error(hr);
>
> IEnumDiskQuotaUsersPtr spEnumDiskQuotaUsers;
> hr = spDiskQuotaControl->CreateEnumUsers(NULL, 0,
DISKQUOTA_USERNAME_RESOLVE_SYNC, &spEnumDiskQuotaUsers);
> if (FAILED(hr)) _com_raise_error(hr);
> }
> // end
>
> Sergei
>
Great!!!, I will note it Down!, never heard about this before!
--
cheers,
Alok Gupta
Visit me at http://alok.bizhat.com
|
|
|
|
|