How does one use the IShellFolder funtions? I saw that you need to SHGetDesktopFolder to get the adress to it but how does one then use the functions? Anyone have any examples? Thanks in advance. Bye
You need include files with the defines of the interface.
The shobjidl.sdk have it .
there is about a thousand of interfaces translated in the "ready to use sdk"
http://www.masm32.com/board/index.php?topic=8542.msg62123#msg62123
The translation follow a rule to name all things.
If the interface is named IShellFolder:
You must create a dword in data named ppvIShellFolder
invoke SHGetDesktopFolder
put the value in ppvIShellFolder
It's finish.You can now use all the functions of the interfce as normal API with just a little difference
The name of the interface replace invoke (IShellFolder is a macro who call invoke)
IShellFolder Release
Sample of use:
http://www.masm32.com/board/index.php?topic=17108.msg145524#msg145524
Thanks a lot Tout.... I'm looking into it. Praise M32 Forum.
I've seen how u do it however am having trouble so went searching for another mo. I found a shlobj.inc by Bill T. I has an enormous amount of conflicts so i had to make another include with only the declarations in needed. However, for the IShellFolder.GetDisplayNameOf, i found that the prototype has an extra dword and theres an AddRef and Query and unknown declarations in the IShellFolder Struct that are undefined symbols. I tried to change using dwords but the prog crashes. I'm going backk to your rtuSDK. Thanks
i found that windows.inc and shlobj structure declaration are bit different ( no significantelly ) but enough for ml to error. It gives non-benign strucutre redefs.
For examplle
SHITEMID STRUCT [color=Blue]in windows.inc[/color]
cb dw ?
abID db 1 dup(?)
S...ENDS
SHITEMID struct DWORD[color=Orange] in shlobj.inc[/color]
cb WORD ?
abID BYTE ?
SHITEMID ends
I wonder if there's actually a shlobj.inc that goes along with masm's windows.inc that is distributed. Thanks
it may be that the constants and structures are missing
or, it may be that the constants and structures are defined, but the prototypes are missing :P
you may not have much luck if you search for "shlobj.inc"
try searching for "shlobj.h", instead - the C-equivalent of an INC file
and - you might try Andreas' WinInc package...
http://www.japheth.de/WinInc.html
well dave.... there are slight differences in the structures declarations between windows.inc and shlobj.inc. Some are only of the sort:
SHITEMID Struct DWORD
cb WORD ?
abID BYTE ?
SH.... ENDS
and
in windows.inc
SHITEMID struct
cb dw ?
abID db 1 dup(?)
SH... ENDS
I fixed part and then proceeded to remove from shlobj those that were already in windows.inc. I'm not so sure anymore that such differences can turn into error.
Anyway there's a part of shlobj that goes:
IShellFolder struct DWORD
QueryInterface IUnknown_QueryInterface ?
AddRef IUnknown_AddRef ?
Release IUnknown_Release ?
...it errors on this reporting syntax error. Do you know how to fix this.... i'm getting desperate with this interfaces stuff. Thanks
Also, some protos differ from what's shown in API Ref. For example IShellFolder.GetDisplayNameOf has a :DWORD defore the ITEMIDLIST. I'm sure that there's a logical reason for this other than a careless mistake. I found two shlobj that look the same.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms680509%28v=vs.85%29.aspx
QueryInterface, AddRef, and Release appear to be functions (not data types) - defined in Unknwn.h
this is all COM stuff :P
not for the faint of heart
structure definitions need an ENDS line, as well...
IShellFolder struct DWORD
IShellFolder ends
http://svn.assembla.com/svn/fragzone_lps/Project/TGE_1_5_2/lib/MSPlatformSDK/Include/Unknwn.h
beyond that - better gets someone that knows COM :P
Donkey or maybe baltoro can help
yes... my heart is week for now... but not long ago it was weaker... yes they're all functions. what's strange is that IUnknow_Addref is like this wierd macro. Where it appears that IUnknown is a GUID and AddRef should represent the function. Well, i'm not so sure about what i just said. Just takle a look
; IShellFolder
;-------------------------------------------------------------------------------------------------
SHGDN_NORMAL equ 0
SHGDN_INFOLDER equ 1
SHGDN_FORPARSING equ 8000h
SHCONTF_FOLDERS equ 32
SHCONTF_NONFOLDERS equ 64
SHCONTF_INCLUDEHIDDEN equ 128
SFGAO_CANCOPY equ DROPEFFECT_COPY
SFGAO_CANMOVE equ DROPEFFECT_MOVE
SFGAO_CANLINK equ DROPEFFECT_LINK
SFGAO_CANRENAME equ 00000010h
SFGAO_CANDELETE equ 00000020h
SFGAO_HASPROPSHEET equ 00000040h
SFGAO_DROPTARGET equ 00000100h
SFGAO_CAPABILITYMASK equ 00000177h
SFGAO_LINK equ 00010000h
SFGAO_SHARE equ 00020000h
SFGAO_READONLY equ 00040000h
SFGAO_GHOSTED equ 00080000h
SFGAO_DISPLAYATTRMASK equ 000F0000h
SFGAO_FILESYSANCESTOR equ 10000000h
SFGAO_FOLDER equ 20000000h
SFGAO_FILESYSTEM equ 40000000h
SFGAO_HASSUBFOLDER equ 80000000h
SFGAO_CONTENTSMASK equ 80000000h
SFGAO_VALIDATE equ 01000000h
SFGAO_REMOVABLE equ 02000000h
LPSHELLFOLDER typedef DWORD
LPPSHELLFOLDER typedef DWORD
IShellFolder_ParseDisplayNameProto typedef proto :DWORD, :DWORD, :DWORD, :DWORD, :DWORD, :LPPENUMIDLIST, :DWORD
IShellFolder_EnumObjectsProto typedef proto :DWORD, :DWORD, :DWORD, :LPPENUMIDLIST
IShellFolder_BindToObjectProto typedef proto :DWORD, :LPITEMIDLIST, :DWORD, :DWORD, :DWORD
IShellFolder_BindToStorageProto typedef proto :DWORD
IShellFolder_CompareIDsProto typedef proto :DWORD, :DWORD, :LPITEMIDLIST, :LPITEMIDLIST
IShellFolder_CreateViewObjectProto typedef proto :DWORD, :DWORD, :DWORD, :DWORD
IShellFolder_GetAttributesOfProto typedef proto :DWORD, :DWORD, :LPITEMIDLIST, :DWORD
IShellFolder_GetUIObjectOfProto typedef proto :DWORD, :DWORD, :DWORD, :LPPITEMIDLIST, :DWORD, :DWORD, :DWORD
IShellFolder_GetDisplayNameOfProto typedef proto :DWORD, :LPITEMIDLIST, :DWORD, :LPSTRRET
IShellFolder_SetNameOfProto typedef proto :DWORD, :DWORD, :LPITEMIDLIST, :DWORD, :DWORD, :LPPITEMIDLIST
IShellFolder_ParseDisplayName typedef ptr IShellFolder_ParseDisplayNameProto
IShellFolder_EnumObjects typedef ptr IShellFolder_EnumObjectsProto
IShellFolder_BindToObject typedef ptr IShellFolder_BindToObjectProto
IShellFolder_BindToStorage typedef ptr IShellFolder_BindToStorageProto
IShellFolder_CompareIDs typedef ptr IShellFolder_CompareIDsProto
IShellFolder_CreateViewObject typedef ptr IShellFolder_CreateViewObjectProto
IShellFolder_GetAttributesOf typedef ptr IShellFolder_GetAttributesOfProto
IShellFolder_GetUIObjectOf typedef ptr IShellFolder_GetUIObjectOfProto
IShellFolder_GetDisplayNameOf typedef ptr IShellFolder_GetDisplayNameOfProto
IShellFolder_SetNameOf typedef ptr IShellFolder_SetNameOfProto
IShellFolder struct DWORD
QueryInterface IUnknown_QueryInterface ?
AddRef IUnknown_AddRef ?
Release IUnknown_Release ?
ParseDisplayName IShellFolder_ParseDisplayName ?
EnumObjects IShellFolder_EnumObjects ?
BindToObject IShellFolder_BindToObject ?
BindToStorage IShellFolder_BindToStorage ?
CompareIDs IShellFolder_CompareIDs ?
CreateViewObject IShellFolder_CreateViewObject ?
GetAttributesOf IShellFolder_GetAttributesOf ?
GetUIObjectOf IShellFolder_GetUIObjectOf ?
GetDisplayNameOf IShellFolder_GetDisplayNameOf ?
SetNameOf IShellFolder_SetNameOf ?
IShellFolder ends
;-------------------------------------------------------------------------------------------------
; Guids and Clsids
externdef CLSID_ShellDesktop:IID
externdef CLSID_ShellLink:IID
externdef IID_IUnknown:IID
externdef IID_IContextMenu:IID
externdef IID_IShellExtInit:IID
externdef IID_IShellPropSheetExt:IID
externdef IID_IExtractIcon:IID
externdef IID_IShellLink:IID
externdef IID_IShellCopyHook:IID
externdef IID_IFileViewerSite:IID
externdef IID_IFileViewer:IID
externdef IID_IEnumIDList:IID
externdef IID_IShellFolder:IID
I sudenlly realised that the release AddRef and Query functions are common to all interfaces and the reason its IUnknow is that IUnknow represents a variable address depending on which interfce you're using. I suppose its like this right?
I'm still having a hard time understanding how to make it work.
Why would the protos have an extra :dword on top?
Quote from: xandaz on October 29, 2011, 11:01:18 PM
Why would the protos have an extra :dword on top?
object pointer? (
this-pointer)
function pointer :P
i seem to recall something about function "vector" tables
somehow, you get a pointer to the table, then call functions by index - something like that
the extra dword may be the table base address
search the forum for "com example" or similar
Tout has some examples but he uses that ready to use sdk which makes things even more complicated.
that may be the way to go (after all - it's ready to use :bg )
he probably understands it very well
but, he speaks French - maybe you guys could use google translate and get a dialogue going :P
i often have a hard time understanding what he is up to
Erol gives you a way to go...
http://www.masm32.com/board/index.php?topic=9913.msg72724#msg72724
they also have a manual install version of masm32 v9, intended for win9x
not sure if it has the COM stuff, though
http://www.oby.ro/masm32/m32v9r_legacy.zip
It's not problem of language,the sdk translate don't speak french.
The interfaces have an usage more simple than the old com stuf who used a complex set of macros and who are not debugged.
To use the interfaces of the sdk translate you must know how to use an API,no more thing is needed,after you have got the pointer.
If you don't know how to use an api,you can't use an interface.
Seem it is the case for xandaz.
A simple way to use them with windows.inc is to copy the needed declaration in an include file.
Here the part to copy:
Quote
STIShellFolder STRUCT
QueryInterface comethod3 ?
AddRef comethod1 ?
Release comethod1 ?
ParseDisplayName comethod7 ?
EnumObjects1 comethod4 ?
BindToObject comethod5 ?
BindToStorage comethod5 ?
CompareIDs comethod4 ?
CreateViewObject comethod4 ?
GetAttributesOf comethod4 ?
GetUIObjectOf comethod7 ?
GetDisplayNameOf comethod4 ?
SetNameOf comethod6 ?
STIShellFolder ENDS
IShellFolder MACRO Function:REQ, args:VARARG
; definition de la macro locale InvokeInterface
LOCAL InvokeInterface, arg
FOR arg, <args> ;verifier que edx n'est pas dans la liste d'arguments args
IFIDNI <&arg>, <edx> ;
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
ENDM
IFIDNI <&pInterface>, <edx>
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
;InvokeInterface = concatene ...CATSTR(concatene) MACRO instruction MASM32
InvokeInterface CATSTR <invoke (STIShellFolder PTR[edx]).>,<&Function,ppvIShellFolder>
IFNB <args> ; add the list of parameter arguments if any
InvokeInterface CATSTR InvokeInterface, <, >, <&args>
ENDIF
; forme les lignes de codes
mov edx, ppvIShellFolder
mov edx, [edx]
InvokeInterface
ENDM
Here the part who defines the comethod
Quote
pcomethod1 TYPEDEF PROTO :DWORD
pcomethod2 TYPEDEF PROTO :DWORD, :DWORD
pcomethod3 TYPEDEF PROTO :DWORD, :DWORD, :DWORD
pcomethod4 TYPEDEF PROTO :DWORD, :DWORD, :DWORD, :DWORD
pcomethod5 TYPEDEF PROTO :DWORD, :DWORD, :DWORD, :DWORD , :DWORD
pcomethod6 TYPEDEF PROTO :DWORD, :DWORD, :DWORD, :DWORD , :DWORD ,:DWORD
pcomethod7 TYPEDEF PROTO :DWORD, :DWORD, :DWORD, :DWORD , :DWORD ,:DWORD ,:DWORD
pcomethod8 TYPEDEF PROTO :DWORD, :DWORD, :DWORD, :DWORD , :DWORD ,:DWORD ,:DWORD ,:DWORD
pcomethod9 TYPEDEF PROTO :DWORD, :DWORD, :DWORD, :DWORD , :DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD
pcomethod10 TYPEDEF PROTO :DWORD, :DWORD, :DWORD, :DWORD , :DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD
pcomethod11 TYPEDEF PROTO :DWORD, :DWORD, :DWORD, :DWORD , :DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD,:DWORD
pcomethod12 TYPEDEF PROTO :DWORD, :DWORD, :DWORD, :DWORD , :DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD,:DWORD,:DWORD
pcomethod13 TYPEDEF PROTO :DWORD, :DWORD, :DWORD, :DWORD , :DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD,:DWORD,:DWORD,:DWORD
pcomethod14 TYPEDEF PROTO :DWORD, :DWORD, :DWORD, :DWORD , :DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD ,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD
comethod1 TYPEDEF PTR pcomethod1
comethod2 TYPEDEF PTR pcomethod2
comethod3 TYPEDEF PTR pcomethod3
comethod4 TYPEDEF PTR pcomethod4
comethod5 TYPEDEF PTR pcomethod5
comethod6 TYPEDEF PTR pcomethod6
comethod7 TYPEDEF PTR pcomethod7
comethod8 TYPEDEF PTR pcomethod8
comethod9 TYPEDEF PTR pcomethod9
comethod10 TYPEDEF PTR pcomethod10
comethod11 TYPEDEF PTR pcomethod11
comethod12 TYPEDEF PTR pcomethod12
comethod13 TYPEDEF PTR pcomethod13
comethod14 TYPEDEF PTR pcomethod14
I can write the code for you but I can help you any more.
Just one more thing,use of the function who interest you is described here:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb775071(v=vs.85).aspx
As i have already explain,get the pointer on IShellFolder,put the value in ppvIShellFolder (dd)
use the function:
IShellFolder GetDisplayNameOf,pidl,flags,addr strret (strret STRRET <>)
You need a function to translate the path in a pidl.This function is given in the sample i have pointed for you.
I understood what you have explained. I was just wondering why shlobj has an extra :DWORD in the IShellFolder Prototypes. I used Push and then call ppvIShellFolder.GetDisplayNameOf but it crashes. You said you cant help anymore? can you take a look at the code? i'll supply the includes also. Thanks toutenmasm. And also i unserstand french. After all i'm portuguese. You're just two countries away and we're all latin-derived.
I have added the needed declare and corrected the syntax for IShellFolder.
asm compile ok,now.(This not grant he is working)
The ressource need some files to compile.
sorry.... i know that this seems stupid and i'd like to thanks you for the help....i'm not used to macros. How do i call a macro? I tried IShelllFolder,GetDisplayNameOf,addr pIDL,SHGDN_NORMAL,addr strret. Didn't work. Syntax error
It was already written,anyway:
You use the macro exactly as an invoke,it's an invoke .
Quote
;corrected syntax
IShelllFolder GetDisplayNameOf,pIDL,SHGDN_NORMAL,addr strret
Did you put a , just after an invoke ? NO
pIDL and SHGDN_NORMAL are value passed without addr
oh yes pIDL is a memory opperand that the pointer to the ITEMIDLIST, ... correct. I had the impression that macros calls were always done like
someMacro(arg1,...argn)
Thanks for the correction.
Thanks teach...i'm on the right path now.
Hail M32!!!