COMインターフェースを構造体から呼び出す
Posted: 2006年5月31日(水) 13:28
COMインターフェースの呼び出しを行うのに通常はクラスを使用して呼び出しますが、
クラスの代わりに構造体を使用して呼び出すことは可能でしょうか?
試しでIShellLinkのインターフェースを取得してみたつもりなんですけど、
DebugしてもShellLinkの後半のアドレスが取得できてないようで・・・。
どこか根本的に間違っていますでしょうか?
クラスの代わりに構造体を使用して呼び出すことは可能でしょうか?
試しでIShellLinkのインターフェースを取得してみたつもりなんですけど、
DebugしてもShellLinkの後半のアドレスが取得できてないようで・・・。
どこか根本的に間違っていますでしょうか?
[ここをクリックすると内容が表示されます]
クラスを使えばすぐ済むかもしれませんが、クラスがなんとなく嫌いなもので。コード: 全て選択
#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
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
TypeDef IShellLink=*_IShellLink
'##### 本体 #####
Dim psl As IShellLink
If CoInitialize(0)=S_OK Then
If CoCreateInstance(CLSID_ShellLink,0,CLSCTX_INPROC_SERVER,IID_IShellLink,VarPtr(psl))=S_OK Then
psl->Release()
End If
CoUninitialize()
End If
End