| 
								  
								This page is for 
								developers. 
								Blader provides 
								automation interface for third-party invoke. 
								Like Flashget, it can even be invoked from IE 
								browser's contexted menu. However, Blader is not 
								just for ordinary network resources download. 
								Ordinary resources download has been well 
								realized by other download tools. Blader's 
								powerful ability exposes when being used 
								together with
								CooJah.
								 
								The ProgramID of 
								Blader automation interface is
								URLDownloader.COMAddTask. 
								For development convenience, a TLB file is 
								provided in Blader package. It can be imported 
								by development tools. Now I will show you how to 
								invoke the only interface implemented by Blader. 
								It's in C/C++, other it's the same for other 
								languages. 
								long AddUrls(VARIANT* varUrls); 
								The varUrls parameter is a 2 Dim Safe 
								Array. There are 5 elements for Dim 1. They are 
								URL, User-Agent, Referer, Cookie and whole 
								Reuest Header. Dim 2 is for multi task. 
								Return value. S_OK(0) is for successful 
								inovke and other return values are for failure. 
								At present, the error values including  
								ERROR_PROC_NOT_FOUND(127L) for cannot find main 
								window of Blader, ERROR_INVALID_PARAMETER(87L) 
								for invalid input parameters). For stability, 
								you'd better add exception handling outside. 
								Following is an example in Viusal C++: 
								
								 
								// To ensure 
								automation interface to be registered, run it 
								first 
								CString strExePath;    // Full path of 
								Blader.exe 
								PROCESS_INFORMATION ProcessInfo;  
								STARTUPINFO StartupInfo; 
								ZeroMemory(&ProcessInfo, sizeof(ProcessInfo)); 
								ZeroMemory(&StartupInfo, sizeof(StartupInfo)); 
								StartupInfo.cb = sizeof(StartupInfo); 
								if(CreateProcess(strExePath, NULL, NULL, NULL, 
								FALSE, 0,  
								NULL, NULL,&StartupInfo,&ProcessInfo)) 
								{  
								WaitForInputIdle(ProcessInfo.hProcess,INFINITE); 
								CloseHandle(ProcessInfo.hThread); 
								CloseHandle(ProcessInfo.hProcess); 
								} 
								else 
								{ 
								AfxMessageBox(_T("Startup failed, please make 
								sure its existence.")); 
								return; 
								} 
								 
								// Startup Blader by automation interface 
								ICOMAddTaskPtr taskAdd; // Smart pointer got by 
								import tlb file 
								if(taskAdd.CreateInstance(_T("URLDownloader.COMAddTask")) 
								!= S_OK) 
								{ 
								AfxMessageBox(_T("Add task to Blader failed!")); 
								return; 
								} 
								// Create 2 Dim SafeArray 
								SAFEARRAYBOUND bounds [2];  
								bounds[0].cElements = 5; // Dim 1, URL, User 
								Agent, Referer, Cookie, Header 
								bounds[0].lLbound = 0; 
								bounds[1].cElements = nSize; // Dim 2, nSize 
								means number of tasks 
								bounds[1].lLbound = 0; 
								SAFEARRAY *psa = SafeArrayCreate(VT_VARIANT, 2, 
								bounds); // Create 2 dim safearray 
								if(psa == NULL) 
								{ 
								AfxMessageBox(_T("Create safe array failed!")); 
								return; 
								} 
								VARIANT varList;  
								varList.vt = VT_BSTR;  
								long ix[2] = {0}; 
								CString strURL, strAgent, strRefer, strCookie, 
								strHeader; // User-Agent is not used at present 
								CReportCtrl& rc = GetReportCtrl(); 
								for(int i = 0; i < nSize; i ++) 
								{ 
								strURL = rc.GetItemText(aItems[i], 
								2);            // Get data from listctrl 
								strRefer = rc.GetItemText(aItems[i], 3); 
								strCookie = rc.GetItemText(aItems[i], 4); 
								strHeader = (LPCTSTR)rc.GetItemData(aItems[i]); 
								if(!strURL.IsEmpty()) 
								{ 
								// Will construct patameters, a 2 Dim SafeArray 
								ix[1] = i; 
								ix[0] = 0; 
								varList.bstrVal = SysAllocString(T2OLE(strURL)); 
								SafeArrayPutElement(psa, ix, &varList); 
								ix[0] ++; 
								varList.bstrVal = 
								SysAllocString(T2OLE(strAgent)); 
								SafeArrayPutElement(psa, ix, &varList); 
								ix[0] ++; 
								varList.bstrVal = 
								SysAllocString(T2OLE(strRefer)); 
								SafeArrayPutElement(psa, ix, &varList); 
								ix[0] ++; 
								varList.bstrVal = 
								SysAllocString(T2OLE(strCookie)); 
								SafeArrayPutElement(psa, ix, &varList); 
								ix[0] ++; 
								varList.bstrVal = 
								SysAllocString(T2OLE(strHeader)); 
								SafeArrayPutElement(psa, ix, &varList); 
								} 
								} 
								varList.vt = VT_ARRAY | VT_VARIANT | VT_BYREF; 
								varList.pparray=&psa; 
								if(taskAdd->AddUrls(&varList) != S_OK) 
								{ 
								AfxMessageBox(_T("Add task to Blader failed!")); 
								} 
								SafeArrayDestroy(psa);  
								   |