06170308.txt 20-Jun-00 SystemParametersInfo() function Hi all Has anyone had any experience of using SystemParametersInfo() function. I am trying to stop my end user from using the W95 key and the Ctrl + Esc keys to bring up the Start Menu whilst my programme is running. I have been told that I can use the API function SystemParametesInfo() along with the Parameter SPI_SCREENSAVERRUNNING. This function is supposed to trick the system into thinking that your programme is a screen saver. I received this information from two different sources, one from VB and one from Delphi. They both use the same function with the same parameter. Yet when I try to use this with VO I am unable to get it to work. I hope that they do not have one over on us. I'm sure there must be a way to stop the Start Menu from being accessed whilst the programme is running. Any help is appreciated. But then I'm sure that goes without saying. Cheers Adrian Hello Adrian, This should do what you want. // 2nd param with a value of 1 disables Alt+Tab. // Send send 0 to enable. // 1 disables SystemParametersInfo (SPI_SCREENSAVERRUNNING, 1, NULL, 0) // 0 enables SystemParametersInfo (SPI_SCREENSAVERRUNNING, 0, NULL, 0) Hope it helps. Butch Nash Hi Voyagers Just curiosity: Why would someone want to block the User from acessing the start menu? Adriano Rui Gominho I would. I have an app that will be used as data entry for shop floor workers. All they see is a screen that lets them choose one thing and another and start/end a job. It uses the keyboard, no mouse and I wouldn't want these guys to fiddle around the system. That's why I hide the Taskbar :) ========Stephane Hebert======== I use the following to hide the Taskbar and then show it again when the app is exited. It doesn't seem to work in Win98 though, I just tried it. I know it works with Win95. I don't know if pressing CTRL+ESCAPE will show it back up on the screen once it's hidden, I'll have to try when I get back to my dev machine. Method Start() class App local hwnd as ptr hwnd:=FindWindow(String2Psz("Shell_TrayHwnd"),null) if !IsNil(hwnd) ShowWindow(hwnd,SW_HIDE) endif self:Exec() ShowWindow(hwnd,SW_RESTORE) ========Stephane Hebert======== Stephane In Win98 the classname for the taskbar is "Shell_TrayWnd" See if that makes any difference. regards Trevor Trevor, Yep, that did it. Now why did they change that ? Makes no sense to me. To come back to Adrians problem, pressing CTRL+ESCAPE when the Taskbar is hidden doesn't prevent the start menu from poping up. Surely there's another way. ========Stephane Hebert======== Stephane >Surely there's another way. You would probably have to put in a system wide hook to capture/filter all keystrokes before the system got them and suppress the ones you don't want to get through. This has to be in a DLL - see extract below from the Win32 API The SetWindowsHookEx function installs an application- defined hook procedure into a hook chain. An application installs a hook procedure to monitor the system for certain types of events. A hook procedure can monitor events associated either with a specific thread or with all threads in the system. This function supersedes the SetWindowsHook function. HHOOK SetWindowsHookEx( int idHook, // type of hook to install HOOKPROC lpfn, // address of hook procedure HINSTANCE hMod, // handle of application instance DWORD dwThreadId //identity of thread to install hook for ); HTH Steve Quinn Stephen, OK, I took a look and came up with the following. It crashes at the MainDLG{self}:Show() line. METHOD Start() CLASS App local lpfn as ptr local ptrHookDLL as ptr local ptrHook as ptr local hWnd as ptr local lResult as logic -- Load the DLL that contains the Keyboardproc ptrHookDLL:=_VOLoadLibrary("WmHook.DLL") if !IsNil(ptrHookDLL) -- Load address of the Keyboardproc lpfn:=GetProcAddress(ptrHookDLL,String2Psz("NoCEHook")) if !IsNil(lpfn) -- Set the system wide hook ptrHook:=SetWindowsHookEx(WH_KEYBOARD,@lpfn,null,0) if IsNil(ptrHook) WarningBox{,"","HOOK IS NIL"}:Show() << ----- never shows up, then it's ok :) endif endif endif -- Find Taskbar and get handle hwnd:=FindWindow(String2Psz("Shell_TrayWnd"),null) if IsNil(hwnd) hwnd:=FindWindow(String2Psz("Shell_TrayHwnd"),null) if !IsNil(hwnd) lResult:=true endif else lResult:=true endif -- Hide it if found if lResult ShowWindow(hwnd,SW_HIDE) endif MainDLG{SELF}:Show() -- Restore Taskbar if it was found if !IsNil(hwnd) ShowWindow(hwnd,SW_RESTORE) endif -- Unhook the system wide hook if UnHookWindowsHookEx(ptrHook) WarningBox{,"","OK REMOVED"}:Show() <<--- I never get to see this, since the app crashes as soon as I press a key. :( endif -- Unload the DLL if !IsNil(ptrHookDLL) _VOFreeLibrary(ptrHookDLL) endif RETURN SELF Now the DLL that contains the function: Static Function NoCEHook(nCode as int, ; wParam as dword, lParam as long) as long CALLBACK return 0L That's all I have and I think my problem is right here. It might be the CALLBACK statement. Isn't there a WINHOOK statement ? I know I saw a _WINCALL statement. What is it used for ? The help file only lists: CLIPPER, STRICT, PASCAL and CALLBACK. Any ideas ?