PDA

View Full Version : Check for Normal, Safe Modes!


Intrigued
11-09-2005, 12:48 PM
I posted this response in the Setup Factory 7.0's forum. It can be useful here in the AMS forums too. I had created a .exe to check for which mode a computer is in (normal, safe, safe with networking mode(s)). But, I took a couple minutes just now and realized the following code (or it seems, try it out and let us know) does the trick without an external .exe or .dll! (it uses the User32.dll windows has innate to itself).

dll_SystemMode = DLL.CallFunction("C:\\WINDOWS\\system32\\user32.dll", "GetSystemMetrics", "67", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)

Dialog.Message("", dll_SystemMode)

Eagle
11-10-2005, 01:23 AM
just a minor more generic tweak...

dll_SystemMode = DLL.CallFunction(_SystemFolder.."\\user32.dll", "GetSystemMetrics", "67", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);

Dialog.Message("", dll_SystemMode);

Corey
11-10-2005, 02:00 AM
Nice one you guys... :yes

Eagle
11-10-2005, 04:25 AM
Just a bit of example usage code
this example detects if in SafeMode
and exits the Application if detected

function IsSafeMode()
--safe mode return params(string form): 0 normal, 1 safemode-std, 2 safemode with network support
bSafeMode = false;
local n_SystemMode = DLL.CallFunction(_SystemFolder.."\\user32.dll", "GetSystemMetrics", "67", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
if (n_SystemMode ~= "") then
if (String.ToNumber(n_SystemMode) > 0) then
--use the below timed message if you wish
Dialog.TimedMessage(" - Installation Startup Aborted: "..n_SystemMode, "This Program should Not be run while\r\n"
.."the System is in a ' SafeMode ' state.\r\nPlease run Program from Normal Bootup\r\n\r\n"
.." - This Installer will now Exit ...", 10000, MB_ICONINFORMATION);
bSafeMode = true;
end
end
return bSafeMode;
end

--to Call it:

if IsSafeMode() then
--add what you wish to do here
Application.Exit(0); --(this one exists the installer)
end

tested on Win2K-XP-W2K3 All versions and SPacks
(should work for Win95,Win98-WinMe also)

Intrigued
11-10-2005, 06:25 PM
Coo' update! I wish I had more time to code. But, I have way less time since moving and getting back to work. Boo'da'hoo hoo.

:huh