by ノッチ » 2006年5月31日(水) 15:57
少し先に進んだんで自己レスです。
CoCreateInstanceで取得したアドレスは、関数構造体(っていうのかな?)への
ポインタへのポインタらしく構造体を参照する構造体を宣言することで対応しました。
ですが、QueryInterfaceやReleaseがうまく動いてくれないです。
関数アドレスの取得はうまくいっているように見えるのですが。。。
[ここをクリックすると内容が表示されます] [ここをクリックすると非表示にします]コード: 全て選択
#STRICT
Type SHITEMID
cb As Word
abID[0] As Byte
End Type
Type ITEMIDLIST
mkid As SHITEMID
End Type
Type PITEMIDLIST
pmkid As *ITEMIDLIST
End Type
Dim CLSID_ShellLink =[&H00021401,&H0000,&H0000,[&HC0,&H00,&H00,&H00,&H00,&H00,&H00,&H46]] As GUID
Dim IID_IShellLink =[&H000214EE,&H0000,&H0000,[&HC0,&H00,&H00,&H00,&H00,&H00,&H00,&H46]] As GUID
Dim IID_IPersistFile =[&H0000010B,&H0000,&H0000,[&HC0,&H00,&H00,&H00,&H00,&H00,&H00,&H46]] As GUID
Type _IPersistFile
QueryInterface As *Function(ByRef iid As GUID,ppvObject As *DWord) As Long
AddRef As *Function() As DWord
Release As *Function() As DWord
GetClassID As *Function(pClassID As VoidPtr) As Long
IsDirty As *Function() As Long
Load As *Function(pszFileName As *Byte,dwMode As DWord) As Long
Save As *Function(pszFileName As *Byte,fRemember As BOOL) As Long
SaveCompleted As *Function(pszFileName As *Byte) As Long
GetCurFile As *Function(ppszFileName As **Byte) As Long
End Type
Type IPersistFile
i As *_IPersistFile
End Type
Type _IShellLink
QueryInterface As *Function(ByRef iid As GUID,ppvObject As *DWord) As Long
AddRef As *Function() As DWord
Release As *Function() As DWord
GetPath As *Function(pszFile As *Byte,cchMaxPath As Long,ByRef fd As WIN32_FIND_DATA,fFlags As DWord) As Long
GetIDList As *Function(ByRef ppidl As PITEMIDLIST)
SetIDList As *Function(ByRef pidl As ITEMIDLIST)
GetDescription As *Function(pszName As *Byte,cchMaxName As Long)
SetDescription As *Function(pszName As *Byte)
GetWorkingDirectory As *Function(pszDir As *Byte,cchMaxPath As Long)
SetWorkingDirectory As *Function(pszDir As *Byte)
GetArguments As *Function(pszArgs As *Byte,cchMaxPath As Long)
SetArguments As *Function(pszArgs As *Byte)
GetHotkey As *Function(pwHotkey As *Word)
SetHotkey As *Function(wHotkey As Word)
GetShowCmd As *Function(piShowCmd As *Long)
SetShowCmd As *Function(iShowCmd As Long)
GetIconLocation As *Function(pszIconPath As *Byte,cchIconPath As Long,piIcon As *Long)
SetIconLocation As *Function(pszIconPath As *Byte,iIcon As Long)
SetRelativePath As *Function(pszPathRel As *Byte)
Resolve As *Function(ByRef pidlRel As ITEMIDLIST)
SetPath As *Function(pszFile As BytePtr)
End Type
Type IShellLink
i As *_IShellLink
End Type
'---------------------------------------------------------------
Dim psl As *IShellLink
Dim ppf As *IPersistFile
If CoInitialize(0)=S_OK Then
If CoCreateInstance(CLSID_ShellLink,0,CLSCTX_INPROC_SERVER,IID_IShellLink,VarPtr(psl))=S_OK Then
If psl->i->QueryInterface(IID_IPersistFile,VarPtr(ppf))=S_OK Then
debug
ppf->i->Release()
End If
psl->i->Release()
End If
CoUninitialize()
End If
End
最終的にはショートカットを作成しようとしているのですが、どうすればよいでしょうか?
少し先に進んだんで自己レスです。
CoCreateInstanceで取得したアドレスは、関数構造体(っていうのかな?)への
ポインタへのポインタらしく構造体を参照する構造体を宣言することで対応しました。
ですが、QueryInterfaceやReleaseがうまく動いてくれないです。
関数アドレスの取得はうまくいっているように見えるのですが。。。
[hide][code]#STRICT
Type SHITEMID
cb As Word
abID[0] As Byte
End Type
Type ITEMIDLIST
mkid As SHITEMID
End Type
Type PITEMIDLIST
pmkid As *ITEMIDLIST
End Type
Dim CLSID_ShellLink =[&H00021401,&H0000,&H0000,[&HC0,&H00,&H00,&H00,&H00,&H00,&H00,&H46]] As GUID
Dim IID_IShellLink =[&H000214EE,&H0000,&H0000,[&HC0,&H00,&H00,&H00,&H00,&H00,&H00,&H46]] As GUID
Dim IID_IPersistFile =[&H0000010B,&H0000,&H0000,[&HC0,&H00,&H00,&H00,&H00,&H00,&H00,&H46]] As GUID
Type _IPersistFile
QueryInterface As *Function(ByRef iid As GUID,ppvObject As *DWord) As Long
AddRef As *Function() As DWord
Release As *Function() As DWord
GetClassID As *Function(pClassID As VoidPtr) As Long
IsDirty As *Function() As Long
Load As *Function(pszFileName As *Byte,dwMode As DWord) As Long
Save As *Function(pszFileName As *Byte,fRemember As BOOL) As Long
SaveCompleted As *Function(pszFileName As *Byte) As Long
GetCurFile As *Function(ppszFileName As **Byte) As Long
End Type
Type IPersistFile
i As *_IPersistFile
End Type
Type _IShellLink
QueryInterface As *Function(ByRef iid As GUID,ppvObject As *DWord) As Long
AddRef As *Function() As DWord
Release As *Function() As DWord
GetPath As *Function(pszFile As *Byte,cchMaxPath As Long,ByRef fd As WIN32_FIND_DATA,fFlags As DWord) As Long
GetIDList As *Function(ByRef ppidl As PITEMIDLIST)
SetIDList As *Function(ByRef pidl As ITEMIDLIST)
GetDescription As *Function(pszName As *Byte,cchMaxName As Long)
SetDescription As *Function(pszName As *Byte)
GetWorkingDirectory As *Function(pszDir As *Byte,cchMaxPath As Long)
SetWorkingDirectory As *Function(pszDir As *Byte)
GetArguments As *Function(pszArgs As *Byte,cchMaxPath As Long)
SetArguments As *Function(pszArgs As *Byte)
GetHotkey As *Function(pwHotkey As *Word)
SetHotkey As *Function(wHotkey As Word)
GetShowCmd As *Function(piShowCmd As *Long)
SetShowCmd As *Function(iShowCmd As Long)
GetIconLocation As *Function(pszIconPath As *Byte,cchIconPath As Long,piIcon As *Long)
SetIconLocation As *Function(pszIconPath As *Byte,iIcon As Long)
SetRelativePath As *Function(pszPathRel As *Byte)
Resolve As *Function(ByRef pidlRel As ITEMIDLIST)
SetPath As *Function(pszFile As BytePtr)
End Type
Type IShellLink
i As *_IShellLink
End Type
'---------------------------------------------------------------
Dim psl As *IShellLink
Dim ppf As *IPersistFile
If CoInitialize(0)=S_OK Then
If CoCreateInstance(CLSID_ShellLink,0,CLSCTX_INPROC_SERVER,IID_IShellLink,VarPtr(psl))=S_OK Then
If psl->i->QueryInterface(IID_IPersistFile,VarPtr(ppf))=S_OK Then
debug
ppf->i->Release()
End If
psl->i->Release()
End If
CoUninitialize()
End If
End[/code][/hide]
最終的にはショートカットを作成しようとしているのですが、どうすればよいでしょうか?