How can I read the ServerBindings for a given site using ABO? For example,
"/LM/W3SVC/12345/" ???

I need to parse out the ":80:myserver.com" to read the domain name for a
given Site ID.

- Mark

Re: Read ServerBindings using IMSAdminBase (ABO) by Ben

Ben
Mon Nov 22 17:05:34 CST 2004

Do you mean something like this?

Function GetSiteServerBindings(strServer, lngSiteNumber)
Set IISObj = getobject("IIS://" & strServer & "/W3SVC/" & lngSiteNumber)
GetSiteServerBindings = IISObj.ServerBindings(0)(0)
Set IISObj = nothing
end function

msgbox GetSiteServerBindings(".", "12345")

You can then use instrrev to find the last ":" & grab everything to the
right.

--
Ben Strackany
www.developmentnow.com

<a href="http://www.developmentnow.com">dn</a>


"Mark A. Richman" <nospam@nospam.com> wrote in message
news:Ovj2FlN0EHA.2540@TK2MSFTNGP09.phx.gbl...
> How can I read the ServerBindings for a given site using ABO? For example,
> "/LM/W3SVC/12345/" ???
>
> I need to parse out the ":80:myserver.com" to read the domain name for a
> given Site ID.
>
> - Mark
>
>



Re: Read ServerBindings using IMSAdminBase (ABO) by Mark

Mark
Mon Nov 22 18:26:59 CST 2004

This is a multi-part message in MIME format.

------=_NextPart_000_0018_01C4D0C9.3C5F02C0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

No I meant using the Admin Base Objects (ABO). This is a COM interface =
exposed to C++.

See =
http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/iissdk=
/iis/ref_abo_adminbaseobjects.asp

- Mark

"Ben Strackany" <infoNOSPAM@developmentnow.nospam.com> wrote in =
message news:#wuu4eO0EHA.3692@TK2MSFTNGP14.phx.gbl...
Do you mean something like this?

Function GetSiteServerBindings(strServer, lngSiteNumber)
Set IISObj =3D getobject("IIS://" & strServer & "/W3SVC/" & =
lngSiteNumber)
GetSiteServerBindings =3D IISObj.ServerBindings(0)(0)
Set IISObj =3D nothing
end function

msgbox GetSiteServerBindings(".", "12345")

You can then use instrrev to find the last ":" & grab everything to =
the
right.

--=20
Ben Strackany
www.developmentnow.com

<a href=3D"http://www.developmentnow.com">dn</a>


"Mark A. Richman" <nospam@nospam.com> wrote in message
news:Ovj2FlN0EHA.2540@TK2MSFTNGP09.phx.gbl...
> How can I read the ServerBindings for a given site using ABO? For =
example,
> "/LM/W3SVC/12345/" ???
>
> I need to parse out the ":80:myserver.com" to read the domain name =
for a
> given Site ID.
>
> - Mark
>
>


