我借用别人的一个程序改了一下,希望对你有用。第二次运行可激活程序窗口
Public Handle
DECLARE INTEGER CreateFileMapping IN kernel32.DLL INTEGER hFile, ;
INTEGER lpFileMappingAttributes,integer flProtect, ;
INTEGER dwMaximumSizeHigh, INTEGER dwMaximumSizeLow, ;
STRING lpName
DECLARE INTEGER GetLastError IN kernel32.DLL
DECLARE INTEGER CloseHandle IN kernel32.DLL INTEGER hObject
Declare Integer FindWindow In Win32api String, String
Declare Long BringWindowToTop In Win32API Long
Declare Long ShowWindow In Win32API Long, Long
szname="hello"
Handle = CreateFilemapping(0xFFFFFFFF,0,4,0,128,szname)
If handle = 0
Wait Windows "CreateFileMapping 失败 - LastError: " ;
+ Ltrim(Str(GetLastError()))
Return
ENDIF
cTitle="城镇居民医疗保险管理系统"
If Handle=0
Messagebox("内存映谢文件创建失败!",46,"错误")
Clear Events
Return .F.
Else
If GetLastError()=183
Handle=FindWindow(0,cTitle)
If Handle<>0
BringWindowToTop(Handle)
ShowWindow(Handle,3)
Endif
CLEAR DLLS "FindWindow","ShowWindow"
Clear Events
quit
Return .F.
Endif
Endif
[ 本帖最后由 shyibaoban 于 2012-12-14 16:05 编辑 ]
Public Handle
DECLARE INTEGER CreateFileMapping IN kernel32.DLL INTEGER hFile, ;
INTEGER lpFileMappingAttributes,integer flProtect, ;
INTEGER dwMaximumSizeHigh, INTEGER dwMaximumSizeLow, ;
STRING lpName
DECLARE INTEGER GetLastError IN kernel32.DLL
DECLARE INTEGER CloseHandle IN kernel32.DLL INTEGER hObject
Declare Integer FindWindow In Win32api String, String
Declare Long BringWindowToTop In Win32API Long
Declare Long ShowWindow In Win32API Long, Long
szname="hello"
Handle = CreateFilemapping(0xFFFFFFFF,0,4,0,128,szname)
If handle = 0
Wait Windows "CreateFileMapping 失败 - LastError: " ;
+ Ltrim(Str(GetLastError()))
Return
ENDIF
cTitle="城镇居民医疗保险管理系统"
If Handle=0
Messagebox("内存映谢文件创建失败!",46,"错误")
Clear Events
Return .F.
Else
If GetLastError()=183
Handle=FindWindow(0,cTitle)
If Handle<>0
BringWindowToTop(Handle)
ShowWindow(Handle,3)
Endif
CLEAR DLLS "FindWindow","ShowWindow"
Clear Events
quit
Return .F.
Endif
Endif
[ 本帖最后由 shyibaoban 于 2012-12-14 16:05 编辑 ]