Hello Coding-Friends !
How to list files an directorys withiut cheap api-commands ?
I want to make a own file browser. - Some DOCS or so ?
Bye !
How to list files an directorys withiut cheap api-commands ?
I want to make a own file browser. - Some DOCS or so ?
Bye !
Cheap API commands? There are expensive ones?
Yeah, it depends whether you bought your Windows copy or not... :grin:
Under Win32 you cant do that without APIs, except you use interrupts, but that would be... well.. stupid because it has no advantage.
Here's one with expensive API commands (i.e. with COM) it doesn't work 100% because I pretty much gave up and decided to use the "Cheap" ones. All the docs you need are at MSDN, look for IShellFolder
PS: Don't ask me to explain how this works, it is long and complicated and you have to grasp COM :)
PS: Don't ask me to explain how this works, it is long and complicated and you have to grasp COM :)
FreePIDL Proc PIDL:DWORD
LOCAL pMalloc :DWORD
invoke SHGetMalloc,ADDR pMalloc
push PIDL
push pMalloc
mov edx,pMalloc
mov edx,[edx]
call DWORD PTR [edx+20] ;IMalloc.Free
push pMalloc
mov edx,pMalloc
mov edx,[edx]
call DWORD PTR [edx+8] ; IMalloc:Release
ret
FreePIDL endp
GetPIDLFromPath proc hWnd:DWORD,pszObject:DWORD
LOCAL pShellFolder :DWORD
LOCAL wsz[MAX_PATH] :WORD
LOCAL Attribs :DWORD
LOCAL Pidl[32] :DWORD
LOCAL Eaten :DWORD
invoke MultiByteToWideChar,CP_ACP,NULL,pszObject,-1,ADDR wsz,MAX_PATH
invoke SHGetDesktopFolder,ADDR pShellFolder
lea eax,Attribs
push eax
lea eax,Pidl
push eax
lea eax,Eaten
push eax
lea eax,wsz
push eax
push NULL
push hWnd
push pShellFolder
mov edx,pShellFolder
mov edx,[edx]
call DWORD PTR [edx+12] ; IShellFolder::ParseDisplayName
push pShellFolder
mov edx,pShellFolder
mov edx,[edx]
call DWORD PTR [edx+8] ; IShellFolder::Release
mov eax,Pidl
ret
GetPIDLFromPath endp
EnumeratePath proc hWnd:DWORD,PIDL:DWORD
LOCAL pShellFolder :DWORD
LOCAL pShellSubFolder :DWORD
LOCAL pEnumFolder :DWORD
LOCAL pIDL :DWORD
LOCAL pMalloc :DWORD
LOCAL Fetched :DWORD
LOCAL sfi :SHFILEINFO
LOCAL sfs :SHELLFLAGSTATE
jmp @F
ExtShown db "Extensions Shown",0
ExtNotShown db "Extensions Not Shown",0
@@:
invoke SHGetSettings,ADDR sfs,SSF_SHOWEXTENSIONS
.IF sfs && MASK fShowExtensions
PrintString ExtShown
.ELSE
PrintString ExtNotShown
.endif
invoke SHGetMalloc,ADDR pMalloc
push 512
push pMalloc
mov edx,pMalloc
mov edx,[edx]
call DWORD PTR [edx+12]
mov pIDL,eax
invoke SHGetDesktopFolder,ADDR pShellFolder
lea eax,pShellSubFolder
push eax
lea eax,IID_IShellFolder
push eax
push NULL
push PIDL
push pShellFolder
mov edx,pShellFolder
mov edx,[edx]
call DWORD PTR [edx+20] ; IShellFolder::BindToObject
.IF eax != NOERROR
push pShellFolder
mov edx,pShellFolder
mov edx,[edx]
call DWORD PTR [edx+8] ; IShellFolder::Release
ret
.ENDIF
lea eax,pEnumFolder
push eax
push SHCONTF_NONFOLDERS
push hWnd
push pShellSubFolder
mov edx,pShellSubFolder
mov edx,[edx]
call DWORD PTR [edx+16] ; IShellFolder::EnumObjects
@@:
lea eax,Fetched
push eax
lea eax,pIDL
push eax
push 20
push pEnumFolder
mov edx,pEnumFolder
mov edx,[edx]
call DWORD PTR [edx+12] ; IEnumIDList:Next
push eax
cmp eax,NOERROR
jne @F
invoke SHGetFileInfo,pIDL,NULL,ADDR sfi,SIZEOF SHFILEINFO,SHGFI_PIDL or SHGFI_DISPLAYNAME
.IF eax == NULL
jmp @F
.endif
invoke SHGetPathFromIDList,PIDL,ADDR szBuffer
invoke lstrlen,ADDR szBuffer
lea esi,szBuffer
mov [esi+eax],BYTE PTR "\"
mov [esi+eax+1],BYTE PTR 0
invoke lstrcat,ADDR szBuffer,ADDR sfi.szDisplayName
; Your file name is in szBuffer
jmp @B
@@:
push pIDL
push pMalloc
mov edx,pMalloc
mov edx,[edx]
call DWORD PTR [edx+20] ; IMalloc.Free
push pMalloc
mov edx,pMalloc
mov edx,[edx]
call DWORD PTR [edx+8] ; IMalloc:Release
push pEnumFolder
mov edx,pEnumFolder
mov edx,[edx]
call DWORD PTR [edx+8] ; IEnumIDList::Release
push pShellSubFolder
mov edx,pShellSubFolder
mov edx,[edx]
call DWORD PTR [edx+8] ; IShellFolder::Release
push pShellFolder
mov edx,pShellFolder
mov edx,[edx]
call DWORD PTR [edx+8] ; IShellFolder::Release
ret
EnumeratePath endp
Oh BTW you will need these as well,
invoke CoInitialize,NULL at the start of your prog and invoke CoUninitialize at the end
.const
sIID_IShellFolder TEXTEQU <{0000214E6H, 00000H, 00000H, \
{0C0H, 000H, 000H, 000H, 000H, 000H, 000H, 046H}}>
sIID_IMalloc TEXTEQU <{000000002H, 00000H, 00000H, \
{0C0H, 000H, 000H, 000H, 000H, 000H, 000H, 046H}}>
.data
IID_IShellFolder GUID sIID_IShellFolder
IID_IMalloc GUID sIID_IMalloc
Be sure to :
invoke CoInitialize,NULL at the start of your prog and invoke CoUninitialize at the end
Have it ever occured to you, that search function on this board is worth learning with everything else your learning?
If you invest some time in the FAQ's, you would not need to be asking such basic questions.
I hope by now, you have also mastered the techniques of using a public search engine of your choice.
Not to mention the M$ knowledge base. I will add, you do have to learn to convert the examples from VB or C to MASM. I remember the days, when C was a fancy librarian to MASM.
Learning is also about maturing your style & techniques, as well as your knowledge.
I want to encourage you in a well rounded approach to learning your craft.
Regards, P1
If you invest some time in the FAQ's, you would not need to be asking such basic questions.
I hope by now, you have also mastered the techniques of using a public search engine of your choice.
Not to mention the M$ knowledge base. I will add, you do have to learn to convert the examples from VB or C to MASM. I remember the days, when C was a fancy librarian to MASM.
Learning is also about maturing your style & techniques, as well as your knowledge.
I want to encourage you in a well rounded approach to learning your craft.
Regards, P1
Don't get too discouraged by how much work is involved to execute what seems to be a simple function in High Level Languages. Just remember that at some point or another each function in an HLL was written from a library that consists of ASM procedures. The thing you've got yourself into is that now there are no huge libraries of routines that mask the actual work involved in doing even the simplest things. That is both the price and the reward of ASM.
MSDN library should be your first point of reference at all times, they wrote the book on the API (no really they did) hell, they wrote the API :). When you diddle around for a while and are still stuck then search here, chances are that someone has already asked the exact same thing you need to know. If that doesn't work because it is a new question (unlikely) or because you just can't find it, then post your question.
In this instance, do you seriously believe that nobody in the history of the board has ever had to list all the files in a folder, just search for "list files" and you will find 151 entries !
MSDN library should be your first point of reference at all times, they wrote the book on the API (no really they did) hell, they wrote the API :). When you diddle around for a while and are still stuck then search here, chances are that someone has already asked the exact same thing you need to know. If that doesn't work because it is a new question (unlikely) or because you just can't find it, then post your question.
In this instance, do you seriously believe that nobody in the history of the board has ever had to list all the files in a folder, just search for "list files" and you will find 151 entries !
How to list files an directorys withiut cheap api-commands ?
Perhaps he wants to do something silly along parsing the file system structure himself?