|
-
Jan 29th, 2000, 07:45 PM
#1
Thread Starter
Hyperactive Member
Hi!
I am making my own shell. And I need to exit within it and run shell as normaly (explorer). How to do it? If i type shell "explorer.exe", it runs normal application exploring disk C:.
------------------
Thanks,
John, 14 years old
-
Jan 29th, 2000, 07:48 PM
#2
Hyperactive Member
Could you please give me a little more detail on what your trying to do?
-
Jan 29th, 2000, 08:08 PM
#3
Thread Starter
Hyperactive Member
Ok.
When Windows starts, it runs a program, located in System.ini. Standardly, there can be found "shell=explorer.exe", but you can change it to any of your/others program.
Well, now I have Windows running my program and nothing else. But, (e.g) my application isn't perfect (or some other reason) and I need to run the standard Windows explorer with taskbar, systray etc.
And here is the problem :-( . When I run an explorer.exe from my app, it starts normal file browser.
I need to run normal Windows (with desktop,...) from my shell (without restarting the computer)
-
Jan 29th, 2000, 08:33 PM
#4
Hyperactive Member
Why don't you just change the system.ini file back to its normal state?
-
Jan 30th, 2000, 03:46 AM
#5
Thread Starter
Hyperactive Member
Because I need to RESTART the computer using this method!!!!!!!!!!!!!!! :-(
-
Jan 30th, 2000, 04:00 AM
#6
Lively Member
Hehehehe ) (sorry, I wouldn't know how to do it)
-
Jan 30th, 2000, 04:02 AM
#7
Hyperactive Member
WELL THEN RESTART YOUR COMPUTER!!!!!!
[This message has been edited by rino_2 (edited 01-30-2000).]
-
Jan 30th, 2000, 04:23 AM
#8
Here's some code I wrote for a Similar Question Just Yesterday.
It basically replaces the Shell, (Explorer.exe), to show my own Login Form, then if you enter the right password, it replaces the Shell again with Explorer.exe and does a LogOff to quickly restart Windows in the Default Shell..
In a Module, (Startup Object)..
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
In the Form, frmLogin..
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
I'm sure you can adapt my code to suit your own purposes.
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|