home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Softwarová Záchrana 3
/
Softwarova-zachrana-3.bin
/
StartRight
/
source.zip
/
UnitUtils.pas
< prev
Wrap
Pascal/Delphi Source File
|
2004-10-05
|
1KB
|
57 lines
unit UnitUtils;
{
Purpose: Miscelanous procedures that don't belong anywhere
}
{///////////////}
{//}interface{//}
{///////////////}
procedure MySleep(milli : integer);
function GetUsername: String;
const UNKNOWN_USER = 'UnknownUser';
{////////////////////}
{//}implementation{//}
{////////////////////}
uses SysUtils, Windows, Forms;
procedure MySleep(milli : integer);
var i, j : integer;
begin
i := Windows.GetTickCount;
j := Windows.GetTickCount;
while ((j - i) <milli) do begin
Application.ProcessMessages;
sleep(100);
if (Application.Terminated) then EXIT;
j := Windows.GetTickCount;
end;
end;
function GetUsername: String;
var userName : array[0..MAX_PATH] of char;
r : Integer;
len : cardinal;
begin
result := UNKNOWN_USER;
{
try
}
FillChar(userName, sizeof(userName), #0);
len := sizeof(userName) - 1;
r := WNetGetUser(PChar(nil), userName, len);
if (r = 0) then begin
result := string(userName);
end;
{
except
end;
}
end;
end.