It is currently Tue Sep 17, 2019 7:56 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Question about Prototypes and calling a function
PostPosted: Fri Apr 05, 2019 4:57 pm 
Offline
User
User

Joined: Mon Jan 21, 2019 1:41 pm
Posts: 23
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?


Top
 Profile  
Reply with quote  
 Post subject: Re: Question about Prototypes and calling a function
PostPosted: Fri Apr 05, 2019 5:40 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Oct 09, 2010 3:47 am
Posts: 1572
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)

_________________

I will be unreachable from the forum for an indefinite period; downloads moved to My PureBasic Stuff.
_________________


Top
 Profile  
Reply with quote  
 Post subject: Re: Question about Prototypes and calling a function
PostPosted: Fri Apr 05, 2019 6:22 pm 
Offline
User
User

Joined: Mon Jan 21, 2019 1:41 pm
Posts: 23
Hi JHPJHP,

after additionally changing
Code:
Define *pidl.ITEMIDLIST

to
Code:
Define pidl.ITEMIDLIST


it ... works!

Thanks a lot!


Top
 Profile  
Reply with quote  
 Post subject: Re: Question about Prototypes and calling a function
PostPosted: Fri Apr 05, 2019 6:24 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3054
Location: Boston, MA
@*pidl works also.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Question about Prototypes and calling a function
PostPosted: Fri Apr 05, 2019 10:55 pm 
Offline
User
User

Joined: Mon Jan 21, 2019 1:41 pm
Posts: 23
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...


Top
 Profile  
Reply with quote  
 Post subject: Re: Question about Prototypes and calling a function
PostPosted: Sat Apr 06, 2019 6:10 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 3054
Location: Boston, MA
Windows is the operating system and indexes files and folders in the background. To duplicate that in code requires a database and threads.

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye