Click here to Skip to main content
15,898,035 members
Home / Discussions / COM
   

COM

 
GeneralRe: IHTMLWindow2::open creating ‘No page to display’ with IE 5.0 but not IE5.5 Pin
Not Active17-Aug-01 3:41
mentorNot Active17-Aug-01 3:41 
GeneralRe: IHTMLWindow2::open creating ‘No page to display’ with IE 5.0 but not IE5.5 Pin
mwolf17-Aug-01 4:27
mwolf17-Aug-01 4:27 
Generalcalls from atl into a DLL and VC++ weirdness Pin
16-Aug-01 3:24
suss16-Aug-01 3:24 
GeneralCOM and ATL Dialogs Pin
Mark Lenz15-Aug-01 10:33
Mark Lenz15-Aug-01 10:33 
GeneralRe: COM and ATL Dialogs Pin
Aaron Schaefer20-Aug-01 5:37
Aaron Schaefer20-Aug-01 5:37 
GeneralSeveral questions about multi dimensional SafeArray , "or" safearray challenge??? <smile> Pin
grossmay15-Aug-01 2:36
grossmay15-Aug-01 2:36 
QuestionHow to use IHTMLEditHost in combination with CHtmlView Pin
Juergen Woelke15-Aug-01 1:46
Juergen Woelke15-Aug-01 1:46 
GeneralHelp with ITypeInfo Pin
Aaron Schaefer13-Aug-01 11:21
Aaron Schaefer13-Aug-01 11:21 
Hi,

I'm trying to get info out of a typelib at runtime, using the ITypeLib interface returned from a GetTypeLib(...) call. I'm having trouble with the enums in the typelib. I'd like to be able to get the names of members of the enum and their helpstrings at run time from the ITypeInfo interface for the enum. I can get the name of the enum itself, but can't get anything inside of it. Here's the code I'm tryin to use:

