Solved

How to disable desktop using VB?

Posted on 2001-07-05
19
211 Views
Last Modified: 2008-02-01
Hello,
    I am having one Password screen.i need some idea about how to disable the desktop using vb.After entering the password only i can access any icons in the desktop.
or any menu in the start up.
Thanks in advance.
0
Comment
Question by:N_K_venkat
  • 9
  • 8
  • 2
19 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6258345
Hi,

To hide/unhide desktop icons:

Option Explicit

Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

'To Show Desktop
Dim hWnd As Long
hWnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
ShowWindow hWnd, 5

'To Hide Desktop
Dim hWnd As Long
hWnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
ShowWindow hWnd, 0


'Hope will help.
0
 
LVL 2

Expert Comment

by:santhoshx
ID: 6258390
Use this to hide stask bar
lng_Ret = FindWindow("Shell_TrayWnd", "")
lng_Ret1 = ShowWindow(lng_Ret , False)
0
 

Author Comment

by:N_K_venkat
ID: 6258392
Dear ryancys ,
  Thanks it works finely but there is one more problem.i already mentioned that he can't access start up menu also.
desktop icons are disable but startup is there.i have to hide that also.i meant that after entering password only he can access the entire machine.
Thnaks and waiting for ur Reply
0
 
LVL 2

Expert Comment

by:santhoshx
ID: 6258395
Use this to hide stask bar
lng_Ret = FindWindow("Shell_TrayWnd", "")
lng_Ret1 = ShowWindow(lng_Ret , 5)
0
 

Author Comment

by:N_K_venkat
ID: 6258412
Dear ryancys ,
  Thanks it works finely but there is one more problem.i already mentioned that he can't access start up menu also.
desktop icons are disable but startup is there.i have to hide that also.i meant that after entering password only he can access the entire machine.
Thnaks and waiting for ur Reply
0
 

Author Comment

by:N_K_venkat
ID: 6258416
Dear ryancys ,
  Thanks it works finely but there is one more problem.i already mentioned that he can't access start up menu also.
desktop icons are disable but startup is there.i have to hide that also.i meant that after entering password only he can access the entire machine.
Thnaks and waiting for ur Reply
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6258417
Hi ,

To be more professional, you need to disable the start button also:

http://www.vbcode.com/asp/showsn.asp?theID=274

Hide windows taskbar:

http://www.vbcode.com/asp/showsn.asp?theID=108

'Hope will help
0
 

Author Comment

by:N_K_venkat
ID: 6258437
Dear ryancys ,
   well its partly working but again there is a problem .sorry for disturbing u again.The proble is i can activate start up menu using my windows key in my key board.ie on pressing the windows key it gets enabled.andother problem is in the status bar i am having some icons.i want to disable that also.


Thanks in advance
Bye
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6258479
Hi, if i'm not wrong, you need to disable the Alt + Tab keys, here is a sample link:

Disable Ctrl + Alt + Del, Alt + Tab:
http://www.vbcode.com/asp/showsn.asp?theID=2691

'Hope will help.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6258482
Hi, ya to enable back the combination key, try this:

Dim lReturn  As Long
    Dim lBool As Long
    lReturn = SystemParametersInfo(97, False, lBool, vbNull)

'Hope will help.
0
 

Author Comment

by:N_K_venkat
ID: 6258550
Hi ryancys,
   i told u that when i am pressing windows key even though the start button is in visible mode it works.
using mouse i can't access my programs in start menu but using key board i can.and then i have to hide the status bar also.becuase i am having some shortcuts in the status bar also.
Thnaks in davance
Bye
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6258571
Hi N_K_venkat,

The link provided not works?

'status bar' or 'task bar' ?
0
 

Author Comment

by:N_K_venkat
ID: 6258885
Dear ryancys ,
  i meant status bar also.ie the place where time is shown.if there any shortcut icons the user can also browse it through that.and then the start menu is hiding according to ur coding but when i press windows key or control+escape its opening.I think u can understand my problem.if any solution please tell me .
Thanks
Bye from
Venkat.N.K
 
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6258890
Hi venkat,

You can also can hide the 'Status bar' using API, but i'm buzy now so you may find yourself the relevant code.

and

Can you post your code?

Regards.
0
 

Author Comment

by:N_K_venkat
ID: 6259145
Dear ryancys ,

Please verify u can delete the menu items from the start menu....


http://www.vbcode.com/asp/showzip.asp?ZipFile=http%3A%2F%2Fwww%2Evbcode%2Ecom%2Fcode%2FStartMenu1%2Ezip&theID=3315

