TIWAppInfo   //IntraWeb 12.2.15 开始使用 TIWAppInfo 来获取应用的相关信息, 和 IWServerController、WebApplication 的某些属性有重复
TIWMimeTypes //IntraWeb 14.0.11 新增, 可方便处理 Http Mime Types; Mime 类型? 我的理解是: 浏览器接受到一个文件或数据流, 如果让浏览器解析(而不是下载), 浏览器该按什么类型来解析呢? 所以需要指定类型.
TIWAppCache //IntraWeb 14.0.29 新增, 可以方便处理缓存文件; 之前有类似的功能, 如: IWServerController.NewCacheFile {三个类提供的都是 class 方法, 使用时无须实例化}

TIWAppInfo 所在单元及继承链:
IW.Common.AppInfo.TIWAppInfo

主要成员:


class function GetAppFullFileName: string
class function GetAppFileName: string
class function GetAppLogFileName: string
class function GetAppPath: string
class function GetAppName: string
class function GetSystemPath: string
class function GetTempPath: string
class function GetCurrentPath: string
class function GetComputerName: string
class function GetFileInfo(const aFileName: string; aFileInfo: TFileInfo): string
class function GetAppVersion: string

测试:


uses IW.Common.AppInfo;

procedure TIWForm1.IWButton1Click(Sender: TObject);
var
str: string;
i: Integer;
begin
IWMemo1.Lines.Add(TIWAppInfo.GetAppFullFileName);
IWMemo1.Lines.Add(TIWAppInfo.GetAppFileName);
IWMemo1.Lines.Add(TIWAppInfo.GetAppLogFileName);
IWMemo1.Lines.Add(TIWAppInfo.GetAppPath);
IWMemo1.Lines.Add(TIWAppInfo.GetAppName);
IWMemo1.Lines.Add(TIWAppInfo.GetSystemPath);
IWMemo1.Lines.Add(TIWAppInfo.GetTempPath);
IWMemo1.Lines.Add(TIWAppInfo.GetCurrentPath);
IWMemo1.Lines.Add(TIWAppInfo.GetComputerName);
IWMemo1.Lines.Add(TIWAppInfo.GetAppVersion);
IWMemo1.Lines.Add('==============='); for i := 0 to 9 do
begin
str := TIWAppInfo.GetFileInfo(TIWAppInfo.GetSystemPath + 'NotePad.exe', TFileInfo(i));
IWMemo1.Lines.Add(str);
end;
IWMemo1.Lines.Add('===============');
end;

TIWMimeTypes 所在单元及继承链:
IWMimeTypes.TIWMimeTypes

主要成员:


