Util to search through APIFunctioning.txt

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Util to search through APIFunctioning.txt

Post by Zebuddi123 »

Hi to All.

Updated Works with linux maybe maybe Mac too. 28/11/2014

Need to search for win api for URLDownloadToFile_( but couldn't`t remember all the function name, so i wrote this little util, thought in future might be helpful in finding associated win api function`s for ie file`s , downloading etc.

hope some might find it usefull.


Zebuddi. :)

1. search for any matching function`s ie. file, url, ascii. etc
2. search for partial match with or without paramaters
3. list with without paramter`s
4. left double click open`s msdn at the selected function

use: type a search term. autofill`s listview gadget
checking paramater`s checkbox auto adds/removes paramater`s

Zebuddi.

Code: Select all

CompilerIf #PB_Compiler_OS = #PB_OS_Linux Or #PB_Compiler_OS = #PB_OS_MacOS
	This_File$ =#PB_Compiler_Home+"/compilers/apifunctions.txt"   
CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
	This_File$ = #PB_Compiler_Home+"compilers\APIFunctionListing.txt"
CompilerEndIf

Global  Window_0 ,ListIcon_0, String_0, Button_0, Check_0, g_string.s
Global NewList p.s()

Procedure getiinfo(Proc.s)
   Protected pos.i=FindString(Proc, Chr(40))
   If pos 
      Proc = Left(Proc, pos-1)
   EndIf
   RunProgram("http://social.msdn.microsoft.com/search/en-us/windows/desktop?query="+Proc+Chr(38)+"Function Refinement=181")
EndProcedure

Procedure getprocs()
   ClearGadgetItems(ListIcon_0)
   Protected s.s="" ,c.i=1, a$, pos.i
   s=GetGadgetText(String_0)
   If s
      ForEach p()
         If GetGadgetState(Check_0) <> #PB_Checkbox_Checked
            pos=FindString(p(),Chr(40))
            If pos
               a$=Left(p(),pos-1)
            Else
               a$=p()
            EndIf
         Else
            a$=p()
         EndIf
         If FindString(LCase(a$),LCase(s))
            AddGadgetItem(ListIcon_0,-1,Str(c)+"."+Chr(10)+a$)
            c+1   
         EndIf
      Next   
   EndIf
   StatusBarText(0, 1, Str(c-1))
EndProcedure

Procedure.s numbsep(numb.s)
   Protected x.b, nn.i, m.s
   numb=ReverseString(Str(Val(numb)))
   nn=(Mod(Len(numb),3))
   Dim n.s(nn)
   For i=1 To nn
      n(i)=Mid(numb,1,3)
      numb=RemoveString(numb,n(i))
      m+n(i)+","
   Next
   m+numb
   FreeArray(n())
   ProcedureReturn ReverseString(m)
EndProcedure

Procedure OpenWindow_0(x = 0, y = 0, width = 470, height = 420)
   Window_0 = OpenWindow(#PB_Any, x, y, width, height, "Pure API Function List  Searcher", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
   CreateStatusBar(0, WindowID(Window_0)) : AddStatusBarField(70)
   StatusBarText(0, 0, "Nbr Procs") :    AddStatusBarField(394)
   ListIcon_0 = ListIconGadget(#PB_Any, 0, 37, 470, 360, "Nbr", 40, #PB_ListIcon_GridLines| #PB_ListIcon_FullRowSelect)
   AddGadgetColumn(ListIcon_0,1,"Matching Procedure`s",430)
   String_0 = StringGadget(#PB_Any, 10, 10, 330, 20, "")

   Check_0=CheckBoxGadget(#PB_Any, 345, 5, 140, 25, "Search in Param`s")
   SetGadgetColor(ListIcon_0,#PB_Gadget_BackColor,$A7FEFF)
   LoadFont(0,"Ariel",10)
   SetGadgetFont(ListIcon_0,FontID(0))
EndProcedure

Procedure Window_0_Events(event)
   Protected g_string.s
   Select event
      Case #PB_Event_CloseWindow
         FreeList(p())
         ProcedureReturn #False         
      Case #PB_Event_Gadget
         Select EventGadget()
            Case Button_0
               getprocs()
            Case ListIcon_0
               Select EventType()
                  Case #PB_EventType_LeftDoubleClick
                     state = GetGadgetState(ListIcon_0)
                     If state > -1
                        g_string = GetGadgetItemText(ListIcon_0, state, 1)
                        If g_string > ""
                           getiinfo(g_string)
                           g_string=""
                        EndIf
                     EndIf
               EndSelect
         EndSelect
   EndSelect
   ProcedureReturn #True
EndProcedure

OpenWindow_0()

AddWindowTimer(Window_0, 123, 1500) 

If ReadFile(0,This_File$)
   SetWindowTitle(Window_0, "PB Window`s API Function List Searcher    "+numbsep((Trim(ReadString(0,ReadStringFormat(0))))+" Entries"))
   While Not Eof(0)
      AddElement(p())
      p()=ReadString(0,ReadStringFormat(0))
   Wend
   CloseFile(0)
Else
   MessageRequester("File Error","Can Not Read "+This_File$)
   End
EndIf

s.s=GetGadgetText(String_0)
gs.i =GetGadgetState(Check_0)
SetActiveGadget(String_0)
Repeat
   event = WaitWindowEvent()
   dummy$ = GetGadgetText(String_0)
   dummy_gs.i = GetGadgetState(Check_0)
   If Event = #PB_Event_Timer And EventTimer() = 123
      If dummy$ <> s Or dummy_gs <> gs
         getprocs()
         SetGadgetItemState(ListIcon_0,1,1)
         s = dummy$ 
         gs =dummy_gs
      EndIf
   EndIf   
Until Window_0_Events(event) = #False

End
Last edited by Zebuddi123 on Sun Nov 30, 2014 1:05 pm, edited 3 times in total.
malleo, caput, bang. Ego, comprehendunt in tempore
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: Util to search through APIFunctioning.txt

Post by electrochrisso »

Very Handy, thanks for sharing. :D
PureBasic! Purely the best 8)
Amilcar Matos
User
User
Posts: 43
Joined: Thu Nov 27, 2014 3:10 pm
Location: San Juan, Puerto Rico

Re: Util to search through APIFunctioning.txt

Post by Amilcar Matos »

Thanks for sharing! Very useful.
Happy holidays! :D
Post Reply