我在看一个取wallpaper以及设置其快捷方式的程序中看到如下代码:
IShellLink* pISL;
IPersistFile* pIPF;
// Create a COM object from the Shell Link coclass.
hr = CoCreateInstance ( CLSID_ShellLink,
NULL,
CLSCTX_INPROC_SERVER,
IID_IShellLink,
(void**) &pISL );
if ( SUCCEEDED(hr) )
{
// Set the path of the target file (the wallpaper).
hr = pISL->SetPath ( sWallpaper );
if ( SUCCEEDED(hr) )
{
// Get an IPersisteFile interface from the COM object.
hr = pISL->QueryInterface ( IID_IPersistFile, (void**) &pIPF );
问题:
为什么不直接去得到pIPF?
一定先要得到IShellLink的指针pISL才可以得到pIPF吗?
IShellLink* pISL;
IPersistFile* pIPF;
// Create a COM object from the Shell Link coclass.
hr = CoCreateInstance ( CLSID_ShellLink,
NULL,
CLSCTX_INPROC_SERVER,
IID_IShellLink,
(void**) &pISL );
if ( SUCCEEDED(hr) )
{
// Set the path of the target file (the wallpaper).
hr = pISL->SetPath ( sWallpaper );
if ( SUCCEEDED(hr) )
{
// Get an IPersisteFile interface from the COM object.
hr = pISL->QueryInterface ( IID_IPersistFile, (void**) &pIPF );
问题:
为什么不直接去得到pIPF?
一定先要得到IShellLink的指针pISL才可以得到pIPF吗?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货