Selamat Datang !

Selamat Datang di Yus Waroeng Software ! Saya ucapkan terima kasih anda sudah masuk ke blog kami, dimana anda dapat mencari informasi Software Aplikasi yang anda butuhkan dan berbagi ilmu pemograman.
Cari Artikel

Saturday, March 29, 2008

Delphi - ActiveX


Membuka Internet Explorer dengan OLE

Ditulis dalam Delphi - ActiveX by yusfian gunawan maret 28, 2008

uses comobj;

procedure OpenIE(aURL: string);
var
IE: Variant;
WinHanlde: HWnd;
begin
if (VarIsEmpty(IE)) then
begin
IE := CreateOleObject(’InternetExplorer.Application’);
IE.Visible := True;
IE.Navigate(aURL);
end
else
begin
WinHanlde := FindWindow(’IEFrame’, nil);
if (0 <> WinHanlde) then
begin
IE.Navigate(aURL);
SetForegroundWindow(WinHanlde);
end
else
ShowMessage(’Can”t open IE !’);
end;
end;


Check if Word, Excel, Access, Outlook, Powerpoint is running


Ditulis dalam Delphi - ActiveX by yusfian gunawan maret 28, 2008

uses
ComObj, ActiveX;

function IsObjectActive(ClassName: string): Boolean;
var
ClassID: TCLSID;
Unknown: IUnknown;
begin
try
ClassID := ProgIDToClassID(ClassName);
Result := GetActiveObject(ClassID, nil, Unknown) = S_OK;
except
Result := False;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
if IsObjectActive(’Word.Application’) then ShowMessage(’Word is running !’);
if IsObjectActive(’Excel.Application’) then ShowMessage(’Excel is running !’);
if IsObjectActive(’Outlook.Application’) then ShowMessage(’Outlook is running !’);
if IsObjectActive(’Access.Application’) then ShowMessage(’Access is running !’);
if IsObjectActive(’Powerpoint.Application’) then ShowMessage(’Powerpoint is running !’);
end;

Send an e-mail through Outlook

Ditulis dalam Delphi - ActiveX by yusfian gunawan maret 28, 2008

uses
ComObj;

procedure TForm1.Button16Click(Sender: TObject);
const
olMailItem = 0;
olByValue = 1;
var
OutlookApp, MailItem, MyAttachments: OLEVariant;
begin
try
OutlookApp := GetActiveOleObject(’Outlook.Application’);
except
OutlookApp := CreateOleObject(’Outlook.Application’);
end;
try
MailItem := OutlookApp.CreateItem(olMailItem);
MailItem.Recipients.Add(’YourMailAddress@something.com’);
MailItem.Subject := ‘Your Subject’;
MailItem.Body := ‘Your Message’;
myAttachments := MailItem.Attachments;
myAttachments.Add(’C:\text.txt’, olByValue, 1, ‘Name of Attachment’);
MailItem.Send;
finally
myAttachments := VarNull;
OutlookApp := VarNull;
end;
end;


0 comments:

Post a Comment

Leave Your Comment Here!

Komentar Terbaru