------=_NextPart_000_0018_01C4D0C9.3C5F02C0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.3790.218" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>No I meant using the Admin Base Objects =
(ABO). This=20
is a COM interface exposed to C++.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>See <A=20
href=3D"http://msdn.microsoft.com/library/default.asp?url=3D/library/en-u=
s/iissdk/iis/ref_abo_adminbaseobjects.asp">http://msdn.microsoft.com/libr=
ary/default.asp?url=3D/library/en-us/iissdk/iis/ref_abo_adminbaseobjects.=
asp</A></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>- Mark</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"Ben Strackany" &lt;<A=20
=
href=3D"mailto:infoNOSPAM@developmentnow.nospam.com">infoNOSPAM@developme=
ntnow.nospam.com</A>&gt;=20
wrote in message <A=20
=
href=3D"news:#wuu4eO0EHA.3692@TK2MSFTNGP14.phx.gbl">news:#wuu4eO0EHA.3692=
@TK2MSFTNGP14.phx.gbl</A>...</DIV>Do=20
you mean something like this?<BR><BR>Function =
GetSiteServerBindings(strServer,=20
lngSiteNumber)<BR>&nbsp;&nbsp;&nbsp; Set IISObj =3D getobject("IIS://" =
&amp;=20
strServer &amp; "/W3SVC/" &amp; lngSiteNumber)<BR>&nbsp;&nbsp;&nbsp;=20
GetSiteServerBindings =3D =
IISObj.ServerBindings(0)(0)<BR>&nbsp;&nbsp;&nbsp; Set=20
IISObj =3D nothing<BR>end function<BR><BR>msgbox =
GetSiteServerBindings(".",=20
"12345")<BR><BR>You can then use instrrev to find the last ":" &amp; =
grab=20
everything to the<BR>right.<BR><BR>-- <BR>Ben Strackany<BR><A=20
=
href=3D"http://www.developmentnow.com">www.developmentnow.com</A><BR><BR>=
&lt;a=20
href=3D"<A=20
=
href=3D'http://www.developmentnow.com">dn</a'>http://www.developmentnow.c=
om"&gt;dn&lt;/a</A>&gt;<BR><BR><BR>"Mark=20
A. Richman" &lt;<A =
href=3D"mailto:nospam@nospam.com">nospam@nospam.com</A>&gt;=20
wrote in message<BR><A=20
=
href=3D"news:Ovj2FlN0EHA.2540@TK2MSFTNGP09.phx.gbl">news:Ovj2FlN0EHA.2540=
@TK2MSFTNGP09.phx.gbl</A>...<BR>&gt;=20
How can I read the ServerBindings for a given site using ABO? For=20
example,<BR>&gt; "/LM/W3SVC/12345/" ???<BR>&gt;<BR>&gt; I need to =
parse out=20
the ":80:myserver.com" to read the domain name for a<BR>&gt; given =
Site=20
ID.<BR>&gt;<BR>&gt; - =
Mark<BR>&gt;<BR>&gt;<BR><BR></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0018_01C4D0C9.3C5F02C0--


Re: Read ServerBindings using IMSAdminBase (ABO) by John

John
Mon Nov 22 19:38:21 CST 2004

Something like below as a rough example


#define WIN32_WINNT 0x0400
#define UNICODE
#define INITGUID
#define STATUS_STRING_SIZE 2048

#include <stdio.h>
#include <windows.h>

#include "MetaTest.h"

#include <iostream.h>
#include <winnt.h>

#include <ks.h>
#include "iadmw.h" // COM Interface header
#include "iiscnfg.h" // MD_ & IIS_MD_ #defines

#include "iwamreg.h"

#include "atlBase.h" // ATL support for smart pointers
#include <asptlb.h>
#include <activeds.h>



int main(int argc, char* argv[])
{
TCHAR szStatus[STATUS_STRING_SIZE];
HRESULT hcores = S_OK;


// initialize COM
hcores = CoInitialize(NULL);

if (FAILED(hcores))
{
wsprintf(szStatus, TEXT("CoInitializeEx failed: %d (0x%08x)"),
hcores, hcores);
fwprintf (stderr, TEXT("%s"), szStatus);
return 0;
}


GetWebSiteDetails();


CoUninitialize();
return 0;
}

BOOL GetWebSiteDetails()

{
HRESULT hRes = 0;
HRESULT hRes1 = 0;
HRESULT hRes2 = 0;
DWORD indx = 0;
METADATA_HANDLE MyHandle;
METADATA_RECORD MyRecord;
WCHAR SubKeyName[METADATA_MAX_NAME_LEN];
CComPtr <IMSAdminBase> pIMeta;
BOOL bMatched = FALSE;
TCHAR CurrKey[METADATA_MAX_NAME_LEN];
DWORD dwBufLen = 1024;
DWORD dwReqBufLen = 0;
PBYTE pbBuffer = new BYTE[dwBufLen];
TCHAR szMetabasepath[MAX_PATH];
DWORD dwWebState;
TCHAR szStatus[32];
WCHAR szTemp[1024];

hRes = CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL,
IID_IMSAdminBase, (void **) &pIMeta);

if (FAILED(hRes))
return FALSE;

//get a handle to the web service
hRes = pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, TEXT("/LM"),
METADATA_PERMISSION_READ, 20, &MyHandle);

if (FAILED(hRes))
{
wprintf(TEXT("OpenKey failed: %d (0x%08x)"),
hRes,
hRes
);
return FALSE;
}


