Autor Beitrag
agent_x
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: Fr 10.08.07 09:21 
hallo,
ich möchte, dass in meinem programm der Benutzername angezeigt wird.
Ein Script hab ich gefunden:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
function GetUsername: String;
var
  Buffer: array[0..255of Char;
  Size: DWord;
begin
  Size := SizeOf(Buffer);
  if not Windows.GetUserName(Buffer, Size) then
    RaiseLastOSError; //RaiseLastWin32Error; {Bis D5};
  SetString(Result, Buffer, Size - 1);
end;
.
aber jetzt will ich, dass der Bn angezeigt wird. Wie geht das?
hathor
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 10.08.07 09:35 
Label1.Caption := GetUsername;
agent_x Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: Fr 10.08.07 09:44 
danke hat sich geklärt
und noch eins, wie kann man, dass machen das der Bn nicht erst angezeigt wird wenn man auf die
Label klickt sondern schon am anfang des Programms?
hier mein jetziger Code von der Label3 [ist die Label wo der Benutzername stehen soll]:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Label3click(Sender: TObject);
begin
Label3.Caption := GetUsername;
end;
arj
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 378

Win XP/Vista, Debian, (K)Ubuntu
Delphi 5 Prof, Delphi 7 Prof, C# (#Develop, VS 2005), Java (Eclipse), C++, QT, PHP, Python
BeitragVerfasst: Fr 10.08.07 12:15 
Das ganze ins FormShow oder FormCreate machen.
agent_x Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: Fr 10.08.07 12:20 
also so oder wie:?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm.FormCreate (Sender: TObject)
begin
 Label3.Caption := GetUsername;
end;
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Fr 10.08.07 12:24 
user profile iconagent_x hat folgendes geschrieben:
also so oder wie:?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm.FormCreate (Sender: TObject)
begin
 Label3.Caption := GetUsername;
end;

:zustimm:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
agent_x Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: Fr 10.08.07 12:25 
klappt aber irgend wie nit
arj
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 378

Win XP/Vista, Debian, (K)Ubuntu
Delphi 5 Prof, Delphi 7 Prof, C# (#Develop, VS 2005), Java (Eclipse), C++, QT, PHP, Python
BeitragVerfasst: Fr 10.08.07 12:31 
Hast du im Objektinspektor das Ereignis FormCreate auch der Methode zugewiesen?
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: Fr 10.08.07 13:48 
Klick einfach doppelt auf eine freie Stelle im Formular, und trage dann die Zeile Code in die von Delphi erstellte Prozedur ein.
agent_x Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 62

WIN 2000, Linux Kubuntu 6.06

BeitragVerfasst: Fr 10.08.07 15:36 
danke