ITypeLib* pTypeLib = NULL;
ITypeInfo* pTypeInfo = NULL;
hr = LoadTypeLib(path, &pTypeLib);
if(SUCCEEDED(hr))
{
// Get info about the typelib itself
BSTR bstrName, bstrDocString, bstrHelpFile;
DWORD dwHelpContext;
pTypeLib->GetDocumentation(-1, &bstrName, &bstrDocString, &dwHelpContext, &bstrHelpFile);

name = bstrName;
docString = bstrDocString;
helpFile = bstrHelpFile;
fprintf(log, "\n--TypeLib information for <%s> -- ", (char*)path);
fprintf(log, "\nName: %s", (char*)name);
fprintf(log, "\nDocString: %s", (char*)docString);
fprintf(log, "\nHelpFile: %s", (char*)helpFile);
fprintf(log, "\n\n");

SysFreeString(bstrName);
SysFreeString(bstrDocString);
SysFreeString(bstrHelpFile);

UINT count = pTypeLib->GetTypeInfoCount();
for(int i = 0; i < count; i++)
{
hr = pTypeLib->GetTypeInfo(i, &pTypeInfo);
if(SUCCEEDED(hr))
{
// Examine the type info for this thingy

// Get documentation about the interface/struct/etc
pTypeInfo->GetDocumentation(-1, &bstrName, &bstrDocString, &dwHelpContext, &bstrHelpFile);

name = bstrName;
docString = bstrDocString;
helpFile = bstrHelpFile;
fprintf(log, "\n--TypeLib information for typelib member # <%i> -- ", i);
fprintf(log, "\nName: %s", (char*)name);
fprintf(log, "\nDocString: %s", (char*)docString);
fprintf(log, "\nHelpFile: %s", (char*)helpFile);

// Type attributes
TYPEATTR* pTypeAttr = NULL;
pTypeInfo->GetTypeAttr(&pTypeAttr);

int j = 0;
switch(pTypeAttr->typekind)
{
case TKIND_COCLASS: fprintf(log, "\ntypekind = TKIND_COCLASS");
break;

case TKIND_ALIAS: fprintf(log, "\ntypekind = TKIND_ALIAS");
break;

case TKIND_DISPATCH: fprintf(log, "\ntypekind = TKIND_DISPATCH");
fprintf(log, "\ncFuncs = %i", pTypeAttr->cFuncs);
while(j < pTypeAttr->cFuncs)
{
pTypeInfo->GetDocumentation(j, &bstrName, &bstrDocString, &dwHelpContext, &bstrHelpFile);

name = bstrName;
docString = bstrDocString;
helpFile = bstrHelpFile;
fprintf(log, "\n--TypeLib information for typelib submember # <%i> -- ", j);
fprintf(log, "\nName: %s", (char*)name);
fprintf(log, "\nDocString: %s", (char*)docString);
fprintf(log, "\nHelpFile: %s", (char*)helpFile);

// Release strings and stuff
SysFreeString(bstrName);
SysFreeString(bstrDocString);
SysFreeString(bstrHelpFile);

j++;
}

break;

case TKIND_ENUM: fprintf(log, "\ntypekind = TKIND_ENUM");
fprintf(log, "\ncVars = %i", pTypeAttr->cVars);

// Enumerate the constants and get doc.
while(j < pTypeAttr->cVars)
{
// ***This next line fails***
hr = pTypeInfo->GetDocumentation(j, &bstrName, &bstrDocString, &dwHelpContext, &bstrHelpFile);

name = bstrName;
docString = bstrDocString;
helpFile = bstrHelpFile;
fprintf(log, "\n--TypeLib information for enum submember # <%i> -- ", j);
fprintf(log, "\nName: %s", (char*)name);
fprintf(log, "\nDocString: %s", (char*)docString);
fprintf(log, "\nHelpFile: %s", (char*)helpFile);

// Release strings and stuff
SysFreeString(bstrName);
SysFreeString(bstrDocString);
SysFreeString(bstrHelpFile);

j++;
}


break;

case TKIND_INTERFACE: fprintf(log, "\ntypekind = TKIND_INTERFACE");
break;

case TKIND_MAX: fprintf(log, "\ntypekind = TKIND_MAX");
break;

case TKIND_MODULE: fprintf(log, "\ntypekind = TKIND_MODULE");
break;

case TKIND_RECORD: fprintf(log, "\ntypekind = TKIND_RECORD");
break;

case TKIND_UNION: fprintf(log, "\ntypekind = TKIND_UNION");
break;

default:
fprintf(log, "\nUnrecognized type kind.");
}


pTypeInfo->ReleaseTypeAttr(pTypeAttr);

// Release strings and stuff
SysFreeString(bstrName);
SysFreeString(bstrDocString);
SysFreeString(bstrHelpFile);

pTypeInfo->Release();
fprintf(log, "\n\n");
}
}


And here is the declaration of the enum (from a larger typelib) that I am trying to get some info about:

// Options for calculating roughness correction factor for PSW [helpstring("Roughness Correction Factor Calculation Options") ]
typedef enum
{
[ helpstring("No roughness correction applied") ]
ROUGHNESS_NONE,

[ helpstring("Viscosity based correction factor") ]
ROUGHNESS_VISCOSITY,

[ helpstring("Reynold's number based correction factor") ]
ROUGHNESS_REYNOLDS
} RoughnessCFOption;

I am getting a failure on the call to get documentation for each of the members of the struct. So maybe I should be usin a different call here?

Thanks in advance for any help.

Aaron
GeneralRe: Help with ITypeInfo Pin
Aaron Schaefer13-Aug-01 11:40
Aaron Schaefer13-Aug-01 11:40 
GeneralWM_CREATE, CWindow and HWND Pin
13-Aug-01 7:26
suss13-Aug-01 7:26 
GeneralRe: WM_CREATE, CWindow and HWND Pin
16-Aug-01 5:52
suss16-Aug-01 5:52 
GeneralShell Extentions / EXPLORER Extentions Pin
12-Aug-01 19:54
suss12-Aug-01 19:54 
GeneralVARIANT data type?! Pin
11-Aug-01 21:28
suss11-Aug-01 21:28 
GeneralRe: VARIANT data type?! Pin
Rashid Thadha12-Aug-01 23:08
Rashid Thadha12-Aug-01 23:08 
GeneralRe: VARIANT data type?! Pin
20-Aug-01 1:06
suss20-Aug-01 1:06 
GeneralHELP!!! Advise() failes when called remotely Pin
10-Aug-01 5:45
suss10-Aug-01 5:45 
GeneralRe: HELP!!! Advise() failes when called remotely Pin
Mike Player10-Aug-01 6:14
Mike Player10-Aug-01 6:14 
GeneralRe: HELP!!! Advise() failes when called remotely Pin
Rashid Thadha10-Aug-01 6:34
Rashid Thadha10-Aug-01 6:34 
GeneralConverting types Pin
8-Aug-01 20:11
suss8-Aug-01 20:11 
GeneralEvents in ASP Pin
Member 169778-Aug-01 19:47
Member 169778-Aug-01 19:47 
GeneralPerformance: Smart pointers vs CComPtr, IDispatch vs IUnknown Pin
Joe Hastings8-Aug-01 11:43
Joe Hastings8-Aug-01 11:43 
GeneralCOM Pin
8-Aug-01 0:14
suss8-Aug-01 0:14 
GeneralCalling the 2nd + method Pin
Brad Bruce7-Aug-01 8:39
Brad Bruce7-Aug-01 8:39 
GeneralATL Dialog based control wizard Pin
7-Aug-01 7:24
suss7-Aug-01 7:24 
GeneralRe: ATL Dialog based control wizard Pin
Aaron Schaefer7-Aug-01 8:41
Aaron Schaefer7-Aug-01 8:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.