wPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
''MODmain
''Option Explicit ''为了在FRMshell卸载之后仍能运行,必须将这行注释掉
Public preview As Boolean ''true是试试屏保效果,false是真正的屏保
Sub Main() ''
程序运行入口
Dim ClassName As String * 64 ''存放窗口的类名
Dim ExeCmd As String ''存放命令行参数
GetClassName FRMmain.hwnd, ClassName, 64 ''取得窗口的类名
ExeCmd = UCase(Command$) ''将调用的屏保的参数转换成大写后存放在变量ExeCmd里
If Not (InStr(ExeCmd, "/P") = 0) Then ''检查屏保的调用参数中是否有"/P"参数
If FindWindow(ClassName, WM_LOOK) <> 0 Then End ''如果找到已有同一个运行方式的实例存在则
程序结束
ClosePreWindow ClassName, WM_RUN ''同上
Scr_Look
ElseIf Not (InStr(ExeCmd, "/S") = 0) Then
If FindWindow(ClassName, WM_RUN) <> 0 Then End
ClosePreWindow ClassName, WM_LOOK ''同上
Scr_Run
Else
ClosePreWindow ClassName, WM_LOOK ''同上
ClosePreWindow ClassName, WM_RUN ''同上
Scr_Run
End If
End Sub
Public Sub ClosePreWindow(ClassName As String, WinCaption As String)
Dim PreWnd As Long
PreWnd = FindWindow(ClassName, WinCaption) ''寻找类名为ClassName,标题为WinCaption的窗口
If Not (PreWnd = 0) Then Call SendMessage(PreWnd, WM_CLOSE, 0, 0) ''如果窗口已找到则关闭它
End Sub
Public Sub Scr_Look()
Dim LookScrWnd As Long
Dim Style As Long
Dim LookRect As RECT
FRMmain.Caption = WM_LOOK ''赋上具有相应运行方式的标题
LookScrWnd = Val(Right(Command$, Len(Command$) - 2)) ''取得小屏幕的窗口句柄
Style = GetWindowLong(FRMmain.hwnd, GWL_STYLE) ''取得窗口的样式
Style = Style Or WS_CHIL