如何將程式轉成系統程式 |
答題得分者是:pascal
|
mcho
初階會員 發表:57 回覆:106 積分:42 註冊:2002-11-11 發送簡訊給我 |
|
pascal
一般會員 發表:1 回覆:2 積分:5 註冊:2004-01-24 發送簡訊給我 |
我看不懂你所說的「轉成系統程式」是什麼意思。 但是,我可以告訴你,希望它執行在螢幕的右下角,有兩個關鍵點, 第一,利用 TTrayIcon 元件,使程式執行於右下角。 TTrayIcon 請到http://vcl.vclxx.org/DELPHI/DEFAULT.HTM 下載。 第二,開機自動執行。
此必須在 Registry 的 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run 內寫上你希望系統開機時執行的程式名稱。 想要做到這種效果,只要是一般程式即可。不必是什麼「系統程式」。 ---Pascal
|
syntax
尊榮會員 發表:26 回覆:1139 積分:1258 註冊:2002-04-23 發送簡訊給我 |
|
mcho
初階會員 發表:57 回覆:106 積分:42 註冊:2002-11-11 發送簡訊給我 |
|
pedro
尊榮會員 發表:152 回覆:1187 積分:892 註冊:2002-06-12 發送簡訊給我 |
|
mcho
初階會員 發表:57 回覆:106 積分:42 註冊:2002-11-11 發送簡訊給我 |
我已安裝且產生喇叭元件
unit TrayIcon;
(* TTrayIcon Version 1.4 Requires: Any 32-bit version of Delphi (2 or greater) Function: Adds an icon to the Windows 95 Tool Tray and
has events to respond to mouse clicks. Original author: Derek Stutsman (dereks@metronet.com)
Second author: Pete Ness (102347.710@compuserve.com)
Third author: Greg Lief (greg@greglief.com)
Fourth author: Jesse C. Slicer (jslicer@planetkc.com) Release history: 3/8/96 - Version 1.0 (Derek Stutsman)
Initial release as TToolIcon. 3/12/96 - Version 1.1 (Pete Ness) Various changes, renamed to TTrayIcon. 3/29/96 - Version 1.2 (Pete Ness)
Add default window handling to allow closing when Win95 shutdown.
Previously, you had to manually close your application before closing
Windows 95. 4/17/96 - Version 1.3 (Pete Ness)
Added a PopupMenu property to automatically handle right clicking on
the tray icon.
Fixed bug that would not allow you to instantiate a TTrayIcon instance
at run-time. 7/23/98 - Version 1.4 (Greg Lief)
Added Images, Animate, and AnimateInterval properties, all of which
serve to simplify the task of animating the tray icon. Steps: 1) Drop a TImageList component on your form and load it with the
desired icons.
2) Plug it into the TTrayIcon component via the Images property.
3) Set the Active and Animate properties to True.
4) Tweak the AnimateInterval property as desired. 1999-Jul-28 - Version 1.5 (Jesse C. Slicer)
- Dynamically request a window message for WM_TOOLTRAYICON and
WM_RESETTOOLTIP instead of WM_USER 1 and WM_USER 2, respectively. Many
apps use the WM_USER x methods and doing dynamically keeps conflicts from
occurring.
- Separated the different NIF_ tray icon notification messages for
improved efficiency. No need to continuously set the uCallbackMessage
parameter if only the icon is being changed. 17/2/2000 - Version 1.6 (Ferran Pi鎙na - ferran77@menta.net)
- Removed the annoying credits message. If you into SM, you can
re-enable it.
- Added ability to easy load an concrete image in runtime (SetTrayIcon). 17/2/2000 - Version 1.61 (Ferran Pi鎙na - ferran77@menta.net)
- Added the INCREDIBILY NECESSARY property HideAppOnActive
*) interface
uses
Windows, Messages, Classes, Graphics, Controls, ShellAPI, Menus, ExtCtrls,
Forms; const
sWM_TOOLTRAYICON: PChar = 'WM_TOOLTRAYICON';
sWM_RESETTOOLTIP: PChar = 'WM_RESETTOOLTIP';
iDEFAULT_ANIMATE_INTERVAL = 100; var
WM_TOOLTRAYICON : UINT = 0;
WM_RESETTOOLTIP : UINT = 0; type
TModIconTypes = (modUnknown, modMessage, modIcon, modToolTip);
TModIconOps = set of TModIconTypes; TTrayIcon = class(TComponent)
private
//Private declarations
IconData : TNotifyIconData;
FAnimate,
FHide,
FActive,
FShowDesigning: Boolean;
FAnimateInterval,
FCurrentImage : Integer;
FIcon,
FOriginalIcon : TIcon; //storage location used if developer chooses to animate tray icon
FToolTip : string;
FWindowHandle : HWND;
FTimer : TTimer;
FOnClick,
FOnDblClick : TNotifyEvent;
FOnRightClick : TMouseEvent;
FPopupMenu : TPopupMenu;
FImages : TImageList; function AddIcon: Boolean;
function ModifyIcon(modIconOps: TModIconOps): Boolean;
function DeleteIcon: Boolean; procedure SetHide(bValue: Boolean);
procedure SetActive(bValue: Boolean);
procedure SetAnimate(bValue: Boolean);
procedure SetAnimateInterval(iValue: Integer);
procedure SetShowDesigning(bValue: Boolean);
procedure SetIcon(icnValue: TIcon);
procedure SetToolTip(const sValue: string);
procedure WndProc(var msg: TMessage); procedure FillDataStructure(modIconOps: TModIconOps);
procedure ChangeIcon(Sender: TObject); protected
//Protected declarations
procedure Notification(AComponent: TComponent;
Operation : TOperation); override;
procedure DoDblClick(Sender: TObject);
procedure DoClick(Sender: TObject);
procedure DoRightClick(Sender: TObject); public
//Public declarations
constructor Create(AOwner: TComponent); override;
destructor Destroy; override; property Handle : HWND read FWindowHandle; published
//Published declarations
property HideAppOnActive: Boolean read FHide write SetHide;
property Active : Boolean read FActive write SetActive;
property Animate : Boolean read FAnimate write SetAnimate;
property AnimateInterval: Integer read FAnimateInterval write SetAnimateInterval default iDEFAULT_ANIMATE_INTERVAL;
property ShowDesigning : Boolean read FShowDesigning write SetShowDesigning;
property Icon : TIcon read FIcon write SetIcon;
property Images : TImageList read FImages write FImages;
property ToolTip : string read FTooltip write SetToolTip; property OnClick : TNotifyEvent read FOnClick write FOnClick;
property OnDblClick : TNotifyEvent read FOnDblClick write FOnDblClick;
property OnRightClick : TMouseEvent read FOnRightClick write FonRightClick;
property PopupMenu : TPopupMenu read FPopupMenu write FPopupMenu; Procedure SetTrayIcon(Sender: TObject; Const IconIndex:Integer);
end; procedure Register; implementation
uses
Dialogs, SysUtils; const
cCR = #13; {$R TrayIcon.res} //------------------------------------------------------------------------------
constructor TTrayIcon.Create(AOwner: TComponent);
{resourcestring
rsAboutBox = 'TTrayIcon version 1.5' cCR
'Original author: Derek Stutsman' cCR
'More mods by Pete Ness' cCR
'Yet more mods by Greg Lief' cCR
'Even more mods by Jesse C. Slicer' cCR
'Retouches by Ferran Pi鎙na';} begin //constructor TTrayIcon.Create
inherited Create(AOwner);
FWindowHandle := AllocateHWnd(WndProc);
WM_TOOLTRAYICON := RegisterWindowMessage(sWM_TOOLTRAYICON);
WM_RESETTOOLTIP := RegisterWindowMessage(sWM_RESETTOOLTIP);
FIcon := TIcon.Create;
FOriginalIcon := TIcon.Create;
FAnimateInterval := iDEFAULT_ANIMATE_INTERVAL;
FTimer := TTimer.Create(Self);
with FTimer do
begin //with
Enabled := False;
OnTimer := ChangeIcon;
end; //with
{ if csDesigning in ComponentState then
MessageDlg(rsAboutBox, mtInformation, [mbOK], 0); ***La propaganda us la foteu pel cul, h瓋tia!***
}
end; //constructor TTrayIcon.Create //------------------------------------------------------------------------------
destructor TTrayIcon.Destroy;
begin //destructor TTrayIcon.Destroy
if (not (csDesigning in ComponentState) and FActive) or
((csDesigning in ComponentState) and FShowDesigning) then
DeleteIcon;
FTimer.Free;
FOriginalIcon.Free;
FIcon.Free;
DeAllocateHWnd(FWindowHandle);
inherited Destroy;
end; //destructor TTrayIcon.Destroy //------------------------------------------------------------------------------
procedure TTrayIcon.Notification(AComponent: TComponent;
Operation : TOperation);
begin //procedure TTrayIcon.Notification
if (AComponent = FImages) and (Operation = opRemove) then
begin //if..then
Animate := False;
FImages := nil;
end; //if..then
end; //procedure TTrayIcon.Notification //------------------------------------------------------------------------------
procedure TTrayIcon.DoDblClick(Sender: TObject);
begin //procedure TTrayIcon.DoDblClick
if Assigned(FOnDblClick) then
FOnDblClick(Sender);
end; //procedure TTrayIcon.DoDblClick //------------------------------------------------------------------------------
procedure TTrayIcon.DoClick(Sender: TObject);
begin //procedure TTrayIcon.DoClick
if Assigned(FOnClick) then
FOnClick(Sender);
end; //procedure TTrayIcon.DoClick //------------------------------------------------------------------------------
procedure TTrayIcon.DoRightClick(Sender: TObject);
var
MouseCo: TPoint;
begin //procedure TTrayIcon.DoRightClick
GetCursorPos(MouseCo);
if Assigned(FPopupMenu) then
begin //if..then
SetForegroundWindow(Application.Handle);
Application.ProcessMessages;
FPopupMenu.Popup(MouseCo.x, MouseCo.y);
end; //if..then
if Assigned(FOnRightClick) then
FOnRightClick(Sender, mbRight, [], MouseCo.x, MouseCo.y);
end; //procedure TTrayIcon.DoRightClick //------------------------------------------------------------------------------
function TTrayIcon.AddIcon: Boolean;
begin //function TTrayIcon.AddIcon
FillDataStructure([modMessage, modIcon, modToolTip]);
Result := Shell_NotifyIcon(NIM_ADD, @IconData);
//For some reason, if there is no tool tip set up, then the icon
//doesn't display. This fixes that.
if FToolTip = '' then
PostMessage(FWindowHandle, WM_RESETTOOLTIP, 0, 0);
end; //function TTrayIcon.AddIcon //------------------------------------------------------------------------------
function TTrayIcon.ModifyIcon(modIconOps: TModIconOps): Boolean;
begin //function TTrayIcon.ModifyIcon
FillDataStructure(modIconOps);
if FActive then
Result := Shell_NotifyIcon(NIM_MODIFY, @IconData)
else
Result := True;
end; //function TTrayIcon.ModifyIcon //------------------------------------------------------------------------------
function TTrayIcon.DeleteIcon: Boolean;
begin //function TTrayIcon.DeleteIcon
Result := Shell_NotifyIcon(NIM_DELETE, @IconData);
end; //function TTrayIcon.DeleteIcon //------------------------------------------------------------------------------
procedure TTrayIcon.SetHide(bValue: Boolean);
Begin
FHide:=bValue;
End; //------------------------------------------------------------------------------
procedure TTrayIcon.SetActive(bValue: Boolean);
begin //procedure TTrayIcon.SetActive
if bValue <> FActive then
begin //if..then
FActive := bValue;
if not (csdesigning in ComponentState) then
if FActive then
Begin
If FHide Then ShowWindow(Application.Handle, SW_HIDE);
AddIcon;
End
else
Begin
If FHide Then ShowWindow(Application.Handle, SW_SHOW);
DeleteIcon;
End;
end; //if..then
end; //procedure TTrayIcon.SetActive //------------------------------------------------------------------------------
procedure TTrayIcon.SetAnimate(bValue: Boolean);
begin //procedure TTrayIcon.SetAnimate
if (not bValue) or
(Assigned(FImages) and (FImages.Count > 0) and FActive) then
begin //if..then 1
FAnimate := bValue;
if FAnimate then
begin //if..then 2
FOriginalIcon.Assign(fIcon);
FCurrentImage := 0;
end; //if..then 2
FTimer.Enabled := FAnimate;
if not bValue then
SetIcon(FOriginalIcon);
end; //if..then 1
end; //procedure TTrayIcon.SetAnimate //------------------------------------------------------------------------------
procedure TTrayIcon.SetAnimateInterval(iValue: Integer);
begin //procedure TTrayIcon.SetAnimateInterval
if iValue > 0 then
begin //if..then
FAnimateInterval := iValue;
FTimer.Interval := FAnimateInterval;
end; //if..then
end; //procedure TTrayIcon.SetAnimateInterval //------------------------------------------------------------------------------
procedure TTrayIcon.SetShowDesigning(bValue: Boolean);
begin //procedure TTrayIcon.SetShowDesigning
if csDesigning in ComponentState then
if bValue <> FShowDesigning then
begin //if..then
FShowDesigning := bValue;
if FShowDesigning then
AddIcon
else
DeleteIcon;
end; //if..then
end; //procedure TTrayIcon.SetShowDesigning //------------------------------------------------------------------------------
procedure TTrayIcon.SetIcon(icnValue: TIcon);
begin //procedure TTrayIcon.SetIcon
if icnValue <> FIcon then
begin //if..then
FIcon.Assign(icnValue);
ModifyIcon([modIcon]);
end; //if..then
end; //procedure TTrayIcon.SetIcon //------------------------------------------------------------------------------
procedure TTrayIcon.SetToolTip(const sValue: string);
begin //procedure TTrayIcon.SetToolTip
//This routine ALWAYS re-sets the field value and re-loads the
//icon. This is so the ToolTip can be set blank when the component
//is first loaded. If this is changed, the icon will be blank on
//the tray when no ToolTip is specified.
FToolTip := Copy(sValue, 1, 62);
ModifyIcon([modToolTip, modIcon]);
end; //procedure TTrayIcon.SetToolTip //------------------------------------------------------------------------------
procedure TTrayIcon.WndProc(var msg: TMessage);
begin //procedure TTrayIcon.WndProc
with msg do
if msg = WM_RESETTOOLTIP then
SetToolTip(FToolTip)
else
if msg = WM_TOOLTRAYICON then
case lParam of
WM_LBUTTONDBLCLK: DoDblClick(Self);
WM_LBUTTONUP : DoClick(Self);
WM_RBUTTONUP : DoRightClick(Self);
end
else //Handle all messages with the default handler
Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);
end; //procedure TTrayIcon.WndProc //------------------------------------------------------------------------------
procedure TTrayIcon.FillDataStructure(modIconOps: TModIconOps);
begin //procedure TTrayIcon.FillDataStructure
with IconData do
begin //with
cbSize := SizeOf(TNotifyIconData);
wnd := FWindowHandle;
uID := 0; //is not passed in with message so make it 0
uFlags := 0;
if modMessage in modIconOps then
begin //if..then
uFlags := uFlags or NIF_MESSAGE;
uCallbackMessage := WM_TOOLTRAYICON;
end; //if..then
if modIcon in modIconOps then
begin //if..then
uFlags := uFlags or NIF_ICON;
hIcon := FIcon.Handle;
end; //if..then
if modToolTip in modIconOps then
begin //if..then
uFlags := uFlags or NIF_TIP;
StrPCopy(szTip, FToolTip);
end; //if..then
end; //with
end; //procedure TTrayIcon.FillDataStructure //------------------------------------------------------------------------------
procedure TTrayIcon.ChangeIcon(Sender: TObject);
var
icnTempIcon: TIcon;
begin //procedure TTrayIcon.ChangeIcon
icnTempIcon := TIcon.Create;
try
if FCurrentImage = Pred(FImages.Count) then
FCurrentImage := 0
else
Inc(FCurrentImage);
FImages.GetIcon(FCurrentImage, icnTempIcon);
SetIcon(icnTempIcon);
finally
icnTempIcon.Free;
end; //try..finally
end; //procedure TTrayIcon.ChangeIcon //------------------------------------------------------------------------------
Procedure TTrayIcon.SetTrayIcon(Sender: TObject; Const IconIndex:Integer);
var
icnTempIcon: TIcon;
begin
If (Assigned(FImages)) And Not(IconIndex>=FImages.Count) Then
Begin
SetAnimate(False);
icnTempIcon:=TIcon.Create;
try
FCurrentImage:=IconIndex;
FImages.GetIcon(FCurrentImage, icnTempIcon);
SetIcon(icnTempIcon);
finally
icnTempIcon.Free;
End;
end;
end; //------------------------------------------------------------------------------
procedure Register;
begin //procedure Register
RegisterComponents('Win32', [TTrayIcon]);
end; //procedure Register //------------------------------------------------------------------------------
end. //unit TrayIcon 何明昌
------
何明昌 |
mcho
初階會員 發表:57 回覆:106 積分:42 註冊:2002-11-11 發送簡訊給我 |
|
mcho
初階會員 發表:57 回覆:106 積分:42 註冊:2002-11-11 發送簡訊給我 |
我會了!如下做法可達到我的要求:
執行完程式後:
ProgInstNo:= FindWindow(Nil,PChar('LocalTim'));
ShowWindow(FindWindow(Nil,PChar('LocalTim')),SW_MINIMIZE);
ShowWindow(ProgInstNo,SW_HIDE);
lWinHide := true; procedure TForm1.TrayIcon1DblClick(Sender: TObject);
var ProgInstNo:integer;
begin
ProgInstNo:= FindWindow(Nil,PChar('LocalTim'));
ShowWindow(ProgInstNo,SW_SHOWNORMAL);
lWinHide := False;
end; 何明昌
------
何明昌 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |