Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 262
  • Last Modified:

How to disable desktop using VB?

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
N_K_venkat
Asked:
N_K_venkat
  • 9
  • 8
  • 2
1 Solution
 
Ryan ChongCommented:
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
 
santhoshxCommented:
Use this to hide stask bar
lng_Ret = FindWindow("Shell_TrayWnd", "")
lng_Ret1 = ShowWindow(lng_Ret , False)
0
 
N_K_venkatAuthor Commented:
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
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
santhoshxCommented:
Use this to hide stask bar
lng_Ret = FindWindow("Shell_TrayWnd", "")
lng_Ret1 = ShowWindow(lng_Ret , 5)
0
 
N_K_venkatAuthor Commented:
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
 
N_K_venkatAuthor Commented:
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
 
Ryan ChongCommented:
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
 
N_K_venkatAuthor Commented:
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
 
Ryan ChongCommented:
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
 
Ryan ChongCommented:
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
 
N_K_venkatAuthor Commented:
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
 
Ryan ChongCommented:
Hi N_K_venkat,

The link provided not works?

'status bar' or 'task bar' ?
0
 
N_K_venkatAuthor Commented:
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
 
Ryan ChongCommented:
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
 
N_K_venkatAuthor Commented:
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
 
Ryan ChongCommented:
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
 
Ryan ChongCommented:
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
 
N_K_venkatAuthor Commented:
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
 
Ryan ChongCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 9
  • 8
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now