//loop until there are no more subkeys
while (SUCCEEDED(hRes))
{
//enumerate the subkeys of the World Wide Web service
hRes = pIMeta->EnumKeys(MyHandle, TEXT("/W3SVC"), SubKeyName, indx);
if (SUCCEEDED(hRes))
{
//initialize the input structure,
//the values specify what kind of data to retrieve
MyRecord.dwMDAttributes = METADATA_NO_ATTRIBUTES;
MyRecord.dwMDUserType = IIS_MD_UT_SERVER;
MyRecord.dwMDDataType = ALL_METADATA;
MyRecord.dwMDDataLen = dwBufLen;
MyRecord.pbMDData = pbBuffer;
MyRecord.dwMDIdentifier = MD_KEY_TYPE; // KeyType
wsprintf(CurrKey, TEXT("/W3SVC/%s"), SubKeyName);
hRes1 = pIMeta->GetData(MyHandle, CurrKey, &MyRecord, &dwReqBufLen);
if (!hRes1 && (!wcscmp((TCHAR *)MyRecord.pbMDData,
TEXT("IIsWebServer"))))
{
hRes2 = pIMeta->GetDataPaths (MyHandle, CurrKey, MD_APP_PACKAGE_ID,
ALL_METADATA, dwBufLen, szTemp, &dwReqBufLen);

MyRecord.dwMDAttributes = METADATA_NO_ATTRIBUTES;
MyRecord.dwMDUserType = IIS_MD_UT_SERVER;
MyRecord.dwMDDataType = ALL_METADATA;
MyRecord.dwMDDataLen = dwBufLen;
MyRecord.pbMDData = pbBuffer;
MyRecord.dwMDIdentifier = MD_SERVER_COMMENT;
hRes1 = pIMeta->GetData(MyHandle, CurrKey, &MyRecord, &dwReqBufLen);
if (!hRes1)
{
wsprintf(szMetabasepath, TEXT("/LM%s %s"), CurrKey, (TCHAR
*)MyRecord.pbMDData);
// wprintf(TEXT("/LM%s %s\n"), CurrKey, (TCHAR *)MyRecord.pbMDData);
}

MyRecord.dwMDAttributes = METADATA_NO_ATTRIBUTES;
MyRecord.dwMDUserType = IIS_MD_UT_SERVER;
MyRecord.dwMDDataType = ALL_METADATA;
MyRecord.dwMDDataLen = dwBufLen;
MyRecord.pbMDData = pbBuffer;
MyRecord.dwMDIdentifier = MD_SERVER_BINDINGS;
hRes1 = pIMeta->GetData(MyHandle, CurrKey, &MyRecord, &dwReqBufLen);
if (!hRes1)
{
wprintf(TEXT("%s %s\n"), szMetabasepath, (TCHAR
*)MyRecord.pbMDData);
}
}
}
//increment the index
indx++;
}
//release the handle
pIMeta->CloseKey(MyHandle);
delete pbBuffer;

return 0;
}



Re: Read ServerBindings using IMSAdminBase (ABO) by v-wzhang

v-wzhang
Tue Nov 23 01:26:19 CST 2004

Hi Mark,

You can use the IMSAdminBase::GetData method.

IMSAdminBase::GetData
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissd
k/iis/ref_abo_imsabmgetdata.asp

The dwMDIdentifier attribute of populated METADATA_RECORD structure
should be MD_SERVER_BINDINGS. The following link contains the sample
about how to call EnumData. You can refer to the code. The whole C++
project is included in Platform SDK.

Enumerating Keys and Data Using ABO
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iissd
k/iis/enumerating_keys_and_data_using_abo.asp

Thanks.

Best regards,

WenJun Zhang
Microsoft Online Support
This posting is provided "AS IS" with no warranties, and confers no
rights.
Get Secure! - www.microsoft.com/security


Re: Read ServerBindings using IMSAdminBase (ABO) by Mark

Mark
Tue Nov 23 12:35:06 CST 2004

This is a multi-part message in MIME format.

------=_NextPart_000_0010_01C4D161.3EC8B3B0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

That worked like a charm! Now, using the same technique (ABO), how would =
I create a new website (hostheader on port 80) running in its own =
AppPool?

Basically I want the ABO functional equivalent of "iisweb /create c:\foo =
"Test Site 2" /d testsite2.com" but running in a new AppPool.

Thanks,
Mark
"John Campbell" <jc> wrote in message =
news:OpG7f0P0EHA.2316@TK2MSFTNGP15.phx.gbl...
Something like below as a rough example


#define WIN32_WINNT 0x0400
#define UNICODE
#define INITGUID
#define STATUS_STRING_SIZE 2048

