News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

searching namespaces for dexplore.exe

Started by ToutEnMasm, March 08, 2009, 05:20:30 PM

Previous topic - Next topic

ToutEnMasm

Hello,
Think i have found something useful here
http://weblog.helpware.net/?tag=html-help
But some namespaces cann't be used with Help2,WHY ?

donkey

Hi,

To get available Help2 namespaces you need to use IHxRegistryWalker, not sure if that's directly available from DExplore's interface, but you can instantiate directly and pass the namespace to DExplore if necessary:

GetHxNamespaces FRAME hwnd
uses ebx,edi,esi
LOCAL pbszNamespace:D
LOCAL pIHxRegNamespace:D
LOCAL pIHxRegNamespaceList:D
LOCAL pHxRegSession:D
LOCAL varResult:VARIANT
LOCAL hGlobal:D

// Populates a combo box with available namespaces

// Get the available collections
invoke CoCreateInstance,offset CLSID_HxRegistryWalker, NULL, CLSCTX_ALL,offset IID_IHxRegistryWalker, offset pHxRegSession
test eax,eax
jnz >>.EXITPROGRAM
// Get the instance pointer for the namespace list
CoInvoke(pHxRegSession,IHxRegistryWalker.RegisteredNamespaceList,[pbszNULL],offset pIHxRegNamespaceList)
// How many namespaces in the list ?
CoInvoke(pIHxRegNamespaceList,IHxRegNamespaceList.Count,offset nNamespaces)
mov ebx,[nNamespaces]
test ebx,ebx
// If there are none then Help2 is not installed (there is at least "Hx" on initial installation)
Jz >>.EXITPROGRAM
:
// Walk through the list adding the available namespaces to our combo box
CoInvoke(pIHxRegNamespaceList,IHxRegNamespaceList.ItemAt,ebx,offset pIHxRegNamespace)
CoInvoke(pIHxRegNamespace,IHxRegNamespace.Name,offset pbszNamespace)

invoke SendMessage,[hwnd],CB_ADDSTRING,0,[pbszNamespace]
mov edi,eax
// Make sure we free each BSTR created by the call
invoke SysFreeString,[pbszNamespace]

// The namespaces description is available through its properties, we get this with a VARIANT structure
mov W[varResult.vt],VT_BSTR
CoInvoke(pIHxRegNamespace,IHxRegNamespace.GetProperty,HxRegNamespaceDescription,offset varResult)
test eax,eax
jnz >>.NODESC
// Create a memory buffer for the description and attach it to the item
invoke GlobalAlloc,GMEM_FIXED,MAX_STRINGLEN
mov [hGlobal],eax
invoke lstrcpyn,[hGlobal],[varResult.bstrVal],MAX_STRINGLEN>>1
// Free the BSTR created by the call
invoke SysFreeString,[varResult.bstrVal]
// Attach the description
invoke SendMessage,[hwnd],CB_SETITEMDATA ,edi,[hGlobal]
.NODESC
// Release the namespace
CoInvoke(pIHxRegNamespace,IHxRegNamespace.IUnknown.Release)
dec ebx
jnz <<

// Release the session and the list
CoInvoke(pIHxRegNamespaceList,IHxRegNamespaceList.IUnknown.Release)
CoInvoke(pHxRegSession,IHxRegNamespaceList.IUnknown.Release)

// return success
xor eax,eax
RET

.EXITPROGRAM

// No usable namespaces were found shut down as gracefully as possible
mov eax,-1
ret

ENDF


All collections listed are available, some however are just placeholders for merged indexes, they will show up as empty but should not throw an error if opened, for example:



Edgar
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable