Page 1 of 3

Help on WIN32API functions does not function anymore!

Posted: Fri Sep 22, 2006 9:34 am
by SimpleMind
Hi,

I had to install my computer from scratch this month. On my old system installation, PureBasic gave me help on the Window API functions when I hit the F1 button. The functions that ends on an xxxxx_(). Now after the reinstall I miss this option and I searched this forum to see what causes this nice option but until now no success.

Does anyone have the same feature active and know which SDK provides this service? I had several of these Windows SDK's installed but do not know which one did the trick.

At the moment I have the MSDN Library for Visual Studio 2005 installed. But Purebasic does not start this help even if I find some legacy API function in this information.

Regards,

Marcel

Posted: Fri Sep 22, 2006 11:18 am
by Trond
Either:
Install Microsoft Platform SDK for Windows Server 2003 SP1 and open the help file and try again.
Or:
Put the contents of this zip file: http://flatassembler.net/docs/win32hlp.zip into a Help subfolder of where you installed PB.

Posted: Fri Sep 22, 2006 12:16 pm
by SimpleMind
Thanks Trond. That was what I had on my machine: Microsoft SDK Windows Server 2003.

I'll try it at once.

Posted: Fri Sep 22, 2006 12:27 pm
by NoahPhense
I have it install, and I even removed my win32 help file from the help
folder. It still doesn't come up. There have been many discussions
about making this work correctly.

- np

Posted: Fri Sep 22, 2006 1:26 pm
by PB
You have to launch the SDK help by itself, not from PureBasic, first. Then all
future launches should work from within PureBasic. That's how it was for me.

Posted: Fri Sep 22, 2006 1:30 pm
by Kale
Create a folder called 'Help' in your PB folder.

Download the WinAPI helpfiles from here: http://www.pb-beginners.co.uk/ and put them in the help folder.

Done!

Posted: Fri Sep 22, 2006 3:18 pm
by NoahPhense
Kale wrote:Create a folder called 'Help' in your PB folder.

Download the WinAPI helpfiles from here: http://www.pb-beginners.co.uk/ and put them in the help folder.

Done!
Yeah that has always worked.

But we want the PSDK to work like that.. ;)

- np

Posted: Fri Sep 22, 2006 3:24 pm
by SimpleMind
I've installed the 2003 server SDK but nothing goes automatically. I've first to start it, copy and paste the function and then push the search button.

To PB: that was also for me also the case in the past. But now I cannot get the same situation. Even when I push F1 the first time after a new start of PureBasic the PB help will not pop up.

To NoahPhense: I've the same experience. In the folder is a helpfile present from MVCOM and that is working.

I do not know if this is due to the new installation of my system or the new PB4.0 version.

I'll try the suggestion given by Kale.... WTH, there is a nice Book!! :shock: about our PB language

Posted: Fri Sep 22, 2006 3:56 pm
by SimpleMind
The only help I can get working is Kale's version. It's better than nothing but e.g. getsockname_() is only present in the 2003 SDK and not in the older version.

Ok, I do not know why it worked under my old system and/or older version of PB.

Maybe Fred knows a solution, always Fred, :D where would we be without this man?

Posted: Fri Sep 22, 2006 4:08 pm
by Fluid Byte
Weird, I followed this discussion a bit and just tought myself to try getting the SDK help running. Well, actually it work's great but I dunno why!

I just removed the "Help" folder wich contained the "WIN32.HLP" file and when I now press F1 on "CreateWindowEx_()" for example the SDK help pops up now intead of the outdated "WIN32.HLP" file.

FYI, the full name of the SDK is "Microsoft Platform SDK for Windows Server 2003 SP1" and I had it installed before I installed PB4.0.

Posted: Fri Sep 22, 2006 6:11 pm
by SimpleMind
I downloaded Microsoft Platform SDK for Windows Server 2003 R2.

I removed the help folder also. Now does nothing show up anymore. :evil:

Posted: Fri Sep 22, 2006 6:15 pm
by NoahPhense
Fluid Byte wrote:Weird, I followed this discussion a bit and just tought myself to try getting the SDK help running. Well, actually it work's great but I dunno why!

I just removed the "Help" folder wich contained the "WIN32.HLP" file and when I now press F1 on "CreateWindowEx_()" for example the SDK help pops up now intead of the outdated "WIN32.HLP" file.

