Page 1 of 1
doing a 'launchy'... searching the start menu
Posted: Mon Nov 01, 2010 11:00 pm
by blueznl
'Launcy' style of apps search through the start menu for matches, and (obviously

) I want to be able to do the same. However it appears that specific folder has different names under different versions / languages of windows, and on top of that there appear to be two folders, one for the user itself, and one for 'all users'.
I've found out how to find the current user's start menu, but I haven't been able to figure out the 'all users' folder.
An alternative approach might be to search the registry for programs, or file extensions with associated programs. Is there a way, for example, to look for M$'s Word in the registry, without having to parse thousands of entries?
As usual suggestions welcome, and I'll share the results, I promise

Re: Doing a 'launchy'... searching for the start menu
Posted: Tue Nov 02, 2010 2:47 am
by LuCiFeR[SD]
http://msdn.microsoft.com/en-us/library ... S.85).aspx
My PB skills are pretty damn lame if I am honest... I kinda got used to the older PB, but so much has changed hehe

So if there is a better way to do this then I am all ears LOL
Code: Select all
Procedure.s GetSpecialFolderPath(CSIDL.l)
Protected SFPath.s = Space(#MAX_PATH), Library = OpenLibrary(#PB_Any,"shell32.dll")
If Library
CallFunctionFast(GetFunction(Library,"SHGetSpecialFolderPathA"),0,@SFPath,CSIDL,0)
CloseLibrary(Library)
EndIf
ProcedureReturn SFPath
EndProcedure
Debug GetSpecialFolderPath(#CSIDL_COMMON_PROGRAMS) ;All users
Debug GetSpecialFolderPath(#CSIDL_STARTMENU) ;Current user
As for the search stuff... I have currently no ideas and all the code I found doesn't work anymore LOL
Re: Doing a 'launchy'... searching for the start menu
Posted: Tue Nov 02, 2010 8:31 am
by blueznl
Weeeeeeeeelllll, things only got better, so.....
Thanks, I had the one for current user, that other one is the one I was missing. Together with some other code I hacked together I should now be able to do some smart searching.
Now the next challenge would be...
1. to read a .LNK file and find out what file it is pointing to so I can find the icon
and
2. to grab an icon from an EXE that is refered to
Of course, I'm first going to try to find solutions myself, but hey, don't feel reluctant to make any suggestions

Re: Doing a 'launchy'... searching for the start menu
Posted: Tue Nov 02, 2010 1:25 pm
by rsts
blueznl wrote:
Now the next challenge would be...
1. to read a .LNK file and find out what file it is pointing to so I can find the icon
and
2. to grab an icon from an EXE that is refered to
Of course, I'm first going to try to find solutions myself, but hey, don't feel reluctant to make any suggestions

Wow, I wonder if there's anyone who hasn't worked on one of these

I'm also working on one.
Link info
http://www.purebasic.fr/english/viewtop ... 13&t=43332
Extract icons
http://www.purebasic.fr/english/viewtop ... 13&t=39617
We should all make one as a collaborative process.
cheers
Re: doing a 'launchy'... searching the start menu
Posted: Tue Nov 02, 2010 2:02 pm
by blueznl
Being a non-pro programmer, I tend to share my code (ie. WallX, CodeCaddy etc.). I've got my framework for 'Thype' (as I've dubbed my 'Launchy' clone) ready, ie. here:
http://www.purebasic.fr/english/viewtop ... 13&t=44142
It already supports one command

Hit [Alt]+[Space] twice, then either abort using the [Esc] key or enter 'quite' [Enter].
Good to see other people are fooling around with similar apps. I couldn't find something that matched my needs, and it seemed like a fun PureBasic project

Re: Doing a 'launchy'... searching for the start menu
Posted: Tue Nov 02, 2010 2:30 pm
by Vera
blueznl wrote:1. to read a .LNK file and find out what file it is pointing to so I can find the icon
maybe this code by
bembulak is of help
(It's part of
RSBasics Win-Api-Library, but it's offline at the moment)
Code: Select all
;Autor: bembulak
EnableExplicit
Procedure ReadShellLink(File$)
Protected psl.IShellLinkA
Protected ppf.IPersistFile
Protected mem.s
Protected hres
Protected PATH$
Protected udata.WIN32_FIND_DATA
Protected Argument$
Protected WorkingDirectory$
Protected DESCRIPTION$
Protected ShowCommand.l
Protected HotKey
Protected IconFile$
Protected IconIndexInFile
Protected result
CoInitialize_(0)
If CoCreateInstance_(?CLSID_ShellLink,0,1,?IID_IShellLink,@psl.IShellLinkA) = 0
ShellLink_LOAD:
; Query IShellLink For the IPersistFile interface For loading the
; shortcut in persistent storage.
If psl\QueryInterface(?IID_IPersistFile,@ppf.IPersistFile) = 0
; Ensure that the string is Unicode.
mem.s = Space(1000) ;AllocateMemory(1,1000)
MultiByteToWideChar_(#CP_ACP, 0, File$, -1, mem, 1000)
;Save the link by calling IPersistFile::Save.
hres = ppf\Load(@mem,#True)
EndIf
Get_ShellLink_preferences:
; The file TO which is linked ( = target for the Link )
;
PATH$=Space(256)
psl\GetPath(@PATH$,Len(PATH$),udata.WIN32_FIND_DATA,0)
Debug path$
; Arguments for the Target
Argument$ = Space(256)
psl\GetArguments(@Argument$,Len(Argument$))
Debug Argument$
; Working Directory
WorkingDirectory$ = Space(256)
psl\GetWorkingDirectory(@WorkingDirectory$,Len(WorkingDirectory$))
Debug WorkingDirectory$
; Description ( also used as Tooltip for the Link )
;
DESCRIPTION$ = Space(256)
psl\GetDescription(@DESCRIPTION$,Len(DESCRIPTION$))
Debug DESCRIPTION$
; Show command:
; SW_SHOWNORMAL = Default
; SW_SHOWMAXIMIZED = aehmm... Maximized
; SW_SHOWMINIMIZED = play Unreal Tournament
ShowCommand.l = 0
psl\GetShowCmd(@ShowCommand)
; Hotkey:
; The virtual key code is in the low-order byte,
; and the modifier flags are in the high-order byte.
; The modifier flags can be a combination of the following values:
;
; HOTKEYF_ALT = ALT key
; HOTKEYF_CONTROL = CTRL key
; HOTKEYF_EXT = Extended key
; HOTKEYF_SHIFT = SHIFT key
;
psl\GetHotkey(@HotKey)
; Set Icon for the Link:
; There can be more than 1 icons in an icon resource file,
; so you have to specify the index.
;
IconFile$ = Space(256)
psl\getIconLocation(@IconFile$, Len(IconFile$),@IconIndexInFile)
Debug IconFile$
psl\Release()
ppf\Release()
EndIf
CoUninitialize_()
ProcedureReturn result
DataSection
CLSID_ShellLink:
; 00021401-0000-0000-C000-000000000046
Data.l $00021401
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
IID_IShellLink:
; DEFINE_SHLGUID(IID_IShellLinkA, 0x000214EEL, 0, 0);
; C000-000000000046
Data.l $000214EE
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
IID_IPersistFile:
; 0000010b-0000-0000-C000-000000000046
Data.l $0000010b
Data.w $0000,$0000
Data.b $C0,$00,$00,$00,$00,$00,$00,$46
EndDataSection
EndProcedure
; CreateLink
; - TARGET$ for the Link ("c:\PureBasic\purebasic.exe")
; - LINK$ - name of the Link ("c:\pb.lnk")
; - Argument$ for the target ("%1")
; - Description$ = Description and Tooltip ("Start PureBasic")
; - Working Directory ("c:\PureBasic\")
; - Show command: #SW_SHOWNORMAL or #SW_SHOWMAXIMIZED or #SW_SHOWMINIMIZED
; - HotKey - no need to use this :)
; - IconFile + Index ( "c:\PureBasic\purebasic.exe" , 1 )
ReadShellLink("C:\abc\test.lnk")
Re: doing a 'launchy'... searching the start menu
Posted: Fri Nov 05, 2010 2:20 am
by Amundo
Hey Guys!
I've been thinking (operative word...."thinking") about one of these too!
I have so many programs installed that my Start Menu is unwieldy, so I went in search of an alternative - thought I'd found it in "Start Menu 7", but, in all honesty, I think it's a bloated mess (don't get me wrong, it seems to work perfectly, but after a few hours use, it's gobbling up 30-40MB of memory).
I will follow this with interest and try (there's another operative word...."try") to participate...