class function IsStaticFile(const aFileName: string; out aMimeType: string): Boolean //
class function GetAsString(const aFileExtension: string): string //根据扩展名即可获取类型的标准字符串很方便, 譬如 TIWMimeTypes.GetAsString('.pdf') 将返回 application/pdf
class function GetAsString(const aMimeType: TMimeType): string //TIWMimeTypes.GetAsString(mtPDF) 结果也是 application/pdf
class procedure RegisterType(const aFileExtension: string; const aMimeTypeDesc: string; const aIsStatic: Boolean) //能自行注册
class procedure UnregisterType(const aFileExtension: string) // {IWMimeTypes.TIWMimeType 枚举的定义}
TIWMimeType = (mtUnknown, mtBinary, mtJPG, mtGIF, mtPNG, mtRSS, mtXML, mtTXT, mtICO, mtHTML, mtJavaScript, mtPDF, mtZIP, mtCSS, mtMP3, mtOGG, mtWAV, mtEXE, mtFlash, mtWMV, mtMOV, mtAVI, mtMPEG, mtXSL); {IWMimeTypes 单元提供的常用的 Mime 类型常量}
MIME_JPG = 'image/jpeg';
MIME_GIF = 'image/gif';
MIME_PNG = 'image/png';
MIME_RSS = 'application/rss+xml; charset=UTF-8';
MIME_XML = 'text/xml; charset=UTF-8';
MIME_XSL = 'text/xsl; charset=UTF-8';
MIME_TXT = 'text/plain; charset=UTF-8';
MIME_ICO = 'image/x-ico';
MIME_JavaScript = 'application/x-javascript; charset=UTF-8';
MIME_PDF = 'application/pdf';
MIME_CSS = 'text/css; charset=UTF-8';
MIME_MP3 = 'audio/mpeg';
MIME_OGG = 'audio/ogg';
MIME_WAV = 'audio/wav';
MIME_Flash = 'application/x-shockwave-flash';
MIME_WMV = 'video/x-ms-wmv';
MIME_MOV = 'video/quicktime';
MIME_AVI = 'video/x-msvideo';
MIME_MPEG = 'video/mpeg';
MIME_Binary = 'application/octet-stream';
MIME_HTML = 'text/html; charset=UTF-8'; { 更多不常用的类型可参见: http://www.iana.org/assignments/media-types/media-types.xhtml }

TIWAppCache 所在单元及继承链:
IWAppCache.TIWAppCache

主要成员:


{建立缓存流; 如需特别指定第一个参数时, 不如选用下面三个函数}
class procedure NewCacheStream(aOwner: TObject; //建立页面级的缓存要指定当前窗体(一般用 Self); 建立 Session 级缓存可指定 WebApplication; 建立应用级缓存指定 nil
const aContentType: string; //Mime Type 字符串, 如: application/pdf
aCacheType: TCacheType; //缓存期选项:ctOneTime、ctApp、ctSession、ctForm
out ACacheStream: TCacheStream; //输出流
out aFileHRef: string //输出缓存文件地址
)
{建立建立应用级缓存流; 参数 1 将被忽略, 其它同上}
class procedure NewAppCacheStream(aOwner: TObject; const aContentType: string; out ACacheStream: TCacheStream; out aFileHRef: string) {建立建立 Session 级缓存流; 参数 1 将被忽略, 其它同上}
class procedure NewSessionCacheStream(aOwner: TObject; const aContentType: string; out ACacheStream: TCacheStream; out aFileHRef: string) {建立建立页面级缓存流; 参数 1 将被忽略, 其它同上}
class procedure NewFormCacheStream(aOwner: TObject; const aContentType: string; out ACacheStream: TCacheStream; out aFileHRef: string) {保存流到缓存文件}
class function StreamToCacheFile(aOwner: TObject; AStream: TStream; const aContentType: string; const aCacheType: TCacheType): string {保存图像到缓存文件}
class function GraphicToCacheFile(aOwner: TObject; AGraphic: TGraphic; const aCacheType: TCacheType; const PreferPNG: Boolean): string
class function GraphicToCacheFile(aOwner: TObject; AGraphic: TGraphic; imgType: TIWImageOutput; const aCacheType: TCacheType): string //TIWImageOutput = (ioGIF, ioJPEG, ioPNG) {保存资源到缓存文件}
class function ResourceToCacheFile(aOwner: TObject; const aResourceName: string; const aContentType: string; const aCacheType: TCacheType): string {情况缓存}
class function ClearCache(ACacheList: TStrings): Integer {创建一个临时文件, 位置在用户临时文件夹}
class function NewTempFileName: string {添加文件到缓存}
class function AddFileToCache(aOwner: TObject; const aFileName: string; const aContentType: string; const aCacheType: TCacheType): string

测试 - 将资源中的图片提取到缓存, 然后呈现出来:


uses IWAppCache, IWServerInternalFiles;

procedure TIWForm1.IWButton1Click(Sender: TObject);
var
fStream: TStream;
fPath: string;
begin
fStream := TIWServerInternalFiles.GetResourceStream('IW_GFX_LogoIntraWeb');
fPath := TIWAppCache.StreamToCacheFile(Self, fStream, 'image/png');
IWImageFile1.ImageFile.Filename := fPath;
fStream.Free;
end;

常用路径:


{获取代码:-------------------------------------------------------}
uses ServerController, IW.Common.AppInfo; procedure TIWForm1.IWAppFormCreate(Sender: TObject);
begin
IWMemo1.Lines.Add(IWServerController.ContentPath + #9'{IWServerController.ContentPath}');
IWMemo1.Lines.Add(IWServerController.CacheDir + #9'{IWServerController.CacheDir}');
IWMemo1.Lines.Add(IWServerController.TemplateDir + #9'{IWServerController.TemplateDir}' + sLineBreak); IWMemo1.Lines.Add(WebApplication.AppUrlBase + #9'{WebApplication.AppUrlBase}');
IWMemo1.Lines.Add(WebApplication.InternalUrlBase + #9'{WebApplication.InternalUrlBase}');
IWMemo1.Lines.Add(WebApplication.SessionInternalUrlBase + #9'{WebApplication.SessionInternalUrlBase}');
IWMemo1.Lines.Add(WebApplication.SessionUrlBase + #9'{WebApplication.SessionUrlBase}');
IWMemo1.Lines.Add(WebApplication.UserCacheUrlBase + #9'{WebApplication.UserCacheUrlBase}');
IWMemo1.Lines.Add(WebApplication.ApplicationURL + #9'{WebApplication.ApplicationURL}');
IWMemo1.Lines.Add(WebApplication.ApplicationPath + #9'{WebApplication.ApplicationPath}');
IWMemo1.Lines.Add(WebApplication.ReferringURL + #9'{WebApplication.ReferringURL}');
IWMemo1.Lines.Add(WebApplication.UserCacheDir + #9'{WebApplication.UserCacheDir}' + sLineBreak); IWMemo1.Lines.Add(TIWAppInfo.GetAppFullFileName + #9'{TIWAppInfo.GetAppFullFileName}');
IWMemo1.Lines.Add(TIWAppInfo.GetAppPath + #9'{TIWAppInfo.GetAppPath}');
IWMemo1.Lines.Add(TIWAppInfo.GetAppFileName + #9'{TIWAppInfo.GetAppFileName}');
IWMemo1.Lines.Add(TIWAppInfo.GetAppName + #9'{TIWAppInfo.GetAppName}');
IWMemo1.Lines.Add(TIWAppInfo.GetTempPath + #9'{TIWAppInfo.GetTempPath}');
IWMemo1.Lines.Add(TIWAppInfo.GetCurrentPath + #9'{TIWAppInfo.GetCurrentPath}');
end; {参考结果:-------------------------------------------------------} C:\Users\wy\Documents\RAD Studio\Projects\MyTest6\Win32\Debug\wwwroot\ {IWServerController.ContentPath}
C:\Users\wy\AppData\Local\Temp\01a3ozdw6r\ {IWServerController.CacheDir}
C:\Users\wy\Documents\RAD Studio\Projects\MyTest6\Win32\Debug\Templates\ {IWServerController.TemplateDir} / {WebApplication.AppUrlBase}
/$/ {WebApplication.InternalUrlBase}
/$/ {WebApplication.SessionInternalUrlBase}
/ {WebApplication.SessionUrlBase}
/$/MyApp/0pnlkje0r4hi7j19tzrq30eq0k2i/ {WebApplication.UserCacheUrlBase}
http://127.0.0.1:3126 {WebApplication.ApplicationURL}
C:\Users\wy\Documents\RAD Studio\Projects\MyTest6\Win32\Debug\ {WebApplication.ApplicationPath}
http://127.0.0.1:3126/$/start {WebApplication.ReferringURL}
C:\Users\wy\AppData\Local\Temp\01a3ozdw6r\user\0pnlkje0r4hi7j19tzrq30eq0k2i\ {WebApplication.UserCacheDir} C:\Users\wy\Documents\RAD Studio\Projects\MyTest6\Win32\Debug\MyTest6.exe {TIWAppInfo.GetAppFullFileName}
C:\Users\wy\Documents\RAD Studio\Projects\MyTest6\Win32\Debug\ {TIWAppInfo.GetAppPath}
MyTest6.exe {TIWAppInfo.GetAppFileName}
MyTest6 {TIWAppInfo.GetAppName}
C:\Users\wy\AppData\Local\Temp\ {TIWAppInfo.GetTempPath}
C:\Users\wy\Documents\RAD Studio\Projects\MyTest6\Win32\Debug\ {TIWAppInfo.GetCurrentPath}

使用 IntraWeb (30) - TIWAppInfo、TIWMimeTypes、TIWAppCache的更多相关文章

  1. IntraWeb XIV 类型速查表

    tkClass ================== IWUserSessionBase.TIWUserSessionBase < TDataModule < TComponent < ...

  2. 使用 IntraWeb (45) - 活用 IntraWeb

    asp.net 刚开始时, 也是拖拉控件, 但后来有了 MVC.xNext. 换个思路使用 IntraWeb 吧: 界面全部用 html+js+css 实现(有些会是用 Delphi 动态生成), 然 ...

  3. 总结30个CSS3选择器

    或许大家平时总是在用的选择器都是:#id  .class  以及标签选择器.可是这些还远远不够,为了在开发中更加得心应手,本文总结了30个CSS3选择器,希望对大家有所帮助. 1 *:通用选择器 ;; ...

  4. 值得收藏!国外最佳互联网安全博客TOP 30

    如果你是网络安全从业人员,其中重要的工作便是了解安全行业的最新资讯以及技术趋势,那么浏览各大安全博客网站或许是信息来源最好的方法之一.最近有国外网站对50多个互联网安全博客做了相关排名,小编整理其中排 ...

  5. CSharpGL(30)用条件渲染(Conditional Rendering)来提升OpenGL的渲染效率

    CSharpGL(30)用条件渲染(Conditional Rendering)来提升OpenGL的渲染效率 当场景中有比较复杂的模型时,条件渲染能够加速对复杂模型的渲染. 条件渲染(Conditio ...

  6. 30分钟学会XAML

    1.狂妄的WPF 相对传统的Windows图形编程,需要做很多复杂的工作,引用许多不同的API.例如:WinForm(带控件表单).GDI+(2D图形).DirectX API(3D图形)以及流媒体和 ...

  7. Shell脚本编程30分钟入门

    Shell脚本编程30分钟入门 转载地址: Shell脚本编程30分钟入门 什么是Shell脚本 示例 看个例子吧: #!/bin/sh cd ~ mkdir shell_tut cd shell_t ...

  8. ViEmu 3.6.0 过期 解除30天限制的方法

    下载:链接: http://pan.baidu.com/s/1c2HUuWw 密码: sak8 删除下面2个地方 HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{B9CDA4 ...

  9. AlloyTouch全屏滚动插件发布--30秒搞定顺滑H5页

    原文链接:https://github.com/AlloyTeam/AlloyTouch/wiki/AlloyTouch-FullPage-Plugin 先验货 插件代码可以在这里找到. 注意,虽然是 ...

随机推荐

  1. elasticsearch5.0集群大数据量迁移方法及注意事项

    当es集群的数据量较小的情况下elasticdump这个工具比较方便,但是当数据量达到一定级别比如上百G的时候,elasticdump速度就很慢了,此时我们可以使用快照的方法进行备份 elasticd ...

  2. windows系统实现mysql数据库数据库主从复制

    环境: master mysql服务器 192.168.8.201 slave mysql服务器 192.168.8.89 目标: 实现主从复制 1.将MySQL5.5安装文件分别拷贝到两台机器的c盘 ...

  3. 基于url拦截

  4. Ex 6_12 凸多边形的最优三角剖分..._第六次作业

    假设顶点的总数为n,从0到n-1. 从序号为0的顶点开始以逆时针方向排序,对于 令子问题A[i,j]为包含顶点i,i+1, . . . j的凸多边形的最小三角剖分代价,dist(i,j)为顶点i到顶点 ...

  5. Node.js ECONNREFUSED错误

    1 现象 node服务器 遇见此错误,如下:events.js:71throw arguments[1]; // Unhandled 'error' event^Error: connect ECON ...

  6. 基于python的k-s值计算

    做评分卡模型时(假设有多个自变量,因变量即是否违约.)通常需要筛选变量. k-s值的作用类似于AUC,它期初是用来评价模型(变量)对是否违约事件的区分程度的. # -*- coding: utf-8 ...

  7. 一次TIME_WAIT和CLOSE_WAIT故障和解决办法

    昨天解决了一个curl调用错误导致的服务器异常,具体过程如下: 里头的分析过程有提到,通过查看服务器网络状态检测到服务器有大量的CLOSE_WAIT的状态. 在服务器的日常维护过程中,会经常用到下面的 ...

  8. Http请求中请求头Content-Type讲解

    在Http请求中,我们每天都在使用Content-type来指定不同格式的请求信息,但是却很少有人去全面了解content-type中允许的值有多少,这里将讲解Content-Type的可用值 Med ...

  9. ie6 表格td中无内容时不显示边框的解决办法

    1.在单元格中加入一个空格.这样: <td> </td> 2.直接在table里这样写:<table border="0" cellspacing=& ...

  10. All about the “paper”

    博采众长吧,看到有用的就记下来,提醒自己,方便他人. 1.good idea. 写论文,good idea很重要 2.看论文. 网友经验:看论文学知识的效率远比看书要快的多,很多人在刚开始看论文的时候 ...