Search code examples
delphicomdownload-manager

How to call IDM(Internet Download Manager) from my Delphi application


The IDM offers some API for client applications : http://www.internetdownloadmanager.com/support/idm_api.html

How can I do this via Delphi?


Solution

  • ok. let suppose we have IDM installed.

    seems IDManTypeInfo.tlb library does not contain information about data types of IDM library. In this case, the only way to use this library is to rewrite c++ header files to Delphi:

    unit IDMan;
    
    interface
    uses windows, ActiveX;
    
    const
        CLSID_CIDMLinkTransmitter : TGUID = '{AC746233-E9D3-49CD-862F-068F7B7CCCA4}';
    
        IID_ICIDMLinkTransmitter  : TGUID = '{4BD46AAE-C51F-4BF7-8BC0-2E86E33D1873}';
        IID_ICIDMLinkTransmitter2 : TGUID = '{94D09862-1875-4FC9-B434-91CF25C840A1}';
    type
        ICIDMLinkTransmitter = interface(IInterface)
            ['{4BD46AAE-C51F-4BF7-8BC0-2E86E33D1873}']
    
            function SendLinkToIDM(
                Url : WideString;
                Referer : WideString;
                Cookies : WideString;
                Data: WideString;
                User: WideString;
                Password: WideString;
                LocalPath: WideString;
                LocalFileName: WideString;
                Flags : longint):HRESULT; stdcall;
        end;
    
        ICIDMLinkTransmitter2 = interface(ICIDMLinkTransmitter)
            ['{94D09862-1875-4FC9-B434-91CF25C840A1}']
            function SendLinkToIDM2(
                Url : WideString;
                Referer: WideString;
                Cookies: WideString;
                Data: WideString;
                User: WideString;
                Password: WideString;
                LocalPath: WideString;
                LocalFileName: WideString;
                Flags : longint;
                reserved1 : Variant;
                reserved2 :Variant): HResult; stdcall;
    
            function SendLinksArray(
                location : WideString;
                LinksArray : PSafeArray):HResult; stdcall;
        end;
    
    implementation
    
    end.
    

    add this unit to your project and try to use the next code:

    uses IDMan, ComObj;
    ....
    procedure TMainForm.TestIDM();
    var lt : ICIDMLinkTransmitter;
    begin
        lt := CreateComObject(CLSID_CIDMLinkTransmitter) as ICIDMLinkTransmitter;
        lt.SendLinkToIDM('http://www.internetdownloadmanager.com/trans_kit.zip', 'teran.karelia.pro','','','','','','', 0);
    end;
    

    I have no IDM installed, so I didn't check this code. I'm not sure it is 100% correct, but try it.