Y
youou
Unregistered / Unconfirmed
GUEST, unregistred user!
接口中的方法不是要通过过类来实现吗?可是我怎么在delphi中只看到定义接口,没有发现delphi通过类来实现,而我也用得好好的?别见笑..进来瞧瞧..(100分)<br />比如在这个ShlObj单元中..
定义了好多接口...我都没有看到他的实现..
而我们在用的时候就要以这样:
use ShlObj;
function CreateLink( AsAppName : String ; AsCmdLine : string ;
AsShortcutName : string ;
AsDescription : string ) : boolean ;
IfUnknown : IUnknown ;
IfShellLnk : IShellLink ;
IfPersistFile : IPersistFile;
sFileName : String ;
sFilePath : string ;
sLnkExt : string ;
sDirectory : String ;
WsFileName : WideString;
Reg : TRegIniFile;
begin
result := true ;
//create a com object
IfUnknown := CreateComObject(CLSID_ShellLink);
// cast the IUnknown interface to a IShellLink
IfShellLnk := IfUnknown as IShellLink;
// cast the IUnknown interface to a IPersistFile
IfPersistFile := IfUnknown as IPersistFile;
sFileName := AsAppName ;
sFilePath := ExtractFilePath( sFileName ) ;
// using the Interface to the Shell link call some of
// it's methods.
with IfShellLnk do
begin
setArguments( PChar(AsCmdLine) ) ;
setPath( PChar(sFileName) ) ;
setWorkingDirectory( PChar(sFilePath) ) ;
setDescription( PChar(AsDescription) ) ;
end ;
...
==============
就拿..IShellLink 接口中的 setArguments 方法来说吧...?我怎么在ShlObj单元中没有发现它的实现呢?----还是在别的地方..?
嘻~~别见笑...
定义了好多接口...我都没有看到他的实现..
而我们在用的时候就要以这样:
use ShlObj;
function CreateLink( AsAppName : String ; AsCmdLine : string ;
AsShortcutName : string ;
AsDescription : string ) : boolean ;
IfUnknown : IUnknown ;
IfShellLnk : IShellLink ;
IfPersistFile : IPersistFile;
sFileName : String ;
sFilePath : string ;
sLnkExt : string ;
sDirectory : String ;
WsFileName : WideString;
Reg : TRegIniFile;
begin
result := true ;
//create a com object
IfUnknown := CreateComObject(CLSID_ShellLink);
// cast the IUnknown interface to a IShellLink
IfShellLnk := IfUnknown as IShellLink;
// cast the IUnknown interface to a IPersistFile
IfPersistFile := IfUnknown as IPersistFile;
sFileName := AsAppName ;
sFilePath := ExtractFilePath( sFileName ) ;
// using the Interface to the Shell link call some of
// it's methods.
with IfShellLnk do
begin
setArguments( PChar(AsCmdLine) ) ;
setPath( PChar(sFileName) ) ;
setWorkingDirectory( PChar(sFilePath) ) ;
setDescription( PChar(AsDescription) ) ;
end ;
...
==============
就拿..IShellLink 接口中的 setArguments 方法来说吧...?我怎么在ShlObj单元中没有发现它的实现呢?----还是在别的地方..?
嘻~~别见笑...