Page 1 of 1

Question about Prototypes and calling a function

Posted: Fri Apr 05, 2019 4:57 pm
by jacky
Hi,

I want to be able to call this function from shell32.dll: SHParseDisplayName
https://docs.microsoft.com/en-us/window ... isplayname

I'm trying it like this and the program crashes when I execute it :oops:

Code: Select all

Prototype.i ProtoSHParseDisplayName(pszName.p-unicode, *pbc, *ppidl, sfgaoIn.i, *psfgaoOut)

Define.i hShell32DLL
Define SHParseDisplayName.ProtoSHParseDisplayName

hShell32DLL = OpenLibrary(#PB_Any, "Shell32.dll")
If hShell32DLL
  SHParseDisplayName.ProtoSHParseDisplayName = GetFunction(hShell32DLL, "SHParseDisplayName")
EndIf

Define *pidl.ITEMIDLIST

hResult = SHParseDisplayName("R:\test_folders\00001", 0, *pidl, 0, 0)
If hResult = #S_OK
  Debug "OK!"
EndIf

I'm obviously doing it wrong, can anybody tell me how to do it right?

Re: Question about Prototypes and calling a function

Posted: Fri Apr 05, 2019 5:40 pm
by JHPJHP
Hi jacky,

Change:

Code: Select all

hResult = SHParseDisplayName("R:\test_folders\00001", 0, *pidl, 0, 0)
To:

Code: Select all

hResult = SHParseDisplayName("R:\test_folders\00001", 0, @pidl, 0, 0)

Re: Question about Prototypes and calling a function

Posted: Fri Apr 05, 2019 6:22 pm
by jacky
Hi JHPJHP,

after additionally changing

Code: Select all

Define *pidl.ITEMIDLIST
to

Code: Select all

Define pidl.ITEMIDLIST
it ... works!

Thanks a lot!

Re: Question about Prototypes and calling a function

Posted: Fri Apr 05, 2019 6:24 pm
by skywalk
@*pidl works also.

Re: Question about Prototypes and calling a function

Posted: Fri Apr 05, 2019 10:55 pm
by jacky
Yes, skywalk, you're right, it's also working that way :D

The whole calling that function thing can't be accelerated in any way, right?

I'm asking because doing that call with a list of 20.000 folder entries takes about 2,75 seconds alone.

v5.70 x64, compiled .exe

Windows Explorer must use some kind of different way to build the shell context menu. Clicking on 20.000 selected
folders with the right mouse button shows the context menu instantly...

Re: Question about Prototypes and calling a function

Posted: Sat Apr 06, 2019 6:10 pm
by skywalk
Windows is the operating system and indexes files and folders in the background. To duplicate that in code requires a database and threads.