用DELPHI實現PIF文件的建立修改(200分)

  • 主题发起人 主题发起人 abchjb
  • 开始时间 开始时间
A

abchjb

Unregistered / Unconfirmed
GUEST, unregistred user!
本人想在 Win95下用DELPHI建立一DOS程序的.PIF<br>並對其一些特性作修改.但對PIFMGR.DLL知道較少,<br>請各位指教.thanks!
 
pif在win95里面似乎已经不太支持了,用"快捷方式"(*.lnk)吧!
 
95对 PIF 的生成没有提供支持,但提供使用的兼容。<br>LNK 的方式提供很好的控制方案,值得提倡。<br>此方面的内容可以在本站找找,很容易找到。
 
确实没有找到创建方法:-(
 
本人正是用.lnk來實現,可怎樣才能用ISHELLLINK<br>控制如字型,顯示...等選項?
 
先了解PIF的文件格式,以后的事就好办啦。
 
在delphi的Help-&gt; win32 programer's refrence里面,用关键字"ISHELLLINK"<br>进行查找,全在里面了!!<br>不过,关于字体设置,这可不是每个Lnk能管理的,而是windows下的那个"MS-DOS方式"<br>来进行管理的,是统一的.
 
使用IShellLink来创建快捷方式?下面是现成得代码:<br>procedure CreateLnk(sFileName, sLink:string; pchDes : LPSTR);<br>var<br>&nbsp; psl : IShellLink;<br>&nbsp; ppf: &nbsp;IPersistFile;<br>&nbsp; pchBuf : array[0..1024] of Char;<br>&nbsp; wch: array[0..1024] of WideChar;<br>begin<br>&nbsp; try<br>&nbsp; &nbsp;OleCheck(CoCreateInstance(CLSID_ShellLink, nil, LSCTX_INPROC_SERVER, IID_IShellLink, psl)); //Get the IShellLink Interface<br>&nbsp; &nbsp;<br>&nbsp; &nbsp;try<br>&nbsp; &nbsp; OleCheck(psl.QueryInterface(IID_IPersistFile, ppf)); //Get the IPersistFile Interface<br>&nbsp; &nbsp; OleCheck(psl.SetDescription(pchDes)); //LNK file's description<br>&nbsp; &nbsp; StrPCopy(pchBuf, sFileName); &nbsp;//Set the original file name<br>&nbsp; &nbsp; OleCheck(psl.SetPath(pchBuf));<br>&nbsp; &nbsp; StrPCopy(pchBuf, sLink);<br>&nbsp; &nbsp; MultiByteToWideChar(CP_ACP, 0, pchBuf, -1, wch, 1024);<br>&nbsp; &nbsp; OleCheck(ppf.Save(wch, True));<br>&nbsp; &nbsp;finally<br>&nbsp; &nbsp; ppf.Release;<br>&nbsp; &nbsp;end;<br>&nbsp; finally<br>&nbsp; &nbsp;psl.Release;<br>&nbsp; end;<br>end;<br>这个程序在结束时会产生一个异常,我还没有仔细检查,但是估计用接口的包装类(Wrapper Class)来代替接口本身会更好一些.
 
现在程序正常了:<br>procedure CreateLnk(sFileName, sLink:string; pchDes : LPSTR);var<br>&nbsp; psl : IShellLink; &nbsp;<br>&nbsp; ppf: &nbsp;IPersistFile; &nbsp;<br>&nbsp; pchBuf : array[0..1024] of Char;<br>&nbsp; wch: array[0..1024] of WideChar;<br>begin &nbsp;<br>&nbsp; try<br>&nbsp; &nbsp; psl := CreateComObject(CLSID_ShellLink) As IShellLink;<br>&nbsp; &nbsp; //Get the IShellLink Interface<br>&nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; &nbsp; ppf := psl As IPersistFile;<br>&nbsp; &nbsp; &nbsp; &nbsp; //Get the IPersistFile Interface<br>&nbsp; &nbsp; &nbsp; &nbsp; OleCheck(psl.SetDescription(pchDes)); //LNK file's description<br>&nbsp; &nbsp; &nbsp; &nbsp; StrPCopy(pchBuf, sFileName); &nbsp;//Set the original file name<br>&nbsp; &nbsp; &nbsp; &nbsp; OleCheck(psl.SetPath(pchBuf)); &nbsp; &nbsp;StrPCopy(pchBuf, sLink);<br>&nbsp; &nbsp; &nbsp; &nbsp; MultiByteToWideChar(CP_ACP, 0, pchBuf, -1, wch, 1024);<br>&nbsp; &nbsp; &nbsp; &nbsp; OleCheck(ppf.Save(wch, True));<br>&nbsp; &nbsp; &nbsp; finally &nbsp; &nbsp;<br>&nbsp; &nbsp; &nbsp; &nbsp; ppf := nil;<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; finally<br>&nbsp; &nbsp; &nbsp; psl := nil;<br>&nbsp; &nbsp; end;<br>end;
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
1K
DelphiTeacher的专栏
D
后退
顶部