Einzelnen Beitrag anzeigen

Benutzerbild von turboPASCAL
turboPASCAL

Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
 
Delphi 6 Personal
 

Re: Logo des Users vom Anmeldebildsch. holen, aber wie ?

  Alt 24. Aug 2006, 20:14
Zitat von faux:
Das ganze wird nicht so einfach werden, wie es scheint, denn Delphi hat anscheinend Probleme mit diesen Icons...
Delphi ja, Windows nein. Verwende einfach LoadImage dann werden die Icons (Bitmaps) richtig Dargestellt.

Delphi-Quellcode:
implementation

{$R *.dfm}

uses
  ShlObj;

function TForm1.CommonDataPath: string;
const
  CSIDL_COMMON_APPDATA = $0023; // All Users\Application Data
var
  Path: array [0..1024] of char;
begin
  if SHGetSpecialFolderPath(Handle, Path, CSIDL_COMMON_APPDATA, TRUE)
    then Result := String(path)
    else Result := '';
end;

function TForm1.GetCurrentUserName: String;
var
  pcUserName : pChar; // temporary storage
  dwMaxChars : dWord; // length parameter
const
  MAXCHARS = 255; // max length
begin
  dwMaxChars := MAXCHARS;
  GetMem(pcUserName, MAXCHARS + 1);
  if GetUserName(pcUserName, dwMaxChars)
    then Result := String(pcUserName)
    else Result := '';
  FreeMem(pcUserName);
end;

procedure TForm1.FormCreate(Sender: TObject);
var LgPath: String;
begin
  Label1.Caption := GetCurrentUserName;

  LgPath := CommonDataPath + '\Microsoft\User Account Pictures\' +
            Label1.Caption + '.bmp';

  if FileExists(LgPath) then
  begin
    Image1.Picture.Bitmap.Handle :=
      LoadImage(0, PChar(LgPath), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
  end else
    ShowMessage(format('%s'#13#10'"%s"', ['Datei nicht gefunden:', LgPath]));
end;
Matti
Meine Software-Projekte - Homepage - Grüße vom Rüsselmops -Mops Mopser
  Mit Zitat antworten Zitat