procedure TForm1.Button1Click(Sender: TObject);
var
RegODBC:TRegistry;
registerTemp : TRegistry;
SysPath: array [0..255] of char;
begin
RegODBC:=TRegistry.create; //訪問注冊表
RegODBC.RootKey:=HKEY_LOCAL_MacHINE;
RegODBC.OpenKey('SYSTEMControlSet001ServicesW3SVCParametersVirtual Roots',True);
getsystemdirectory(SysPath,255);
if regodbc.ValueExists('/fire') then
begin
suimessage1.Text:='本機WEB已存在名為fire的虛擬目錄。'+#13#10+'請將此fire刪除或重命名。';
suimessage1.IconType:=suistop;
suimessage1.ButtonCount:=1;
suimessage1.Caption:='錯誤';
if suimessage1.ShowModal=mrok then
winexec(pchar(SysPath+'inetsrvinetmgr.exe'),sw_shownormal);
exit;
end
else
begin
registerTemp := TRegistry.Create; //建立一個Registry實例
with registerTemp do
begin
RootKey:=HKEY_LOCAL_MACHINE;//設置根鍵值為HKEY_LOCAL_MacHINE
//找到或創建SYSTEMControlSet001ServicesW3SVCParametersVirtual Roots,寫入IIS配置信息
if OpenKey('SYSTEMControlSet001ServicesW3SVCParametersVirtual Roots',True) then
begin
WriteString('/fire','E:fire,,205');
end
else//創建鍵值失敗
begin
suimessage1.Text:='IIS配置失敗,本程序即將關閉。'+#13#10+'關閉後請先檢查Internet服務管理器,排除錯誤或安裝後再運行本程序。';
suimessage1.IconType:=suistop;
suimessage1.ButtonCount:=1;
suimessage1.Caption:='錯誤';
if suimessage1.ShowModal=mrok then
application.Terminate ;
end;
CloseKey;
Free;
end;
end;
RegODBC.Free;
end;
說明:代碼中用到了suipack4控件的suimessagedialog組件,例子的確認窗口也可通過Application.MessageBox()來替代。如大家對此有興趣的話可以與我聯系。[email protected] QQ:49055028