建立的目录实质上在磁盘是不可见的,是不是要划分一块内存空间出来?
请教一下  
谢谢

解决方案 »

  1.   

    建立IIS虚拟目录的例子:unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, ComObj, IISOle_TLB, ActiveDs_TLB;type
      TForm1 = class(TForm)
        Button1: TButton;
        Button2: TButton;
        Button3: TButton;
        Button4: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
        procedure Button3Click(Sender: TObject);
        procedure Button4Click(Sender: TObject);
      private
        { Private declarations }
        function CreateIISVirtualPath(MapPath:String;Path:String):Boolean;
        function SetIISRootPathParam:Boolean;
        function KillIISPath(MapPath:String):Boolean;
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      function ADsGetObject(const PathName: WideString; const GUID: TGUID; out I: IUnknown): HRESULT; stdcallimplementationfunction ADsGetObject;external 'activeds.dll' name 'ADsGetObject'{$R *.DFM}function TForm1.CreateIISVirtualPath(MapPath:String;Path:String):Boolean;
    var
     I: IADsContainer;
     ADs: IADs;
    begin
     Result:=false;
     try
      if ADsGetObject('IIS://localhost/w3svc', IID_IADsContainer, IUnknown(I)) = S_Ok then
       begin
        ADs := IADs(I.GetObject('IIsWebServer','1'));
        i:=ADs as IADsContainer;
        ADs := I.GetObject('IIsWebVirtualDir','Root') as IADs;
        i:=ADs as IADsContainer;
        ADs := I.Create('IIsWebVirtualDir',MapPath) as IADs;
        ADs.Put('AccessRead','True');
        ADs.Put('AccessScript','True');
        ADs.Put('AccessExecute','True');
        file://modify by liguang in 2001-7-8 comeback from shengzhen
        file://if operating system is WINDOWS NT4.0+IIS4.0 then this call is error
        ADs.Put('AccessSource','True');
        ADs.Put('Path',Path);
        ADs.SetInfo;
        Result:=true;
       end;
     except
     end;
    end;function TForm1.SetIISRootPathParam:Boolean;
    var
     I: IADsContainer;
     ADs: IADs;
    begin
     Result:=false;
     try
      if ADsGetObject('IIS://localhost/w3svc', IID_IADsContainer, IUnknown(I)) = S_Ok then
       begin
        ADs := IADs(I.GetObject('IIsWebServer','1'));
        i:=ADs as IADsContainer;
        ADs := I.GetObject('IIsWebVirtualDir','Root') as IADs;
        ADs.Put('AccessRead','True');
        ADs.Put('AccessScript','True');
        ADs.Put('AccessExecute','True');
        ADs.Put('AccessSource','True');
        ADs.SetInfo;
        Result:=true;
       end;
     except
     end;
    end;function TForm1.KillIISPath(MapPath:String):Boolean;
    var
     I: IADsContainer;
     ADs: IADs;
    begin
     Result:=false;
     if MapPath='Root' then
      exit;
     try
      if ADsGetObject('IIS://localhost/w3svc', IID_IADsContainer, IUnknown(I)) = S_Ok then
       begin
        ADs := IADs(I.GetObject('IIsWebServer','1'));
        i:=ADs as IADsContainer;
        ADs := I.GetObject('IIsWebVirtualDir','Root') as IADs;
        i:=ADs as IADsContainer;
        ADs := I.GetObject('IIsWebVirtualDir',MapPath) as IADs;
        i.Delete(ADs.Get_Schema,ADs.get_Name);
        Result:=true;
       end;
     except
     end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
     if CreateIISVirtualPath('WebUser','E:\VC')=true then
      MessageBox(GetforegroundWindow,'建立成功!','提示信息',MB_OK)
     else
         MessageBox(GetforegroundWindow,'建立失败!','提示信息',MB_OK);
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
     if SetIISRootPathParam=true then
      MessageBox(GetforegroundWindow,'修改成功!','提示信息',MB_OK)
     else
         MessageBox(GetforegroundWindow,'修改失败!','提示信息',MB_OK);
    end;procedure TForm1.Button3Click(Sender: TObject);
    begin
     if SetIISRootPathParam=true then
      MessageBox(GetforegroundWindow,'修改成功!','提示信息',MB_OK)
     else
         MessageBox(GetforegroundWindow,'修改失败!','提示信息',MB_OK);
     if CreateIISVirtualPath('WebUser','E:\VC')=true then
      MessageBox(GetforegroundWindow,'建立成功!','提示信息',MB_OK)
     else
         MessageBox(GetforegroundWindow,'建立失败!','提示信息',MB_OK);
    end;procedure TForm1.Button4Click(Sender: TObject);
    begin
     if KillIISPath('WebUser')=true then
      MessageBox(GetforegroundWindow,'删除成功!','提示信息',MB_OK)
     else
         MessageBox(GetforegroundWindow,'删除失败!','提示信息',MB_OK);
    end;end.
      

  2.   

    呵呵,不是要建立IIS虚拟目录,是想具体的实现一个虚拟文件夹,在里面创建文件,进行读写,其实文件也是虚拟的,也就是说这些东西只有在自己的系统里面才能看见。而实际上创建的这个系统的整个文件体系在windows下面应该只是一个2进制文件。我想应该是不是要分配一些空间来实现这个文件的存储,搞了几天了,没有什么头绪。
      

  3.   

    API:
    IStorage and IStream