为客户端应用程序提供了IDM
一些 API:http: //www.internetdownloadmanager.com/support/idm_api.html
我怎样才能通过德尔福做到这一点?
为客户端应用程序提供了IDM
一些 API:http: //www.internetdownloadmanager.com/support/idm_api.html
我怎样才能通过德尔福做到这一点?
行。假设我们安装了 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% 正确,但请尝试一下。
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%