问题
I've seen several (not all) registry values like the followings, when trying to parse out the file path under the TypeLib registry key:
HKEY_CLASS_ROOT\TypeLib\\{EE9CFA8C-F997-4221-BE2F-85A5F603218F}\1.0\0\win64(Defalt): C:\Program Files (x86)\Microsoft Office\root\VFS\ProgramFilesX64\Microsoft Office\Office16\OCHelper.dll\1
HKEY_CLASS_ROOT\TypeLib\\{F9E34568-0298-46D3-B9C4-19AFB415CBA8}\1.0\0\win32(Default): C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Packages\mswebprj.dll\5
HKEY_CLASS_ROOT\TypeLib\\{F2A7EE29-8BF6-4a6d-83F1-098E366C709C}\1.0\0\win32(Default): C:\Program Files (x86)\Microsoft Office\Root\Office16\ONENOTE.EXE\2
Each file path is appended with a backslash followed a number. Apparently, these file paths are not legal to file system. I'm wondering if anyone recognizes the syntax, and what the appendix means to a typelib registration under these registry key.
回答1:
usually we use LoadRegTypeLib for load typelib based on registry information. the The function LoadRegTypeLib
defers to LoadTypeLib to load the file. and read Remarks section for LoadTypeLib
By default, the type library is extracted from the first resource of type ITypeLib. To load a different type of library resource, append an integer index to szFile. For example:
ITypeLib *ptlib;
LoadTypeLib("C:\\MONTANA\\EXE\\MFA.EXE\\3", &ptlib)
This statement loads the type library resource 3 from the file Mfa.exe file.
回答2:
In Visual Studio use File > Open > File and select C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Packages\mswebprj.dll. You'll see the resources embedded in the DLL. Open the TYPELIB node and you'll instantly see what 5 means.
It is the resource id.
More typically there is only one type library embedded in the file and has resource id #1. Sometimes the type library is not embedded but stored in a separate file, commonly with the .tlb or .olb filename extension. Like a .NET [ComVisible] assembly, Office is a common example.
来源:https://stackoverflow.com/questions/46268523/what-does-it-mean-to-append-num-to-file-paths-under-hkcr-typelib-typelib