Mine is Microsoft Platform SDK (R2) ..
I do have the source code, it's on this board somewhere.. This is what
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