Some people think that the API is very complicated. In fact, if you start learning from the more interesting API function, I feel that the API is very fun. Below we launch the screen protection of the Windows operating system in our own procedure. Use the powerful sendMessage function to send a WM_SYSCOMMAND message, we can get it, it is very simple.
Establish a VB6 standard EXE project to place the following code
The news Option Explicit 'declare the SendMessage API usage Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long' we will be called Search for WM_SYSCOMMAND in MSDN, you can find concrete note const wm_syscommand = & h112 'This parameter indicates that we let the system start screen protection const sc_screensave = & hf140 &
Private submmand1_click () sendMessage me.hwnd, wm_syscommand, sc_screensave, 0nd Sub
Do you see if it is very interesting!
:)
This program is debugged in Win2000 VB6