IDM
为客户端应用提供了一些API:http://www.internetdownloadmanager.com/support/idm_api.html
我怎么能通过Delphi做到这一点?
答案 0 :(得分:3)
确定。假设我们安装了IDM。
似乎IDManTypeInfo.tlb
库不包含有关IDM库的数据类型的信息。
在这种情况下,使用此库的唯一方法是将c ++头文件重写为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.
将此单元添加到您的项目中并尝试使用下一个代码:
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;
我没有安装IDM,所以我没有检查此代码。我不确定它是100%正确,但尝试一下。
答案 1 :(得分:1)
uses ShellAPI,Registry;
function GetProgramFilesDir: string;
begin
with TRegistry.Create do begin
try
RootKey := HKEY_LOCAL_MACHINE;
OpenKeyReadOnly('SOFTWARE\Microsoft\Windows\CurrentVersion');
Result := ReadString('ProgramFilesDir');
finally
Free;
end;
end;
end;
var url:string;
begin
url:='http:\\yourfile';
if FileExists(GetProgramFilesDir+'\Internet Download Manager\IDMan.exe') then
ShellExecute(Handle, 'open',pchar('"'+GetProgramFilesDir+'\Internet Download Manager\IDMan.exe"'),PChar(' /d "'+url+'"'),nil, 1) else
ShellExecute(Handle, 'open',nil,PChar(url),nil, 1) ; //1=show --
end;
100%工作