PureBasic Forum
https://www.purebasic.fr/english/

Question about Prototypes and calling a function
https://www.purebasic.fr/english/viewtopic.php?f=5&t=72590
Page 1 of 1

Author:  jacky [ Fri Apr 05, 2019 4:57 pm ]
Post subject:  Question about Prototypes and calling a function

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:
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?

Author:  JHPJHP [ Fri Apr 05, 2019 5:40 pm ]
Post subject:  Re: Question about Prototypes and calling a function

Hi jacky,

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

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

Author:  jacky [ Fri Apr 05, 2019 6:22 pm ]
Post subject:  Re: Question about Prototypes and calling a function

Hi JHPJHP,

after additionally changing
Code:
Define *pidl.ITEMIDLIST

to
Code:
Define pidl.ITEMIDLIST


it ... works!

Thanks a lot!

Author:  skywalk [ Fri Apr 05, 2019 6:24 pm ]
Post subject:  Re: Question about Prototypes and calling a function

@*pidl works also.

Author:  jacky [ Fri Apr 05, 2019 10:55 pm ]
Post subject:  Re: Question about Prototypes and calling a function

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...

Author:  skywalk [ Sat Apr 06, 2019 6:10 pm ]
Post subject:  Re: Question about Prototypes and calling a function

Windows is the operating system and indexes files and folders in the background. To duplicate that in code requires a database and threads.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/