#include <stdio.h>
#include <windows.h>

#include "MetaTest.h"

#include <iostream.h>
#include <winnt.h>

#include <ks.h>
#include "iadmw.h" // COM Interface header
#include "iiscnfg.h" // MD_ & IIS_MD_ #defines

#include "iwamreg.h"

#include "atlBase.h" // ATL support for smart pointers
#include <asptlb.h>
#include <activeds.h>



int main(int argc, char* argv[])
{
TCHAR szStatus[STATUS_STRING_SIZE];
HRESULT hcores =3D S_OK;


// initialize COM
hcores =3D CoInitialize(NULL);

if (FAILED(hcores))
{
wsprintf(szStatus, TEXT("CoInitializeEx failed: %d (0x%08x)"),
hcores, hcores);
fwprintf (stderr, TEXT("%s"), szStatus);
return 0;
}


GetWebSiteDetails();


CoUninitialize();
return 0;
}

BOOL GetWebSiteDetails()

{
HRESULT hRes =3D 0;
HRESULT hRes1 =3D 0;
HRESULT hRes2 =3D 0;
DWORD indx =3D 0;
METADATA_HANDLE MyHandle;
METADATA_RECORD MyRecord;
WCHAR SubKeyName[METADATA_MAX_NAME_LEN];
CComPtr <IMSAdminBase> pIMeta;
BOOL bMatched =3D FALSE;
TCHAR CurrKey[METADATA_MAX_NAME_LEN];
DWORD dwBufLen =3D 1024;
DWORD dwReqBufLen =3D 0;
PBYTE pbBuffer =3D new BYTE[dwBufLen];
TCHAR szMetabasepath[MAX_PATH];
DWORD dwWebState;
TCHAR szStatus[32];
WCHAR szTemp[1024];

hRes =3D CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL,
IID_IMSAdminBase, (void **) &pIMeta);

if (FAILED(hRes))
return FALSE;

//get a handle to the web service
hRes =3D pIMeta->OpenKey(METADATA_MASTER_ROOT_HANDLE, TEXT("/LM"),
METADATA_PERMISSION_READ, 20, &MyHandle);

if (FAILED(hRes))
{
wprintf(TEXT("OpenKey failed: %d (0x%08x)"),
hRes,
hRes
);
return FALSE;
}


//loop until there are no more subkeys
while (SUCCEEDED(hRes))
{
//enumerate the subkeys of the World Wide Web service
hRes =3D pIMeta->EnumKeys(MyHandle, TEXT("/W3SVC"), SubKeyName, =
indx);
if (SUCCEEDED(hRes))
{
//initialize the input structure,
//the values specify what kind of data to retrieve
MyRecord.dwMDAttributes =3D METADATA_NO_ATTRIBUTES;
MyRecord.dwMDUserType =3D IIS_MD_UT_SERVER;
MyRecord.dwMDDataType =3D ALL_METADATA;
MyRecord.dwMDDataLen =3D dwBufLen;
MyRecord.pbMDData =3D pbBuffer;
MyRecord.dwMDIdentifier =3D MD_KEY_TYPE; // KeyType
wsprintf(CurrKey, TEXT("/W3SVC/%s"), SubKeyName);
hRes1 =3D pIMeta->GetData(MyHandle, CurrKey, &MyRecord, =
&dwReqBufLen);
if (!hRes1 && (!wcscmp((TCHAR *)MyRecord.pbMDData,
TEXT("IIsWebServer"))))
{
hRes2 =3D pIMeta->GetDataPaths (MyHandle, CurrKey, =
MD_APP_PACKAGE_ID,
ALL_METADATA, dwBufLen, szTemp, &dwReqBufLen);

MyRecord.dwMDAttributes =3D METADATA_NO_ATTRIBUTES;
MyRecord.dwMDUserType =3D IIS_MD_UT_SERVER;
MyRecord.dwMDDataType =3D ALL_METADATA;
MyRecord.dwMDDataLen =3D dwBufLen;
MyRecord.pbMDData =3D pbBuffer;
MyRecord.dwMDIdentifier =3D MD_SERVER_COMMENT;
hRes1 =3D pIMeta->GetData(MyHandle, CurrKey, &MyRecord, =
&dwReqBufLen);
if (!hRes1)
{
wsprintf(szMetabasepath, TEXT("/LM%s %s"), CurrKey, (TCHAR
*)MyRecord.pbMDData);
// wprintf(TEXT("/LM%s %s\n"), CurrKey, (TCHAR =
*)MyRecord.pbMDData);
}

MyRecord.dwMDAttributes =3D METADATA_NO_ATTRIBUTES;
MyRecord.dwMDUserType =3D IIS_MD_UT_SERVER;
MyRecord.dwMDDataType =3D ALL_METADATA;
MyRecord.dwMDDataLen =3D dwBufLen;
MyRecord.pbMDData =3D pbBuffer;
MyRecord.dwMDIdentifier =3D MD_SERVER_BINDINGS;
hRes1 =3D pIMeta->GetData(MyHandle, CurrKey, &MyRecord, =
&dwReqBufLen);
if (!hRes1)
{
wprintf(TEXT("%s %s\n"), szMetabasepath, (TCHAR
*)MyRecord.pbMDData);
}
}
}
//increment the index
indx++;
}
//release the handle
pIMeta->CloseKey(MyHandle);
delete pbBuffer;

