2008. július 1., kedd
Working with delphi menus
Problem/Question/Abstract:
How to hack delphi environment (IDE)?
Answer:
This is just a sample application for interacting with Delphi IDE.U can use it more extensively. For invoking other applications u just need to change the menuclick event handler.
Given below is the full code. Compile this unit into a package and install the same.
unit SubhaExp;
interface
uses Windows, Menus, ExtCtrls, SysUtils, Forms, ToolsApi;
type
TSubhaMenu = class
private
FMainMenu: TMainMenu;
FFileMenu: TMenuItem;
FGiriMenu: TMenuItem;
procedure OnMenuItemClick(Sender: TObject);
public
procedure AddMenuItem;
procedure RemoveMenuItem;
end;
var
FSubhaMenu: TSubhaMenu;
procedure Register;
implementation
procedure TSubhaMenu.AddMenuItem;
var
i: Integer;
begin
FMainMenu := (BorlandIDEServices as INTAServices).MainMenu;
for i := 0 to FMainMenu.Items.Count - 1 do
begin
if AnsiSameCaption(FmainMenu.items[i].Caption, 'File') then
begin
FFileMenu := FMainMenu.items[i];
Break;
end;
end;
FGiriMenu := TMenuItem.Create(FFileMenu);
FGiriMenu.Caption := 'Subha IDE Services';
FGiriMenu.OnClick := OnMenuItemClick;
for i := 0 to FFileMenu.count - 1 do
begin
if FFileMenu.Items[i].isLine then
begin
FFileMenu.Insert(i, FGiriMenu);
Break;
end;
end;
end;
procedure TSubhaMenu.RemoveMenuItem;
var
i: Integer;
begin
for i := 0 to FFileMenu.Count - 1 do
begin
if AnsiSameCaption(FFileMenu.Items[i].Caption, 'Subha IDE Services') then
begin
FFileMenu.Remove(FFileMenu.items[i]);
Break;
end;
end;
end;
procedure TSubhaMenu.OnMenuItemClick(Sender: TObject);
begin
Application.MessageBox(PChar('This Is only a Simple Example' +
' to Work With Delphi IDE ' + #13#10 + ' For Further Details On This Contact' +
#13#10#13#10 + ' Subha@botree.co.in'), PChar('Message From Subha'), MB_OK);
end;
procedure Register;
begin
FSubhaMenu.AddMenuItem;
Application.MessageBox('Subha Narayanan Has Hacked Your ' +
' Delphi Environment !!! ' + #13#10 +
' See You Soon With Lot More Goodies !!! ' +
#13#10 + ' CopyRight (c) 2001, Subha Narayanan. ',
' Welcome To Delphi ', MB_SYSTEMMODAL);
end;
initialization
FSubhaMenu := TSubhaMenu.Create;
finalization
FSubhaMenu.RemoveMenuItem;
FSubhaMenu.Free;
end.
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése