Announcement

Collapse
No announcement yet.

Making self documenting COM components part 2

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Making self documenting COM components part 2

    Back in February I started a thread on "creating self documenting COM components." When it became clear that it wasn't possible to do the things I wanted to do in PowerBasic natively, I let the thread die.

    http://www.powerbasic.com/support/pb...ad.php?t=39809

    However, I'm still interested in making my COM objects self documenting and I'd be grateful to anyone who can offer some guidance. If I understand correctly, adding TypeDefs and HelpStrings to a PowerBasic generated COM object is possible if you know how to construct your own *.IDL file and compile it into the resulting .TLB file.

    Are there any tools available that can be used to create/edit .IDL files and compile them into .TLB's?

    I'm still very happy with PowerBasic's ability to create COM objects. I just want to take it a step further.

    -Wes

  • #2
    Study the Microsoft Interface Definition Language(MIDL) and use any text editor.
    Some links to start you off.
    http://msdn.microsoft.com/en-us/libr...91(VS.85).aspx
    http://www.microsoft.com/msj/0898/idl/idl.aspx

    The files you need are on the Platform SDK CD.

    The following code demonstrates how to invoke the MIDL compiler.
    Code:
     
    FUNCTION Compile() AS LONG
    
      LOCAL     szCmdLine   AS ASCIIZ * 4096
      LOCAL     szTargetDir AS ASCIIZ * %MAX_PATH
      LOCAL     szCL        AS ASCIIZ * %MAX_PATH
      LOCAL     szIncl      AS ASCIIZ * %MAX_PATH
      LOCAL     tsa         AS SECURITY_ATTRIBUTES
      LOCAL     tpi         AS PROCESS_INFORMATION
      LOCAL     tsi         AS STARTUPINFO
      LOCAL     lRet        AS LONG
    
      GetShortPathName "C:\Program Files\Microsoft SDK\Bin\Win64\cl.exe", szCL, %MAX_PATH
      GetShortPathName "C:\Program Files\Microsoft SDK\include\", szIncl, %MAX_PATH
    
      ' Build the command for invoking the Windows resource compiler
      ' ------------------------------------------------------------
      szCmdLine = $DQ + "C:\Program Files\Microsoft SDK\Bin\midl.exe" + $DQ + _
                  " /nologo /env win32 /cpp_cmd " + szCL + _
                  " /I" + szIncl + _
                  " /tlb F:\Support\BHO\BHO.tlb" + _
                  " F:\Support\BHO\BHO.idl"
    
      szTargetDir = "F:\Support\BHO\"
    
      WriteLogFileHeader "F:\Support\InvokeMidl\log.txt", VARPTR(szCmdLine), LEN(szCmdLine)
    
      ' Create the pipe for communicating with the console process
      tsa.nLength        = SIZEOF(tsa)
      tsa.bInheritHandle = %TRUE
    
      IF ISTRUE CreatePipe(BYVAL VARPTR(ghReadPipe), BYVAL VARPTR(ghWritePipe), BYVAL VARPTR(tsa), 256 * 1024) THEN
        tsi.cb              = SIZEOF(tsi)
        tsi.lpReserved      = %NULL
        tsi.lpDesktop       = %NULL
        tsi.lpTitle         = %NULL
        tsi.dwX             = 0
        tsi.dwY             = 0
        tsi.dwXSize         = 0
        tsi.dwYSize         = 0
        tsi.dwXCountChars   = 0
        tsi.dwYCountChars   = 0
        tsi.dwFillAttribute = 0
        tsi.dwFlags         = %STARTF_USESTDHANDLES OR %STARTF_USESHOWWINDOW OR %STARTF_FORCEONFEEDBACK
        tsi.wShowWindow     = %SW_HIDE
        tsi.cbReserved2     = 0
        tsi.lpReserved2     = %NULL
        tsi.hStdInput       = 0
        tsi.hStdOutput      = ghWritePipe
        tsi.hStdError       = ghWritePipe
    
        lRet = CreateProcess(BYVAL %NULL, BYVAL VARPTR(szCmdLine), BYVAL %NULL, BYVAL %NULL, %TRUE, _
                             %CREATE_SUSPENDED OR %NORMAL_PRIORITY_CLASS OR %CREATE_SEPARATE_WOW_VDM, BYVAL %NULL, _
                             BYVAL VARPTR(szTargetDir), BYVAL VARPTR(tsi), BYVAL VARPTR(tpi))
    
        ' The child process gets a copy of this handle
        CloseHandle ghWritePipe
    
        IF ISFALSE lRet THEN
          CloseHandle ghReadPipe
          EXIT FUNCTION
        END IF
    
        ResumeThread tpi.hThread
        ' Close the thread handle as soon as it is no longer needed
        CloseHandle tpi.hThread
    
        WaitForSingleObject tpi.hProcess, %INFINITE
    
        IF ghReadPipe THEN
          GetConsoleOutputVPB "F:\Support\InvokeMidl\log.txt"
          CloseHandle ghReadPipe
        END IF
    
        CloseHandle tpi.hProcess
      END IF
    
    END FUNCTION
    Dominic Mitchell
    Phoenix Visual Designer
    http://www.phnxthunder.com

    Comment

    Working...
    X