FYI, the full name of the SDK is "Microsoft Platform SDK for Windows Server 2003 SP1" and I had it installed before I installed PB4.0.
Mine is Microsoft Platform SDK (R2) ..

I do have the source code, it's on this board somewhere.. This is what
had to happen for 3.80 ..

Code: Select all

; #####################################################################
; ##        Display MS PlatformSDK Help for PureBasic IDE            ##
; #####################################################################
; 01/29/2004 by Timo 'fr34k' Harter
;
; This editor tool should be usefull for everybody who doesn't like that
; outdated Win32.hlp, and would rather like to display the help of the
; MS PSDK, which is far better, and more complete.
; With this tool, you can do just that.
;
; Requirements:
; =============
; You need the MS PlatformSDK (February 2003) installed on your PC. An
; older Release of the PSDK won't work, as it doesn't use the same format.
; Get it here: http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
; To run this tool, you need at least Windows 98 or WinNT 4.0 with SP3,
; because of some used functions.
; To compile this tool, you need at least PureBasic 3.80
;
; Installation:
; =============
; Just compile this code to an executable, and add it to the IDE's tools
; menu. I suggest you add a shortcut to it for quicker access. Do NOT
; set it to 'Wait until tool Quits', because it will run in the background
; until the editor itself is closed.
; Now you can simply move the cursor to a WinAPI command, and press your
; Shortcut for the tool, and a PSDK window should pop up. If you do this
; again, the help will be displayed in the same window again. (that's why
; the app keeps running)
;
; Note: You can use this to display command help, and also help for Winapi
; constants (as long as they are in the PSDK index). For example, point the
; cursor to any windows message constant like #WM_SIZE, and you'll get the
; help for it.
;
; How this works:
; ===============
; Some more insight on what this tool does for those who are interested:
; The PlatformSDK is in the MSHelp2.0 format, which uses the MS Document
; Explorer (dexplore.exe) to be displayed. 
; This program has a COM Interfacem, which allows you to controll it.
; This Interface is not supported by MS, and therefore not officially
; documented. However, somebody found out how it works through the typelibs
; and trial&error, so there is some info about it here:
; http://www.helpware.net/mshelp2/dexplore/dexplorer.htm
; This tool uses that Interface to controll dexlore.exe.
;
; #####################################################################


#PROCESS_QUERY_INFORMATION = $400

Structure GUITHREADINFO
  cbSize.l
  flags.l
  hwndActive.l
  hwndFocus.l
  hwndCapture.l
  hwndMenuOwner.l
  hwndMoveSize.l
  hwndCaret.l
  rcCaret.RECT
EndStructure

Structure CLSID
  Data1.l       
  Data2.w
  Data3.w
  Data4.b[8]
EndStructure  

Interface IMSHelp20 
  QueryInterface(a.l, b.l)
  AddRef()
  Release()
  GetTypeInfoCount(a.l)
  GetTypeInfo(a.l, b.l, c.l)
  GetIDsOfNames(a.l, b.l, c.l, d.l, e.l)
  Invoke(a.l, b.l, c.l, d.l, e.l, f.l, g.l, h.l)
  Contents()
  Index()
  Search()
  IndexResults()
  SearchResults()
  DisplayTopicFromId(a.l, b.l)
  DisplayTopicFromURL(a.l)
  DisplayTopicFromURLEx(a.l, b.l)
  DisplayTopicFromKeyword(a.l)
  DisplayTopicFromF1Keyword(a.l)
  DisplayTopicFrom_OLD_Help(a.l, b.l)
  SyncContents(a.l)
  CanSyncContents(a.l)
  GetNextTopic(a.l, b.l)
  GetPrevTopic(a.l, b.l)
  FilterUI()
  CanShowFilterUI()
  Close()
  SyncIndex(a.l, b.l)
  SetCollection(a.l, b.l)
  GetCollection(a.l)
  GetFilter(a.l)
  SetFilter(a.l)
  FilterQuery(a.l)
  GetHelpOwner(a.l)
  SetHelpOwner(a.l)
  HxSession(a.l)
  Help(a.l)
  GetObject(a.l, b.l, c.l)
EndInterface

Global PlatformSDKObject.IMSHelp20, PlatformSDKHelpString$

Dim IsNameChar(255)

