locked
trouble with Microsoft.Web.Administration.dll, Interop, Visual C++ 6.0 RRS feed

  • Question

  • User-1202834629 posted

    I would like to use the functionality contained within Microsoft.Web.Administration.dll.  More specifically I would like to be able to do this from a Visual C++ 6.0 dll.  I tried to use COM Interop to do this, but when I export the Microsoft.Web.Administration.dll to a type library (using Tlbexp.exe), I do not get any interfaces that I can use.

     So, is there some way I can access this via COM Interop?

     Otherwise, is there another file I can access besides Microsoft.Web.Administration.dll?

     Or, am I stuck using a .NET dll to configure IIS 7 with code?

    Thanks in advance for any help\suggestions.

    Tuesday, September 12, 2006 6:04 PM

All replies

  • User-1202834629 posted

    Ok, as a workaround I did the following:

    • Created my own C# dll in Visual Studio 2005
    • Created an interface to the dll, setting ComVisible to 'true'
    • Created an EXE in Visual C++ 6.0
    • In the VC C++ 6 code, imported the tlb of the C# dll and used Com Interop to access the C# dll

    Now I can access Microsoft.Web.Administration.dll.

    Perhaps this workaround is unnecessary?  Maybe the Microsoft IIS team could create a ComVisible interface for Microsoft.Web.Administration.dll?

    Wednesday, September 13, 2006 2:41 PM
  • User-1832218776 posted

    There is an API that we are recommending for usage within native code applications or module development. This is a native code COM-friendly interface. You can find it in the nativerd.dll in the inetsrv directory. This interface is the AHADMIN interface that can also be used from within native code modules via the httpserv API. Also, you can take the AHADMIN interface and access it via script by creating a COM object from script or if you want, from managed code by importing the library into your managed code project.

     Here is a quick sample in native code of how to access root configuration for the default document section:


     //Get the configuration system object
     IAppHostAdminManager* pAppHostAdminManager = g_pHttpServer->GetAdminManager();
            
     //Get the global <system.webServer/defaultDocument> section from applicationHost.config
       
     //Get the configuration section.
     IAppHostElement* pDemoSection = NULL;
     hr = pAppHostAdminManager->GetAdminSection(L"system.webServer/defaultDocument",L"MACHINE/WEBROOT/APPHOST",&pDemoSection);
           
     //Get the enabled property.
     IAppHostProperty* enabledAttribute = NULL;
     hr = pDemoSection->GetPropertyByName( L"enabled", &enabledAttribute );

     VARIANT boolValue;
     VariantInit( &boolValue );
      
     //Get the value to a variant variable.
     hr = enabledAttribute->get_Value( &boolValue );
     //Get the specific value from within the VARIANT structure.
     bool enabled = boolValue.boolVal;
      
     //Set the message value that will be returned to the user based on whether the enabled attribute is set or not.
     
     if (enabled)
     //do something
     else
     //do something else

    Hope that helps, OscarGS

    Thursday, September 14, 2006 5:36 PM
  • User-1202834629 posted

    Thank you very much for that code example.  I'm having difficulty getting the g_pHttpServer.  It seems that you have to get it through the exported RegisterModule function.  I'm looking at the beta walkthroughs for that:

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/IIS_70_WebExtSDK/html/175190d6-4f32-4813-8ffd-458c79d708e4.asp

    Is there another way to get pHttpServer?  I just want to write native code that sets the default document.  I don't want to have to add the dll to the list of modules for the server.

    Wednesday, September 20, 2006 3:00 PM
  • User-1202834629 posted

    Just FYI, I continued this question here:

    http://forums.iis.net/1409553/ShowThread.aspx#1409553

    Monday, September 25, 2006 3:23 PM