unit raiis;
inte***ce
uses
sysutils, classes, comobj, windows;
type
traiis = class(tcomponent)
private
fondeletevirtualdir: tnotifyevent;
foncreatevirtualdir: tnotifyevent;
protected
public
constructor create(aowner: tcomponent); override;
function checkdotnetframework: boolean;
function deletevirtualdir(strvirtualdir: string): boolean;
function checkvirtualdir(const strvirtualdir: string): boolean;
published
property ondeletevirtualdir: tnotifyevent read fondeletevirtualdir write fondeletevirtualdir;
property oncreatevirtualdir: tnotifyevent read foncreatevirtualdir write foncreatevirtualdir;
end;
procedure register;
implementation
procedure register;
begin
registercomponents('rarnu components', [traiis]);
end;
function traiis.checkdotnetframework: boolean;
varsysdir: pchar;
begin
getmem(sysdir, 250);
getsystemdirectory(sysdir, 250);
ifnot fileexists(sysdir + '/mscoree.dll') then
result := false
else
result := true;
freemem(sysdir);
end;
function traiis.checkvirtualdir(const strvirtualdir: string): boolean;
varwebsite, webserver, webroot: variant;
begin
result := true;
trywebsite := createoleobject('iisnamespace');
website := website.getobject('iiswebservice', 'localhost/w3svc');
webserver := website.getobject('iiswebserver', '1');
webroot := webserver.getobject('iiswebvirtualdir', 'root');
webroot.getobject('iiswebvirtualdir', strvirtualdir);
except
result := false;
end;
end;
constructor traiis.create(aowner: tcomponent);
begin
inherited create(aowner);
end;
function traiis.createvirtualdir(const strvirtualdir, strdir,
varwebsite, webserver, webroot, vdir: variant;
begin
result := true;
trywebsite := createoleobject('iisnamespace');
website := website.getobject('iiswebservice', 'localhost/w3svc');
webserver := website.getobject('iiswebserver', '1');
webroot := webserver.getobject('iiswebvirtualdir', 'root');
vdir := webroot.create('iiswebvirtualdir', strvirtualdir);
vdir.accessread := true;
vdir.accessscript := true; //執行許可為純指令碼
vdir.defaultdoc := 'index.aspx,index.asp'; //預設文件
vdir.enabledirbrowsing := false;
vdir.path := strdir;
vdir.setinfo;
except
result := false;
end;
if assigned(oncreatevirtualdir) then
oncreatevirtualdir(self);
end;
function traiis.deletevirtualdir(strvirtualdir: string): boolean;
varwebsite, webserver, webroot: variant;
begin
result := true;
trywebsite := createoleobject('iisnamespace');
website := website.getobject('iiswebservice', 'localhost/w3svc');
webserver := website.getobject('iiswebserver', '1');
webroot := webserver.getobject('iiswebvirtualdir', 'root');
webroot.delete('iiswebvirtualdir', strvirtualdir);
except
result := false;
end;
if assigned(ondeletevirtualdir) then
ondeletevirtualdir(self);
end;
varwebsite, webserver, webroot, vdir: variant;
begin
result := true;
trywebsite := createoleobject('iisnamespace');
website := website.getobject('iiswebservice', 'localhost/w3svc');
webserver := website.getobject('iiswebserver', '1');
webroot := webserver.getobject('iiswebvirtualdir', 'root');
vdir := webroot.getobject('iiswebvirtualdir', strvirtualdir);
vdir.setinfo;
except
result := false;
end;
end;
end.
Delphi對ini檔案的操作
一 ini檔案的結構 注釋 小節名 關鍵字 值 ini檔案允許有多個小節,每個小節又允許有多個關鍵字,後面是該關鍵字的值。值的型別有三種 字串 整型數值和布林值。其中字串存貯在ini檔案中時沒有引號,布林真值用1表示,布林假值用0表示。注釋以分號 開頭。二 定義 1 在inte ce的uses節增加...
delphi對ini檔案的操作
定義 1 在inte ce的uses節增加inifiles 2 在var變數定義部分增加一行 myinifile tinifile 開啟ini檔案 myinifile tinifile.create program.ini 當地 filename extractfilepath paramstr 0...
Delphi對INI檔案的詳細操作方法
ini檔案在系統配置及應用程式引數儲存與設定方面,具有很重要的作用,delphi為我們提供了乙個tinifile類,以便我們可以非常靈活的處理ini檔案。一 ini檔案的結構 注釋語句 小節名1 關鍵字1 值1 關鍵子2 值2 小節名2 關鍵字1 值1 關鍵子2 值2 ini檔案允許有多個小節,每個...