Procedure.l IsPlatformSDKAvaiable()
  IsAvaiable = 0

  If RegCreateKeyEx_(#HKEY_CURRENT_USER, "Software\Microsoft\MSDN\7.0\Help", 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_READ , 0, @NewKey, @KeyInfo) = #ERROR_SUCCESS
    Index = 0
    Repeat
      ValueName$ = Space(260)
      ValueNameSize = 260
      ValueData$ = Space(260)
      ValueDataSize = 260
      
      Result = RegEnumValue_(NewKey, Index, @ValueName$, @ValueNameSize, 0, @ValueType, 0, 0)      
      
      If Result = #ERROR_SUCCESS And ValueType = #REG_SZ
        
        If Left(LCase(ValueName$),18) = "ms-help://ms.psdk." ; current version: ms-help://MS.PSDK.1033
          PlatformSDKHelpString$ = ValueName$
          IsAvaiable = 1
            
          Break
        EndIf
        
      EndIf
        
      Index + 1
    Until Result <> #ERROR_SUCCESS

    RegCloseKey_(NewKey)
  EndIf

  ProcedureReturn IsAvaiable
EndProcedure


Procedure.l DisplayPlatformSDKHelp(Keyword$)  
  Success = 0

  If PlatformSDKObject = 0
  
    If PlatformSDKHelpString$ Or IsPlatformSDKAvaiable()
    
      CoInitialize_(0)
      
      DExplore$ = Space(Len("DExplore.AppObj")*2+2)
      
      ; Debug DExplore$
      
      
      
      MultiByteToWideChar_(#CP_ACP, 0, "DExplore.AppObj", -1, @DExplore$, Len("DExplore.AppObj")*2+2)
      
      CLSIDFromProgID_(@DExplore$, @CLSID_DExplore.CLSID)
      
      If CoCreateInstance_(@CLSID_Dexplore, 0, 4, ?IID_IMSHelp20, @PlatformSDKObject) = #S_OK
      
        HelpSelection$ = Space(Len(PlatformSDKHelpString$)*2+1)
        MultiByteToWideChar_(#CP_ACP, 0, @PlatformSDKHelpString$, -1, @HelpSelection$, Len(PlatformSDKHelpString$)*2+2)     
        
        BSTR_HelpSelection = SysAllocString_(@HelpSelection$)
        
        NullString_UNICODE$ = " "
        PokeB(@NullString_UNICODE$, 0)
        
        BSTR_NullString = SysAllocString_(@NullString_UNICODE$)
        
        PlatformSDKObject\SetCollection(BSTR_HelpSelection, BSTR_NullString)
      
        SysFreeString_(BSTR_HelpSelection)
        SysFreeString_(BSTR_NullString)                
          
      EndIf
    
    EndIf
    
  EndIf

  If PlatformSDKObject <> 0
  
    Keyword_UNICODE$ = Space(Len(KeyWord$)*2+2)
    MultiByteToWideChar_(#CP_ACP, 0, @Keyword$, -1, @Keyword_UNICODE$, Len(Keyword$)*2+2)    
    
    BSTR_Keyword = SysAllocString_(@Keyword_UNICODE$)                
    
    PlatformSDKObject\Contents()
    If PlatformSDKObject\DisplayTopicFromF1Keyword(BSTR_Keyword) = #S_OK    
         
      PlatformSDKObject\SyncIndex(BSTR_Keyword, 1)
      PlatformSDKObject\Index()
                   
      Success = 1

    EndIf
    
    SysFreeString_(BSTR_Keyword)
  
  EndIf

  ProcedureReturn Success
EndProcedure

Procedure.l DisplayHelp(MainWindow)
  result = 0

  EditorThreadID = GetWindowThreadProcessId_(MainWindow, 0)
  
  info.GUITHREADINFO\cbSize = SizeOf(GUITHREADINFO)  
  GetGUIThreadInfo_(EditorThreadID, @info)
  
  RichEdit = info\hwndFocus

  SendMessage_(RichEdit, #EM_GETSEL, @Cursor, @CursorEnd)

  Line     = SendMessage_(RichEdit, #EM_LINEFROMCHAR, Cursor, 0)
  Position = Cursor - SendMessage_(RichEdit, #EM_LINEINDEX, Line, 0) - 1

  *Buffer = AllocateMemory(1000)
  If *Buffer
    
    ; Debug RichEdit
    
    PokeW(*Buffer, 1000)
    SendMessage_(RichEdit, #EM_GETLINE, Line, *Buffer)
    
    *Char.BYTE = *Buffer + Position
    While *Char >= *Buffer And IsNameChar(*Char\b & $FF) = 1
      *Char - 1
    Wend    
    *Char + 1
    
    *Start = *Char
    
    While *Char\b <> 0 And IsNameChar(*Char\b & $FF) = 1
      *Char + 1
    Wend    
    
    Length = *Char - *Start
    
    KeyWord$ = Trim(PeekS(*Start, Length))
    FreeMemory(0)
    
    Debug Keyword$

    If Keyword$ <> ""
      If Right(Keyword$, 1) = "_"
        Keyword$ = Left(Keyword$, Len(Keyword$)-1)
      EndIf
      
      result = DisplayPlatformSDKHelp(KeyWord$)
    EndIf

  EndIf

  ProcedureReturn result
EndProcedure


Global GlobalMessage, FirstInstance

Procedure.l WindowCallback(Window, Message, wParam, lParam)
  
  ; display new PSDK help
  If FirstInstance And Message = GlobalMessage
    DisplayHelp(lParam)
  EndIf

  ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure


;- Program start

For i = 'A' To 'Z'
  IsNameChar(i) = 1
Next i

For i = 'a' To 'z'
  IsNameChar(i) = 1
Next i

For i = '0' To '9'
  IsNameChar(i) = 1
Next i

IsNameChar('_') = 1 

; Get the PB window
EditorWindow = GetForegroundWindow_()

Title$ = Space(200)
GetWindowText_(EditorWindow, @Title$, 200)
If Left(Title$, 9) <> "PureBasic"
  MessageRequester("PSDK Help","PB EditorWindow not found!")
  End
EndIf

; Make sure, this get's run only once, to open only one PSDK window
GlobalMessage = RegisterWindowMessage_("PSDK_HelpTool_Message")
Mutex         = CreateMutex_(0, 1, "PSDK_HelpTool_Mutex")

If GetLastError_() = #ERROR_ALREADY_EXISTS
  PostMessage_(#HWND_BROADCAST, GlobalMessage, 0, EditorWindow)
  End
EndIf

FirstInstance = #True

; window to receive messages
OpenWindow(0, 0, 0, 0, 0, #PB_Window_Invisible, "PSDK Help Message Window")
SetWindowCallback(@WindowCallback())

; display the help
If DisplayHelp(EditorWindow) = 0
  
  Debug ".."
  
  If PlatformSDKObject <> 0
    PlatformSDKObject\Release()
    CoUninitialize_()
  EndIf

  ReleaseMutex_(Mutex)
  End
EndIf


; monitor the PB Editor process:
GetWindowThreadProcessId_(EditorWindow, @EditorProcessID)
ProcessHandle = OpenProcess_(#PROCESS_QUERY_INFORMATION, 0, EditorProcessID)

; wait for editor quit or a GlobalMessage (in callback)
Quit = 0
Repeat
  Event = WindowEvent()
  
  GetExitCodeProcess_(ProcessHandle, @ExitCode)
  
  If ExitCode <> #STATUS_PENDING
    Quit = 1
  Else      
    Delay(125)
  EndIf

Until Quit

; release MSHelp object
If PlatformSDKObject <> 0
  PlatformSDKObject\Release()
  CoUninitialize_()
EndIf

CloseHandle_(ProcessHandle)
ReleaseMutex_(Mutex)
End


DataSection
  IID_IMSHelp20: ; 4A791148-19E4-11D3-B86B-00C04F79F802
    Data.l $4A791148
    Data.w $19E4, $11D3
    Data.b $B8, $6B, $00, $C0, $4F, $79, $F8, $02      
EndDataSection
- np

Posted: Fri Sep 22, 2006 6:21 pm
by ts-soft
@SimpleMind
you can use this tip: http://www.purebasic.fr/english/viewtopic.php?t=19269
but worked not all times, all keywords :?

Posted: Fri Sep 22, 2006 6:24 pm
by SimpleMind
Thanks ts-soft. I'll take a look at it. :D

Posted: Fri Sep 22, 2006 6:24 pm
by NoahPhense
ts-soft wrote:@SimpleMind
you can use this tip: http://www.purebasic.fr/english/viewtopic.php?t=19269
but worked not all times, all keywords :?
Yeah I have that installed. But I still want my linkage back to my local
psdk. ;)

With this example. We can make it work again.

- np