Is there a way to load windows 98 manually, after say I change the win.ini Shell=explorer.exe to Shell=<myprogram.exe>
I havent been able to figure this out I have been messing around with it for about 3 months now.... please help!
Printable View
Is there a way to load windows 98 manually, after say I change the win.ini Shell=explorer.exe to Shell=<myprogram.exe>
I havent been able to figure this out I have been messing around with it for about 3 months now.... please help!
If you want it to load properly then set the entry back to Shell = Explorer.exe then restart windows using the "ExitWindowsEx()" API, here's an example I put together at the beginning of the year:
In a Module:In a Form (frmLogin) with a Textbox (txtPassword) and 2 Command Buttons (cmdOK and cmdCancel):Code:'******************************************
'* Replacement Shell Module
'* Written by Aaron Young, Jan 29th 2000
'******************************************
Option Explicit
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long ' Note that if you declare the lpData parameter as String, you must pass it By Value.
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const EWX_FORCE = 4
Private Const EWX_LOGOFF = 0
Private Const EWX_REBOOT = 2
Private Const EWX_SHUTDOWN = 1
Sub Main()
Dim lRegKey As Long
Dim sShell As String
Dim sWinDir As String
Dim bLoggedin As Boolean
'First make sure this App is Run when Windows Starts so we can make sure we always
'have the chance to make this App the Shell before a Reboot.
If RegOpenKey(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", lRegKey) = 0 Then
Call RegSetValueEx(lRegKey, "PreShellLogin", 0&, 1, ByVal "prewin.exe", 10)
Call RegCloseKey(lRegKey)
End If
'Get the Windows Directory
sWinDir = Space(255)
sWinDir = Left$(sWinDir, GetWindowsDirectory(sWinDir, 255))
'Get the Filename of the Current Shell
sShell = Space(255)
sShell = Left$(sShell, GetPrivateProfileString("boot", "shell", "", sShell, 255, sWinDir & "\system.ini"))
If LCase(sShell) <> "prewin.exe" Then
'If the Shell isn't this App then Change the System.ini to make it the Shell Next time
'the System is Rebooted.
Call WritePrivateProfileString("boot", "shell", "prewin.exe", sWinDir & "\system.ini")
Else
'We're using our own Shell, so show the Login Form
frmLogin.Show vbModal
bLoggedin = Len(frmLogin.Tag)
Unload frmLogin
Set frmLogin = Nothing
If bLoggedin Then
'If the User Logged in Correctly, Change the System.ini to use the Default windows
'Explorer Shell, then Restart Windows, (Takes a Split Second, Fake Logout)
Call WritePrivateProfileString("boot", "shell", "explorer.exe", sWinDir & "\system.ini")
Call ExitWindowsEx(EWX_FORCE Or EWX_LOGOFF, 0&)
Else
'If the User didn't Login correctly or Cancel, Shutdown Windows.
Call ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN, 0&)
End If
End If
End Sub
Make SubMain the Startup Object and compile the Project calling it "PreWin", set it to be the new Shell in the system.ini and reboot.Code:Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub cmdOK_Click()
'Check the Password
If txtPassword = "letmein" Then
'If it's valid, load the Tag with a string value
Tag = "OK"
End If
Unload Me
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
If Visible Then
'If Closing the Form, just Hide it to return operation to the
'calling Sub, otherwise, if it's hidden, let it unload.
Hide
Cancel = True
End If
End Sub