Autor Beitrag
Xeron
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP Home, Vista Home Premium 64Bit, Win7 Home Premium
Delphi 3 Prof, Delphi 7 Personal, Delphi 2010 Prof., AutoIt
BeitragVerfasst: Sa 03.04.10 21:59 
Hi, ich schreibe grade eine kleine Anwendung in Delphi. Nix großes oder bedeutsames.

In meinem Quelltext will ich eine Zahl übergeben, das klappt aber nicht.
Zum Test habe ich daher eine simple Dll gemacht, die das Handle einer Anwendung rückgeben soll

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
library Project2;

uses
  SysUtils, Windows,
  Classes;

{$R *.res}

function GetHandle(Titel: PChar): Hwnd;
var wnd: HWnd;
begin
  wnd := FindWindow(nil, Titel);
  if wnd <> 0 then
    Result := wnd;
end;

begin
end.


ausblenden Delphi-Quelltext
1:
[Warnung] Project2.dpr(15): Rückgabewert der Funktion 'GetHandle' könnte undefiniert sein					


Was ist daran bitte falsch?
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Sa 03.04.10 22:02 
wenn wnd = 0 ist, wird result niemals ein Wert zugewiesen. Somit steht da irgendeine Zahl drin.
Nimm die If-Abfrage raus, und vergleich in der aufrufenden Funktion auf 0 oder nicht.

_________________
PROGRAMMER: A device for converting coffee into software.
Xeron Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 41

WinXP Home, Vista Home Premium 64Bit, Win7 Home Premium
Delphi 3 Prof, Delphi 7 Personal, Delphi 2010 Prof., AutoIt
BeitragVerfasst: Sa 03.04.10 22:05 
ahh, ok. Es klappt. Danke