Bye
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6259208
Hi venkat,

You don't need to disable/ hide the start menu items since you said you can't disable the start button.

Anyway, you can restrict the mouse in a control to prevent user from clicking the start button or program in system tray.

Here is the sample to restrict the mouse:

To Restrict Mouse Cursor:
http://www.mvps.org/vbnet/code/helpers/clipcursor.htm

'Hope will help.

PS: i will do this program as self-research, and will be post to my website later, stay turn!
0
 
LVL 49

Accepted Solution

by:
Ryan Chong earned 100 total points
ID: 6259290
Hi venkat,

Here is the complete demo, i think this should solve your problem!

Develop Enviroment : VB6 + Win98SE

The sample:

___________________________________________________

Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function ClipCursor Lib "user32" (lpRect As Any) As Long
Private Declare Function GetClientRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hWnd As Long, lpPoint As POINT) As Long
Private Declare Function OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long) As Long

Private Type RECT
   left   As Long
   top    As Long
   right  As Long
   bottom As Long
End Type

Private Type POINT
   x   As Long
   y   As Long
End Type

Private Const SWP_HIDEWINDOW = &H80
Private Const SWP_SHOWWINDOW = &H40

Private Function hideStartButton()
'This Function Hides the Start Button'
OurParent& = FindWindow("Shell_TrayWnd", "")
OurHandle& = FindWindowEx(OurParent&, 0, "Button", vbNullString)
ShowWindow OurHandle&, 0
End Function

Private Function showStartButton()
'This Function Shows the Start Button'
OurParent& = FindWindow("Shell_TrayWnd", "")
OurHandle& = FindWindowEx(OurParent&, 0, "Button", vbNullString)
ShowWindow OurHandle&, 5
End Function

Private Sub Command1_Click()
    hideStartButton
End Sub

Private Sub Command2_Click()
    showStartButton
End Sub

Private Sub Command3_Click()
    Dim lReturn  As Long
    Dim lBool As Long
    lReturn = SystemParametersInfo(97, True, lBool, vbNull)
End Sub

Private Sub Command4_Click()
    Dim lReturn  As Long
    Dim lBool As Long
    lReturn = SystemParametersInfo(97, False, lBool, vbNull)
End Sub

Private Sub Command5_Click()
    Dim rtn As Long
    'hide the taskbar
    rtn = FindWindow("Shell_traywnd", "") 'get the Window
    Call SetWindowPos(rtn, 0, 0, 0, 0, 0, SWP_HIDEWINDOW) 'hide the Tasbar
End Sub

Private Sub Command6_Click()
    Dim rtn As Long
    'show th taskbar
    rtn = FindWindow("Shell_traywnd", "") 'get the Window
    Call SetWindowPos(rtn, 0, 0, 0, 0, 0, SWP_SHOWWINDOW) 'show the Taskbar
End Sub

Private Sub Command7_Click()
    Static justOnce As Boolean
    Dim rc As RECT
    Dim topcorner As POINT
         
    If Not justOnce Then
   
       justOnce = True
       
       GetClientRect Text1.hWnd, rc
       
       topcorner.x = rc.left
       topcorner.y = rc.top
       
       If ClientToScreen(Text1.hWnd, topcorner) <> 0 Then
       
          If OffsetRect(rc, topcorner.x, topcorner.y) <> 0 Then
         
             Call ClipCursor(rc)
             Caption = "Cursor is Trapped!"
             
          End If
       End If
         
    End If
   
End Sub

Private Sub Command8_Click()
    'To Hide Desktop
    Dim hWnd As Long
    hWnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
    ShowWindow hWnd, 0
End Sub

Private Sub Command9_Click()
    'To Show Desktop
    Dim hWnd As Long
    hWnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
    ShowWindow hWnd, 5
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn Then
        If Text1.Text = "Text1" Then ClipCursor ByVal 0&
    End If
End Sub

'Hope will help.
0
 

Author Comment

by:N_K_venkat
ID: 6270554
Hi,ryancys

This will not support for NT??Where are U working?Thanks for the answer.if u know the code for NT if its different please tell me
Bye
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6271594
Hi venkat,

my environment is win98se + vb6 , sorry that the code is not tested in NT environment.

The websites you can find more resources are:

www.vbcode.com
http://www.mvps.org/vbnet/index.html
http://www.planet-source-code.com/
www.vbexplorer.com

'Hope will help.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now