Use Delphi to create an IIS's virtual directory by writing registry!

xiaoxiao2021-03-06  87

There are a lot of examples on the virtual directory of Delphi to create IIS, but they need to load class libraries. I use the write registry to implement, the method is simple, mainly do not need to join the complex process, unique Differently, you need to restart your computer to take effect. code show as below:

procedure TForm1.Button1Click (Sender: TObject); var RegODBC: TRegistry; registerTemp: TRegistry; SysPath: array [0..255] of char; begin RegODBC: = TRegistry.create; // accessing the registry RegODBC.RootKey: = HKEY_LOCAL_MACHINE ; RegODBC.OpenKey ( '/ SYSTEM / ControlSet001 / Services / W3SVC / Parameters / Virtual Roots', True); getsystemdirectory (sysPath, 255); if regodbc.ValueExists (' / fire ') then begin suimessage1.Text: =' present The machine Web has a virtual directory called Fire. ' # 13 # 10 ' Please delete or rename this fire. '; Suimessage1.IconType: = suistop; suimessage1.ButtonCount: = 1; suimessage1.Caption: =' Error '; if suimessage1.ShowModal = mrok then winexec (pchar (SysPath ' / inetsrv / inetmgr.exe '), sw_shownormal); EXIT; END ELSE BEGIN registertemp: = Tregistry.create; // Create a registry instance with registertemp do begin rootkey: = hkey_local_machine; // Set the root key value is hkey_local_machine

// Find or create / system / controlset001 / services / w3svc / parameters / server ROOTS, write IIS configuration information if Openkey ('/ system / controlset001 / services / w3svc / parameters / virtual roots "THEN BEGIN WRITESTRING (' / Fire ',' E: / Fire ,, 205 '); END ELSE // Creating a key value failed Begin SuiMessage1.Text: =' IIS configuration failed, this program is about to close. After ' # 13 # 10 ' After shutting down, please check the Internet Service Manager, troubleshoot the error or install. '; Suimessage1.IconType: = suistop; suimessage1.ButtonCount: = 1; suimessage1.Caption: =' Error '; if suimessage1.ShowModal = mrok then application.Terminate; end; CloseKey; Free; end; end; RegODBC.Free; END; Description: The SuiMessageDialog component of the SuiPack4 control is used in the code. The confirmation window of the example can also be replaced by Application.MessageBox (). If you are interested in this, you can contact me. XH416@163.net QQ: 49055028

转载请注明原文地址:https://www.9cbs.com/read-122696.html

New Post(0)