Willkommen ~Gast!
Registrieren || Einloggen || Hilfe/FAQ || Staff
Probleme mit der Registrierung im Forum? Melde dich unter registerEin Bild.
Autor Beitrag
000
03.12.2002, 19:56
Doppelhertz



Würd gern wissen ob's en parameter für'n IE gibt mit dem man ne bestimmte seite aufrufen kann.
mein Quelltext um die Startseite aufzurufen:

ShellExecute(0, 'open', Pchar(C:\....\IEXplorer.exe), nil, nil ,SW_SHOW);

und dann würd ich noch ganz gerne ma wisse wie man, wenn mehrere IE's offen sin, nen bestimmten schließt, hab nur den code:

uses tlhelp32;

function KillTask(ExeFileName: string): integer;
const
PROCESS_TERMINATE=$0001;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
result := 0;

FSnapshotHandle := CreateToolhelp32Snapshot
(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := Sizeof(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle,
FProcessEntry32);

while integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(
FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName)) or
(UpperCase(FProcessEntry32.szExeFile) =
UpperCase(ExeFileName))) then

Result := Integer(TerminateProcess(OpenProcess(
PROCESS_TERMINATE, BOOL(0),
FProcessEntry32.th32ProcessID), 0));

ContinueLoop := Process32Next(FSnapshotHandle,
FProcessEntry32);
end;

CloseHandle(FSnapshotHandle);
end;

Wär nett, wenn sich einer meiner (Probleme) annehmen könnte

--

zum Seitenanfang zum Seitenende Profil || Suche
001
03.12.2002, 22:22
hausi



@1:
Pchar('C:\....\IEXplorer.exe')
ersetzen durch
Pchar('"C:\....\IEXplorer.exe" "http://www.bla.de/"')
@2:
Ich habe leider zu wenig Zeit, das gleich zu schreiben, gebe dir deshalb hier ein paar Code Snippets:
URL des IEs per DDE auslesen:
Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var
  DDE: TDDEClientConv;
begin
  DDE := TDDEClientConv.Create(self);
  if DDE.SetLink('IExplore', 'WWW_GetWindowInfo') then
    Memo1.Lines.Add(DDE.RequestData('0xFFFFFFFF,sURL,sTitle'));
  DDE.Free;
end;

Hier noch ein Zitat aus einem Forum (weiss nicht mehr genau welches; habs auf die HD kopiert :)):

Zitat:

I did the same job not long ago. The code works alright with Netscape but with IE you will run into a problem.

If you start IE and then open additional windows with the 'New Window' menu item, then you are running only ONE instance and you will get successfully all URLs.

BUT:

If you start a second instance of IE by clicking on the icon in your start menu a second.. then only one of your two instances will report DDE messages to your Delphi program. Usually the first started one seems to reply.

There is no clean solution around it.

I ended up enumerating top level windows and manually checking each top level window whether it was an IE instance. Then I would move through the child window chain with FindWindow(), GetWindowClass() and so on.. and retrieve the URL that way. The same code actually worked for IE 4, IE 5.0 and IE 5.5. I did not test with IE 6.

The code needed a modification for Netscape, naturally.


Und hier noch eine einfachere Möglichkeit IE zu "schliessen":
Quellcode:
function CloseIEs(Wnd: HWnd; Form: TForm1): Boolean; export; stdcall;
var
  sCap: array[0..255] of char;
begin
  GetWindowText(Wnd, sCap, sizeof(sCap));
  if pos('Microsoft Internet Explorer', sCap) > 0 then
  begin
    PostMessage(Wnd, WM_CLOSE, 0, 0);
  end
  else
  begin
    // check by class name!
    GetClassName(Wnd, sCap, sizeof(sCap));
    if sCap = 'IEFrame' then
      PostMessage(Wnd, WM_CLOSE, 0, 0);
  end;

  CloseIEs := true; { next window, please }
end;

begin
  // close all hidden instances
  EnumWindows(@CloseIEs, 0);
end.

Hoffe, konnte irgendwie helfen...

--

zum Seitenanfang zum Seitenende Profil || Suche
002
03.12.2002, 22:33
Doppelhertz



also beim 1. darf ich dich ma en bissel korrigieren, habs nämlich grad selber gemerkt, dass es ja ne variable für die parameter gibt, d.h.

ShellExecute(0, 'open', Pchar("C:\...."), pchar(' "http://www.thewall.de"'), nil ,SW_SHOW);

so geht des nämlich dann auch ;)
abba großen dank für die hilfe, den rest schau ich mir morgen ma an :)

--

zum Seitenanfang zum Seitenende Profil || Suche