如果是自己的,看以前的帖子,已经解决了。
如果是别人的,先用findwindow查找看看。
如果是别人的,先用findwindow查找看看。
解决方案 »
- Delphi 连接数据库高手进!
- 幫我寫一個Delphi循環語句,直到Table內的記錄爲空.然後分別求出各個字段的值.另外我要根據各字段的值進行計算,由計算結果update另一個Tab
- 密码和可用分被盗,请大家注意保护(ZT) 散分
- delphi里面画flash
- 请教!为什么Activeform编译成HTML,打开之后无法显示窗体?
- delphi 一个很简单的问题?
- 我只想知道怎样获得当前游览器的url 高分大放送
- 请问whois服务器那里有资料?
- 如何通过网络传送一个string类的数组
- 带压缩文件的发信、收信问题?(手头就这么点分,我还会继续加)
- 三级考试机试试题
- 在IE4下为何无法往工具条上增加按钮,也不能往菜单里增加菜单项?我该怎么办?
var hMutex: Hwnd;
Ret: integer;
begin
Application.Initialize;
Application.Title:='Program Run Once Test':
hMutex:=CreateMutex(nil,false,'Program Run Once Test');
Ret:=GetLastError;
if Ret<>Error_Already_Exists then
begin
Application.Create(TForm1,Form1);
Application.Run;
end
else
Application.MessageBox('This Program is running','Warning',MB_OK);
ReleaseMutex(hMutex);
end;
{
JustOne v1.1 - A Delphi Component
By: Steven L. Keyser
email: 71214,[email protected] ####################################################################
# Modified By He Kai, ZIQ, China, email : [email protected]
# Delphi 3.0 26-Jun-1998
# In order to use in Win95, I Modified the program, the original can only
# use in win31
#################################################################### Purpose: JustOne is a component which makes it easy to limit the
number of your application's instances to just one. If a second
instance of your application starts, the first instance is brought
to the front and given the focus (or restored if it was minimized
to an icon). The second instance then halts.}
unit Justone;interfaceuses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, DsgnIntf;type
TMyDataType = record
Name : string;
end;type
TJustOne = class(TComponent)
private
public
constructor Create(AOwner:TComponent); override;
destructor Destroy; override;
procedure GoToPreviousInstance;
published
end;procedure Register;type
PHWND = ^HWND;
// Modified By He Kai
// function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean; export;
function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean; export; stdcall;implementation{########################################################################}
procedure Register;
{If you want, replace 'SLicK' with whichever component page you want
JustOne to show up on.}
begin
RegisterComponents('HK Invisible', [TJustOne]);
end;{########################################################################}
// Modified by He Kai
{
function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean;
var
ClassName : array[0..30] of char;
begin
result := TRUE;
if GetWindowWord(Wnd,GWW_HINSTANCE) = hPrevInst then
begin
GetClassName(Wnd,ClassName,30);
if StrIComp(ClassName,'TApplication') = 0 then
begin
TargetWindow^ := Wnd;
result := FALSE;
end;
end;
end;
}
// Modified By He Kai
// function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean;
function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean;
var
TheClassName : array[0..200] of char;
TheTitleName : array[0..200] of char;
ThisTitleName : String;
begin
result := TRUE;
GetClassName(Wnd,TheClassName,200);
if StrIComp( TheClassName,'TApplication' ) = 0 then
begin
GetWindowText( Wnd, TheTitleName, 200 );
ThisTitleName := Application.Title;
If (Wnd<>Application.Handle) And (StrIComp( PChar(ThisTitleName), TheTitleName ) = 0) Then
Begin
TargetWindow^ := Wnd;
result := FALSE;
End;
End;
end;{########################################################################}
procedure TJustOne.GotoPreviousInstance;
var
PrevInstWnd : HWND;
begin
PrevInstWnd := 0;
EnumWindows(@EnumFunc,longint(@PrevInstWnd)); if PrevInstWnd <> 0 then
Begin
if IsIconic(PrevInstWnd) then
ShowWindow(PrevInstWnd,SW_RESTORE)
else
SetForegroundWindow(PrevInstWnd);
FlashWindow(PrevInstWnd, True );
Sleep(450);
FlashWindow(PrevInstWnd, false );
Sleep(450);
FlashWindow(PrevInstWnd, True );
Sleep(450);
FlashWindow(PrevInstWnd, false );
Halt;
End
end;{########################################################################}
constructor TJustOne.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
// modified by He Kai
// if hPrevInst <> 0 then
// begin
GotoPreviousInstance;
// halt;
// end;
end;{########################################################################}
destructor TJustOne.Destroy;
begin
inherited Destroy;
end;{########################################################################}
end.
{
JustOne v1.1 - A Delphi Component
By: Steven L. Keyser
email: 71214,[email protected] ####################################################################
# Modified By He Kai, ZIQ, China, email : [email protected]
# Delphi 3.0 26-Jun-1998
# In order to use in Win95, I Modified the program, the original can only
# use in win31
#################################################################### Purpose: JustOne is a component which makes it easy to limit the
number of your application's instances to just one. If a second
instance of your application starts, the first instance is brought
to the front and given the focus (or restored if it was minimized
to an icon). The second instance then halts.}
unit Justone;interfaceuses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, DsgnIntf;type
TMyDataType = record
Name : string;
end;type
TJustOne = class(TComponent)
private
public
constructor Create(AOwner:TComponent); override;
destructor Destroy; override;
procedure GoToPreviousInstance;
published
end;procedure Register;type
PHWND = ^HWND;
// Modified By He Kai
// function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean; export;
function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean; export; stdcall;implementation{########################################################################}
procedure Register;
{If you want, replace 'SLicK' with whichever component page you want
JustOne to show up on.}
begin
RegisterComponents('HK Invisible', [TJustOne]);
end;{########################################################################}
// Modified by He Kai
{
function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean;
var
ClassName : array[0..30] of char;
begin
result := TRUE;
if GetWindowWord(Wnd,GWW_HINSTANCE) = hPrevInst then
begin
GetClassName(Wnd,ClassName,30);
if StrIComp(ClassName,'TApplication') = 0 then
begin
TargetWindow^ := Wnd;
result := FALSE;
end;
end;
end;
}
// Modified By He Kai
// function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean;
function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean;
var
TheClassName : array[0..200] of char;
TheTitleName : array[0..200] of char;
ThisTitleName : String;
begin
result := TRUE;
GetClassName(Wnd,TheClassName,200);
if StrIComp( TheClassName,'TApplication' ) = 0 then
begin
GetWindowText( Wnd, TheTitleName, 200 );
ThisTitleName := Application.Title;
If (Wnd<>Application.Handle) And (StrIComp( PChar(ThisTitleName), TheTitleName ) = 0) Then
Begin
TargetWindow^ := Wnd;
result := FALSE;
End;
End;
end;{########################################################################}
procedure TJustOne.GotoPreviousInstance;
var
PrevInstWnd : HWND;
begin
PrevInstWnd := 0;
EnumWindows(@EnumFunc,longint(@PrevInstWnd)); if PrevInstWnd <> 0 then
Begin
if IsIconic(PrevInstWnd) then
ShowWindow(PrevInstWnd,SW_RESTORE)
else
SetForegroundWindow(PrevInstWnd);
FlashWindow(PrevInstWnd, True );
Sleep(450);
FlashWindow(PrevInstWnd, false );
Sleep(450);
FlashWindow(PrevInstWnd, True );
Sleep(450);
FlashWindow(PrevInstWnd, false );
Halt;
End
end;{########################################################################}
constructor TJustOne.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
// modified by He Kai
// if hPrevInst <> 0 then
// begin
GotoPreviousInstance;
// halt;
// end;
end;{########################################################################}
destructor TJustOne.Destroy;
begin
inherited Destroy;
end;{########################################################################}
end.
{
JustOne v1.1 - A Delphi Component
By: Steven L. Keyser
email: 71214,[email protected] ####################################################################
# Modified By He Kai, ZIQ, China, email : [email protected]
# Delphi 3.0 26-Jun-1998
# In order to use in Win95, I Modified the program, the original can only
# use in win31
#################################################################### Purpose: JustOne is a component which makes it easy to limit the
number of your application's instances to just one. If a second
instance of your application starts, the first instance is brought
to the front and given the focus (or restored if it was minimized
to an icon). The second instance then halts.}
unit Justone;interfaceuses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, DsgnIntf;type
TMyDataType = record
Name : string;
end;type
TJustOne = class(TComponent)
private
public
constructor Create(AOwner:TComponent); override;
destructor Destroy; override;
procedure GoToPreviousInstance;
published
end;procedure Register;type
PHWND = ^HWND;
// Modified By He Kai
// function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean; export;
function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean; export; stdcall;implementation{########################################################################}
procedure Register;
{If you want, replace 'SLicK' with whichever component page you want
JustOne to show up on.}
begin
RegisterComponents('HK Invisible', [TJustOne]);
end;{########################################################################}
// Modified by He Kai
{
function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean;
var
ClassName : array[0..30] of char;
begin
result := TRUE;
if GetWindowWord(Wnd,GWW_HINSTANCE) = hPrevInst then
begin
GetClassName(Wnd,ClassName,30);
if StrIComp(ClassName,'TApplication') = 0 then
begin
TargetWindow^ := Wnd;
result := FALSE;
end;
end;
end;
}
// Modified By He Kai
// function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean;
function EnumFunc(Wnd:HWND; TargetWindow:PHWND): boolean;
var
TheClassName : array[0..200] of char;
TheTitleName : array[0..200] of char;
ThisTitleName : String;
begin
result := TRUE;
GetClassName(Wnd,TheClassName,200);
if StrIComp( TheClassName,'TApplication' ) = 0 then
begin
GetWindowText( Wnd, TheTitleName, 200 );
ThisTitleName := Application.Title;
If (Wnd<>Application.Handle) And (StrIComp( PChar(ThisTitleName), TheTitleName ) = 0) Then
Begin
TargetWindow^ := Wnd;
result := FALSE;
End;
End;
end;{########################################################################}
procedure TJustOne.GotoPreviousInstance;
var
PrevInstWnd : HWND;
begin
PrevInstWnd := 0;
EnumWindows(@EnumFunc,longint(@PrevInstWnd)); if PrevInstWnd <> 0 then
Begin
if IsIconic(PrevInstWnd) then
ShowWindow(PrevInstWnd,SW_RESTORE)
else
SetForegroundWindow(PrevInstWnd);
FlashWindow(PrevInstWnd, True );
Sleep(450);
FlashWindow(PrevInstWnd, false );
Sleep(450);
FlashWindow(PrevInstWnd, True );
Sleep(450);
FlashWindow(PrevInstWnd, false );
Halt;
End
end;{########################################################################}
constructor TJustOne.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
// modified by He Kai
// if hPrevInst <> 0 then
// begin
GotoPreviousInstance;
// halt;
// end;
end;{########################################################################}
destructor TJustOne.Destroy;
begin
inherited Destroy;
end;{########################################################################}
end.