본문 바로가기

delphi

Delphi Tips #1

반응형
SMALL

윈도우 사용자 이름 

nSize :=  MAX_COMPUTERNAME_LENGTH + 1;

SetLength(szBuffer,NSize);

GetUserName(Pchar(szBuffer),nSize);

컴퓨터 이름
GetComputerName(Pchar(szBuffer),nSize);
------------------------------------------------------------

프로그램 추가삭제에서 뜨는 목록 보기
const
  UNINST_PATH = 'Software\Microsoft\Windows\CurrentVersion\Uninstall';
var
  Reg : TRegistry;
  SubKey: TSTringList;
  I : Integer;
  sDisplayName : String;
begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.OpenKeyReadOnly(UNINST_PATH) then
    begin
      SubKey := TStringList.Create;
      try
        Reg.GetKeyNames(SubKey);
        Reg.CloseKey;
        for i := 0 to subKey.Count - 1 do
        begin
          if Reg.OpenKeyReadOnly(Format('%s\%s', [UNINST_PATH, SubKey[i]])) then
          begin
            try
              sDisplayName := Reg.ReadString('DisplayName');
              if  ((sDisplayName) <> '') and
                  (Pos('업데이트',sDisplayName) = 0) and
                  (Pos('HOTFIX',UpperCase(sDisplayName)) = 0) and
                  (Pos('핫픽스',sDisplayName) = 0) then
              begin
                    //-------TODO--------
                    //---------------------
              end;
            finally
              Reg.CloseKey;
            end;
          end;
        end;
      finally
        SubKey.Free;
      end;
    end;
  finally
    Reg.CloseKey;
    reg.Free;
  end;
end;
//---------아웃룩으로 이메일 보내기---------------
    try
      OutlookApp := GetActiveOleObject('Outlook.Application');
    except
      OutlookApp := CreateOleObject('Outlook.Application');
    end;

    try
      MailItem := OutlookApp.CreateItem(olMailItem);
      MailItem.Recipients.Add(메일주소);

      MailItem.Subject := edt_User.Text + '  Program List';

      MailItem.Body := '내용'
      MailItem.Attachments.Add(경로);
      MailItem.Send;
      //MailItem.Display(True);

    finally
      myAttachments := VarNull;
      OutlookApp := VarNull;
    end;
//------------------------------------------------

 

출처 : http://beehone.egloos.com/2601505

반응형
LIST