return 0;
}


------=_NextPart_000_0010_01C4D161.3EC8B3B0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.3790.218" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>That worked like a charm! Now, using =
the same=20
technique (ABO), how would I create a new website (hostheader on port =
80)=20
running in its own AppPool?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Basically I want the ABO functional =
equivalent of=20
"iisweb /create c:\foo "Test Site 2" /d testsite2.com" but running in a =
new=20
AppPool.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Mark</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV>"John Campbell" &lt;jc&gt; wrote in message <A=20
=
href=3D"news:OpG7f0P0EHA.2316@TK2MSFTNGP15.phx.gbl">news:OpG7f0P0EHA.2316=
@TK2MSFTNGP15.phx.gbl</A>...</DIV>Something=20
like below as a rough example<BR><BR><BR>#define WIN32_WINNT =
0x0400<BR>#define=20
UNICODE<BR>#define INITGUID<BR>#define STATUS_STRING_SIZE =
2048<BR><BR>#include=20
&lt;stdio.h&gt;<BR>#include &lt;windows.h&gt;<BR><BR>#include=20
"MetaTest.h"<BR><BR>#include &lt;iostream.h&gt;<BR>#include=20
&lt;winnt.h&gt;<BR><BR>#include &lt;ks.h&gt;<BR>#include=20
"iadmw.h"&nbsp;&nbsp;&nbsp; // COM Interface header<BR>#include=20
"iiscnfg.h"&nbsp; // MD_ &amp; IIS_MD_ #defines<BR><BR>#include=20
"iwamreg.h"<BR><BR>#include "atlBase.h"&nbsp; // ATL support for smart =

