Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Login Name??? 1

Status
Not open for further replies.

BobbaFet

Programmer
Feb 25, 2001
903
0
0
NL
How can I figure out under which name a user has logged in
on a computer??? I cant seem to find anywhere in the
registry of Windows.

Thanx allot,

BobbaFet Everyone has a right to my opinion.
E-mail me at cwcon@programmer.net
 
Try

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  lpBuff : pchar;
  ret : longbool;
  ret2 : Cardinal;
begin
  ret2 := 25;
  ret := GetUserName(lpBuff,ret2);
  caption := lpbuff;
end;

Hope this helps

X-)

Billy H

bhogar@acxiom.co.uk
 
You can do all sorts of fancy stuff using the API calls of course, but does anyone know how to pull up the Windows icon selector.
I have seen this done in C++ builder, based on creating a function to handle the call..
I had a go at converting this to Delphi as follows but couldnt get it to work. any ideas guys.

type
TPickIconDlg = function(whandle: HWND; Name: pchar; N1:DWORD; N2: pointer): boolean;

//etc...
//and in form activate


shelllib := loadlibrary('Shell32.Dll');
if shelllib = 0 then
showmessage('SHELLDLL32 not found');

Address := chr(62); // this is supposed to be the proccess
address for the icon picker..

// according to the winapi help we can pass an Ordinal value to getprocaddres
// Not sure how though.
@PickIconDlg := GetProcAddress(Shelllib, Address);

// But we cant go round calling funtions without their parameters in Delphi..
// if pickiconDlg() = 0 then showmessage('PickIconDlg routine not found');

// finally

procedure TForm1.Button1Click(Sender: TObject);
var szfilename: array[0..255] of char;
IconIndex: DWORD;
begin
getmodulefilename(shelllib, szfilename,sizeof(szfilename));
edit1.text := inttostr(shelllib);
PickIcondlg(Form1.handle, szfilename, sizeof(szfilename),@iconindex);
end;


Steve..
 
sggaunt: In the past I've allways created my own Icon picker, that seems the simplest way to do it.

The code below provides the basis of this and in this example displays the ecions for 'shell32.dll'


As for as Address := chr(62); goes this has me puzzled as I do not seem to be able to track this entry point down and in the past have always passed in the method name.

A good app to view the functions in a DLL is Dependency Walker which comes as part of visual studio6

Code:
implementation

{$R *.DFM}

procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  index: integer;
begin
  index := ARow * DrawGrid1.ColCount + ACol;
  with Sender as TDrawGrid do
  begin
    Canvas.Brush.Color := clBackGround;
    Canvas.FillRect(Rect);
    ImageList1.Draw(Canvas,Rect.Left,Rect.Top,index);
    if gdFocused in State then
      Canvas.DrawFocusRect(Rect);
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
   NoOfIcons: integer;
   IconHandle : THandle;
   x:integer;
   tmp:string;
begin
   x:= -1;
   tmp := 'c:/winnt/system32/shell32.dll';
   NoOfIcons:=extracticon(handle,pchar(tmp),x);
   caption := tmp;
   caption := caption + 'No of Icons: '+inttostr(NoOfIcons);
   for x:= 0 to NoOfIcons-1 do
   begin
      image1.Picture.Icon.Handle:= extracticon(handle,pchar(tmp),x);
      imagelist1.Addicon(image1.Picture.Icon);
   end;
end;

X-) Billy H

bhogar@acxiom.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top