How to import IDL into Delphi?

与世无争的帅哥 提交于 2019-12-12 15:23:47

问题


How do i import an Interface Definition Language (idl) file into Delphi; converting the types and interfaces to a pascal file?

I've tried:

  • File, Open: it just shows the text of the .idl text file
  • Project, Add to project: It just (acts like) it adds a .idl text file to the project
  • Component, Install component, Import a Type Library, Add: But it causes a handled crash
  • Component, Install component, Import ActiveX Control, Add: But it causes a handled crash
  • using Embarcadero's GenTLB tool: Fails (which makes sense, as GenTLB it doesn't support IDL, only "RIDL"):

    D:\>gentlb d:\develop\avatar\pdb\source\import\CorSym.idl
    Embarcadero GenTLB Version 12.16581
    Copyright(c) 1995-2010 Embarcadero Technologies, Inc.
    
    Opening  'd:\develop\avatar\pdb\source\import\CorSym.idl'
    ***ERRORS*** - 3 errors encountered:
    Error E0001 CorSym.idl 14: 'library' expected, found 'cpp_quote' instead
    Error E0001 CorSym.idl 49: Type keyword expected, found 'const' instead
    Error E0001 CorSym.idl 63: '<EOF>' expected, found 'module' instead
    

Bonus Reading

  • DocWiki - Type Libraries
  • How can I import a IDL file to DELPHI Project? (2005)
  • How to Import IDL to a project (2006)
  • Delphi 2010: how to convert .idl files to .TLB files? (2009)
  • IDL to Type Library (2011)

回答1:


You can use a two stage process with Embarcadero tools:

  1. Use gentlb to create a type library from your IDL file.
  2. Use tlibimp to create a Pascal import file from the type library.

I personally use gentlb to make a type library from an Embarcadero IDE generated .ridl file. I believe that .ridl is an Embarcadero flavour of IDL that is not compatible with standard MS IDL. If you have IDL of the MS flavour then you'd use the MS IDL compiler to generate the type library.



来源:https://stackoverflow.com/questions/27822452/how-to-import-idl-into-delphi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!