pointers<BR>#include &lt;asptlb.h&gt;<BR>#include=20
&lt;activeds.h&gt;<BR><BR><BR><BR>int main(int argc, char*=20
argv[])<BR>{<BR>&nbsp;&nbsp;&nbsp; TCHAR=20
szStatus[STATUS_STRING_SIZE];<BR>&nbsp;HRESULT hcores =3D=20
S_OK;<BR><BR><BR>&nbsp;// initialize COM<BR>&nbsp;&nbsp;&nbsp; hcores =
=3D=20
CoInitialize(NULL);<BR><BR>&nbsp;&nbsp;&nbsp; if=20
(FAILED(hcores))<BR>&nbsp;&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; wsprintf(szStatus,=20
TEXT("CoInitializeEx failed: %d (0x%08x)"),<BR>hcores, =
hcores);<BR>&nbsp;=20
fwprintf (stderr, TEXT("%s"), szStatus);<BR>&nbsp; return=20
0;<BR>&nbsp;&nbsp;&nbsp;=20
=
}<BR><BR><BR>&nbsp;GetWebSiteDetails();<BR><BR><BR>&nbsp;CoUninitialize()=
;<BR>&nbsp;return=20
0;<BR>}<BR><BR>BOOL GetWebSiteDetails()<BR><BR>{<BR>&nbsp;HRESULT hRes =
=3D=20
0;<BR>&nbsp;HRESULT hRes1 =3D 0;<BR>&nbsp;HRESULT hRes2 =3D =
0;<BR>&nbsp;DWORD indx=20
=3D 0;<BR>&nbsp;METADATA_HANDLE MyHandle;<BR>&nbsp;METADATA_RECORD=20
MyRecord;<BR>&nbsp;WCHAR =
SubKeyName[METADATA_MAX_NAME_LEN];<BR>&nbsp;CComPtr=20
&lt;IMSAdminBase&gt; pIMeta;<BR>&nbsp;BOOL bMatched =3D =
FALSE;<BR>&nbsp;TCHAR=20
CurrKey[METADATA_MAX_NAME_LEN];<BR>&nbsp;DWORD dwBufLen =3D =
1024;<BR>&nbsp;DWORD=20
dwReqBufLen =3D 0;<BR>&nbsp;PBYTE pbBuffer =3D new=20
BYTE[dwBufLen];<BR>&nbsp;&nbsp;&nbsp; TCHAR=20
szMetabasepath[MAX_PATH];<BR>&nbsp;DWORD dwWebState;<BR>&nbsp;TCHAR=20
szStatus[32];<BR>&nbsp;WCHAR szTemp[1024];<BR><BR>&nbsp;hRes =3D=20
CoCreateInstance(CLSID_MSAdminBase, NULL, CLSCTX_ALL,<BR>&nbsp;=20
IID_IMSAdminBase, (void **) &amp;pIMeta);<BR><BR>&nbsp;if=20
(FAILED(hRes))<BR>&nbsp; return FALSE;<BR><BR>&nbsp;//get a handle to =
the web=20
service<BR>&nbsp;hRes =3D =
pIMeta-&gt;OpenKey(METADATA_MASTER_ROOT_HANDLE,=20
TEXT("/LM"),<BR>METADATA_PERMISSION_READ, 20, =
&amp;MyHandle);<BR><BR>&nbsp;if=20
=
(FAILED(hRes))<BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
wprintf(TEXT("OpenKey failed: %d=20
=
(0x%08x)"),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;=20
=
hRes,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;=20
=
hRes<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
);<BR>&nbsp; return FALSE;<BR>&nbsp;}<BR><BR><BR>&nbsp;//loop until =
there are=20
no more subkeys<BR>&nbsp;while (SUCCEEDED(hRes))<BR>&nbsp;{<BR>&nbsp;=20
//enumerate the subkeys of the World Wide Web service<BR>&nbsp; hRes =
=3D=20
pIMeta-&gt;EnumKeys(MyHandle, TEXT("/W3SVC"), SubKeyName, =
indx);<BR>&nbsp; if=20
(SUCCEEDED(hRes))<BR>&nbsp; {<BR>&nbsp;&nbsp; //initialize the input=20
structure,<BR>&nbsp;&nbsp; //the values specify what kind of data to=20
retrieve<BR>&nbsp;&nbsp; MyRecord.dwMDAttributes =3D=20
METADATA_NO_ATTRIBUTES;<BR>&nbsp;&nbsp; MyRecord.dwMDUserType =3D=20
IIS_MD_UT_SERVER;<BR>&nbsp;&nbsp; MyRecord.dwMDDataType =3D=20
ALL_METADATA;<BR>&nbsp;&nbsp; MyRecord.dwMDDataLen =3D =
dwBufLen;<BR>&nbsp;&nbsp;=20
MyRecord.pbMDData =3D pbBuffer;<BR>&nbsp;&nbsp; =
MyRecord.dwMDIdentifier =3D=20
MD_KEY_TYPE; // KeyType<BR>&nbsp;&nbsp; wsprintf(CurrKey, =
TEXT("/W3SVC/%s"),=20
SubKeyName);<BR>&nbsp;&nbsp; hRes1 =3D pIMeta-&gt;GetData(MyHandle, =
CurrKey,=20
&amp;MyRecord, &amp;dwReqBufLen);<BR>&nbsp;&nbsp; if (!hRes1 =
&amp;&amp;=20
(!wcscmp((TCHAR=20
*)MyRecord.pbMDData,<BR>TEXT("IIsWebServer"))))<BR>&nbsp;&nbsp;=20
{<BR>&nbsp;&nbsp;&nbsp; hRes2 =3D pIMeta-&gt;GetDataPaths (MyHandle, =
CurrKey,=20
MD_APP_PACKAGE_ID,<BR>ALL_METADATA, dwBufLen, szTemp,=20
&amp;dwReqBufLen);<BR