IDM has a COM interface to be called from other programs. The use of the COM interface requires version 3.18, which was released on Oct 28, 2003, or older. Thus the version of IDM newer than 3.18 must be installed on a user machine.
At the first run, IDM will register IDManTypeInfo.tlb type library. After the first run of IDM the COM interface may be used from any third party applications.
Interface specification:
interface ICIDMLinkTransmitter2: ICIDMLinkTransmitter { HRESULT SendLinkToIDM2(BSTR bstrUrl, BSTR bstrReferer, BSTR bstrCookies, BSTR bstrData, BSTR bstrUser, BSTR bstrPassword, BSTR bstrLocalPath, BSTR bstrLocalFileName, long lFlags, VARIANT reserved1, VARIANT reserved2); /*Transfers one link (URL) to IDM, brings Start Download dialog, or just adds the file to IDM download queue if a special flag is set.*/ HRESULT SendLinksArray(BSTR location, VARIANT * pLinksArray); /* Transfers to IDM an array of internet links (URLs). Note that the use of this function will bring "Download All Links with IDM" dialog to give user an opportunity to review URLs before downloading.*/ }; Parameters of SendLinkToIDM2 function: bstrUrl - Url to download bstrReferer - Referer bstrCookies - cookies bstrData - PostData (if using POST method) bstrUser - UserName (if server requires authentication) bstrPassword - Password bstrLocalPath - LocalPath (where to save a file on your computer) bstrLocalFileName - LocalFileName (file name to save with) lFlags - Flags, can be zero or a combination of the following values: 1 - do not show any confirmations dialogs; 2 - add to queue only, do not start downloading. reserved1 - can be used to set a specific user-agent header with the following way: reserved1.vt = VT_BSTR; reserved1.bstrVal = pbstrUA; if you don’t need to specify a user agent, then reserved1.vt should be set to VT_EMPTY; reserved2 - not used, you should set reserved2.vt to VT_EMPTY; Paramerets of SendLinksArray function: Location - the referrer of download, it’s assumed that the referrer is a single one for the entire array of internet links. pLinksArray – a pointer to 2 dimensional SAFEARRAY array of BSTR strings. For example, for N number of links, the size of the array will be (4 * N). For i changing from 0 to N-1 a[i,0] elements of the array are URLs to download, a[i,1] are cookies for corresponding a[i,0] URLs, a[i,2] are link descriptions for corresponding URLs, a[0,3] is the user agent, all others elements a[i,3] are not used and should be always NULL.
Samples:
C++. Please add IDManTypeInfo.tlb, IDManTypeInfo.h, IDManTypeInfo_i.c to your project. You may download IDManTypeInfo.tlb IDManTypeInfo.h and IDManTypeInfo_i.c here.
Sample 1. Transferring a single link to IDM
#import "IDManTypeInfo.tlb" #include "IDManTypeInfo.h" #include "IDManTypeInfo_i.c" #include <atlbase.h> //for CComBSTR class int main(int argc, char* argv[])  { CComBSTR bstrHref = L"https://www.internetdownloadmanager.com/trans_kit.zip"; CComBSTR referer = L"https://www.tonec.com/"; CComBSTR pbstrUA = L"TestIDM User-Agent"; CoInitialize(NULL); ICIDMLinkTransmitter2* pIDM; HRESULT hr = CoCreateInstance(CLSID_CIDMLinkTransmitter, NULL, CLSCTX_LOCAL_SERVER, IID_ICIDMLinkTransmitter2, (void**)&pIDM); if (S_OK == hr) { VARIANT var1, var2; VariantInit(&var1); VariantInit(&var2); if (pbstrUA) { var1.vt = VT_BSTR; var1.bstrVal = pbstrUA; } else { var1.vt = VT_EMPTY; } var2.vt = VT_EMPTY; hr = pIDM->SendLinkToIDM2(bstrHref, referer, NULL, NULL, NULL, NULL, NULL, NULL, 0, var1, var2); if (S_OK != hr) { //......... } pIDM->Release(); } CoUninitialize(); return 0; }
This sample for VC++ 6.0 may be downloaded here.
Sample 2. Transferring an array of links to IDM
#import "IDManTypeInfo.tlb" #include "IDManTypeInfo.h" #include "IDManTypeInfo_i.c" #include <atlbase.h> //for CComBSTR class int main(int argc, char* argv[]) { int nItems = 2; CComBSTR referer = L"https://www.internetdownloadmanager.com/"; CComBSTR href1 = L"https://www.internetdownloadmanager.com/trans_kit.zip"; CComBSTR cookie1 = L"cookie1=aaa"; CComBSTR descr1 = L"Link 1"; CComBSTR href2 = L"https://www.internetdownloadmanager.com/idman406.exe"; CComBSTR cookie2 = L"cookie2=bbb"; CComBSTR descr2 = L"Link 2"; CComBSTR userAgent = L"User-Agent test2"; CoInitialize(NULL); ICIDMLinkTransmitter2* pIDM; HRESULT hr = CoCreateInstance(CLSID_CIDMLinkTransmitter, NULL, CLSCTX_LOCAL_SERVER, IID_ICIDMLinkTransmitter2, (void**)&pIDM); if (S_OK == hr) { SAFEARRAY *pSA = NULL; SAFEARRAYBOUND bound[3]; bound[0].lLbound = 0; bound[0].cElements = nItems; bound[1].lLbound = 0; bound[1].cElements = 4; pSA = SafeArrayCreate(VT_BSTR, 2, bound); if (NULL != pSA) { long index[2]; int iItem = 0; index[0] = iItem; index[1] = 0; SafeArrayPutElement(pSA, index, href1); index[1] = 1; SafeArrayPutElement(pSA, index, cookie1); index[1] = 2; SafeArrayPutElement(pSA, index, descr1); index[1] = 3; SafeArrayPutElement(pSA, index, ((0 == iItem) ? userAgent : NULL)); iItem ++; index[0] = iItem; index[1] = 0; SafeArrayPutElement(pSA, index, href2); index[1] = 1; SafeArrayPutElement(pSA, index, cookie2); index[1] = 2; SafeArrayPutElement(pSA, index, descr2); index[1] = 3; SafeArrayPutElement(pSA, index, ((0 == iItem) ? userAgent : NULL)); VARIANT var; VariantInit(&var); var.vt = VT_ARRAY | VT_BSTR; var.parray = pSA; hr = pIDM->ndLinksArray(referer, &var); if (S_OK != hr) { //......... } SafeArrayDestroy(pSA); } pIDM->lease(); } CoUninitialize(); return 0; }
This sample for VC++ 6.0 may be downloaded here.
VB:
Private Sub Command1_Click() Dim idm1 As CIDMLinkTransmitter Dim referer As String Dim cookie As String Dim postData As String Dim user As String Dim password As String Set idm1 = CreateObject("IDMan.CIDMLinkTransmitter") idm1.SendLinkToIDM "/idman401.exe", referrer, cookie, postData, user, password, "C:\", "idman401.exe", 0 End Sub
It’s impossible to call IDM COM object directly from HTML page. If you want to call IDM with Java or VB Script from an HTML page, you should develop your ActiveX component, which calls IDM object and call this ActiveX from your script.
Please note that it's strictly forbidden to use IDM COM API from any 3rd party extensions and add-ons hosted in Chrome Webstore, Mozilla AMO web site, and in Microsoft Store. The reason is that many users think that it's an official extension/add-on and they are confused to install it. As the result these add-on/extensions cannot provide the necessary level of integration with the browser. Internet Download Manager users contact us and complain about such 3rd party extensions. Also it's prohibited to use such Impersonation/Deceptive Behavior in all store policies. We will complain to store administration about such extensions/add-ons which confuse our users. We will block all such extensions in Internet Download Manager because they abuse our license agreement, usage policy, and store policies.