+62 812-1171-5379 Fast Respond

Tips dan Trik Delphi

Menggeser panel pada form / Form / Windows / Delphi 7 - XE


Procedure GeserPanel(NamaPanel : TPanel);
const
    SC_DragMove = $F012; {a magic number }
begin
    ReleaseCapture;
    NamaPanel.Perform(WM_SysCommand, SC_DragMove, 0);
End;

Mendeteksi IP Lokal komputer windows / Windows / Windows / Delphi 7 - XE


Gunakan Uses Winsock;
function LocalIP: string;
type
  TaPInAddr = array[0..10] of PInAddr;
  PaPInAddr = ^TaPInAddr;
var
  phe: PHostEnt;
  pptr: PaPInAddr;
  Buffer: array[0..63] of Char;
  I: Integer;
  GInitData: TWSAData;
begin
    WSAStartup($101, GInitData);
    Result := '';
    GetHostName(Buffer, SizeOf(Buffer));
    phe := GetHostByName(buffer);
    if phe = nil then Exit;
    pPtr := PaPInAddr(phe^.h_addr_list);
    I := 0;
    while pPtr^[I] <> nil do
    begin
         Result := inet_ntoa(pptr^[I]^);
         Inc(I);
    end;
    WSACleanup;
end;


Mendeteksi nama user login windows yang sedang aktif pada windows / Windows / Windows / Delphi 7 - XE


function GetNetUserName: string;
var
  pcUser: PChar;
  dwUSize: DWORD;
begin
  dwUSize := 21;              // user name can be up to 20 characters
  GetMem(pcUser, dwUSize);    // allocate memory for the string
  try
    if NO_ERROR = WNetGetUser(0, pcUser, dwUSize)
      then Result := pcUser;
  finally
    FreeMem(pcUser);
  end;
end;

Mendeteksi nama komputer pada sistem operasi windows / Windows / Windows / Delphi 7 - XE


Function getNetComputername : String;
Var
  PcName: array[0..256] of Char;
  dwUSize: DWORD;
Begin
     dwUSize := 255;
     if GetComputerName(PcName, dwUSize) Then
     Begin
         Result:=pcname;
     end else
     Begin

     end;
end;