Friday, August 27, 2004

Unloading an ISAPI dll from IIS

I got this snippet from the borland.public.delphi.internet.isapi-webbroker newsgroup - a simple way to unload an ISAPI dll programmatically:
WSite, WServer, WRoot: Variant;
WSite := CreateOleObject('IISNamespace');
WSite := WSite.GetObject('IIsWebService', 'localhost/w3svc');
WServer := WSite.GetObject('IIsWebServer', '1');
WRoot := WServer.GetObject('IIsWebVirtualDir', 'Root');
This works on XP - I didn't even know you could create an OLE object with "IISNamespace". But you can. Anyhow, in the WSite.GetObject call you see a "1" - if you're wondering what that is, it's the number given to a web site by IIS. You can get the numbers of all your websites through Adsi - import the Ads type library and use the code from ADSI paper like this:
var serv : IADSContainer;
varArr : OleVariant;
lNumElements : ULong;
obj : IADs;
hr : integer;
// list web sites
AdsGetObject('IIS://localhost/w3svc',IAdsContainer, serv) ; hr := ADsBuildEnumerator(serv,e);
while(Succeeded(Hr)) do
hr := ADsEnumerateNext(e,1,
varArr ,lNumElements);
if (lNumElements=0) then
IDispatch(varArr).QueryInterface(IADs, obj);
if obj<>nil then
if obj.Class_ = 'IIsWebServer' then
// obj.Name contains the "number" you need.
obj := nil;
varArr := NULL;
//don't call ADsFreeEnumerator(e); //since e will be released by Delphi
You can use ADSI to do a ton of things.


TOndrej said...

Interesting, but doesn't stopping the server already unload all DLLs?

Anonymous said...

However mean your gold in wow life is,buy wow gold meet it and live it ;wow gold cheap do not shun it and call it hard names.It is not so bad as you are.It looks poorest when you are richest.The fault-finder will find faults in gold kaufen love your life,poor as it is.maple meso You may perhaps have some pleasant,thrilling,maplestory power leveling glorious hourss,even in a poor-house.The setting sun is reflected from the windows of the alms-house as brightly as from the rich man's abode;the snow melts before its door as early in the spring.sell wow gold I do not see but a quiet mind may live as contentedly there,cheap mesos and have as cheering thoughts,as in a palace.The town's poor seem to me often to live the most independent lives of any.May be they are simply great enough to billig wow gold receive without misgiving.Most think that they are above being supported by the town;powerlevel but it often happens that buy maplestory mesos they are not above supporting themselves by dishonest means.which should be more disreputable.Cultivate poverty like a garden herb,like sage.Do not trouble wow powerleveln yourself much to get new things,maple mesos whether clothes or friends

Adi said...

Oes Tsetnoc one of the ways in which we can learn seo besides Mengembalikan Jati Diri Bangsa. By participating in the Oes Tsetnoc or Mengembalikan Jati Diri Bangsa we can improve our seo skills. To find more information about Oest Tsetnoc please visit my Oes Tsetnoc pages. And to find more information about Mengembalikan Jati Diri Bangsa please visit my Mengembalikan Jati Diri Bangsa pages. Thank you So much.

ambersbridal said...

A holy church, rings, a bouquet, a 3-floor wedding cake, lace wedding dress champagne, and the moving promise “ I do”, make up the happiest moment in one’s life. Then it is the wedding.
lace wedding gowns
A gorgeous wedding dress has been inside a girl’s dream since she was five years old. It is widely said that the bride is the most beautiful woman all over the world.
Bridal gowns vary in different parts of the world. For example, cheap wedding dresses plus sizein traditional Chinese culture, the color red is regarded for centuries as the symbol of good luck; while in the Occident, wedding dresses 2012 a full-length white wedding dress is always associated with romance and sanctity. But, with the globalization, wedding dresses tend to be alike in the whole world.