Quote:
> I need to know how I can access the network neighbourhood via vb4 to select
> server names for UNC. I was also wondering if some one can tell me how to
> shutdown 95/98 through vb4 also how to put an app in the system tray.
> any help on the above probs would be muchly appreciated
> thanx
> ;-)
> Andrew
Hello, sunny Australia... From cloudy Canada:
1. Network neighborhood.
Private Declare Function SHGetSpecialFolderLocation Lib "Shell32.dll"
(ByVal hwndOwner As Long, ByVal Folder As Long, ByRef idl As Long) As
Long
Private Type BROWSEINFO
hwndOwner As Long
pidlRoot As Long
strDisplayName As String
strTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Private Declare Function SHBrowseForFolder Lib "Shell32.dll" (ByRef bi
As BROWSEINFO) As Long
Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long)
As Long
Private Declare Function SHGetPathFromIDList Lib "Shell32" (ByVal idl As
Long, ByVal Path As String) As Long
Private Sub SetUtilsPath()
Dim lngIdl As Long
Dim udtBrowse As BROWSEINFO
Dim strPath As String
Const MAXPATH = 260
Const CSIDL_NETWORK = &H12
Const CSIDL_DESKTOP = &H0
Const BIF_BROWSEFORCOMPUTER = &H1000
Const BIF_RETURNONLYFSDIRS = &H1
If SHGetSpecialFolderLocation(Me.hwnd, CSIDL_DESKTOP, lngIdl) = 0
Then
With udtBrowse
.hwndOwner = Me.hwnd
.pidlRoot = lngIdl
.strDisplayName = Space(MAXPATH)
.strTitle = "Your dialog's title goes here..."
.ulFlags = BIF_RETURNONLYFSDIRS
End With
lngIdl = SHBrowseForFolder(udtBrowse)
If lngIdl <> 0 Then
strPath = Space(MAXPATH)
SHGetPathFromIDList ByVal lngIdl, ByVal strPath
strPath = Left(strPath, InStr(strPath, vbNullChar) - 1)
End If
Call GlobalFree(lngIdl)
.... Do something here with strPath.
End If
End Sub
2. Win 95 Shutdown.
From Daniel Appleman's book:
ExitWindowsEx
VB Declaration
Declare Function ExitWindowsEx& Lib "user32" (ByVal uFlags As Long,
ByVal _
dwReserved As Long)
Description
Allows you to exit and optionally restart windows.
Parameter Type/Description
uFlags LongSpecify one or more of the following flags (combined using
the OR operation):
EWX_FORCEForcibly terminates processes that do not respond.
EWX_LOGOFFTerminates processes, then logs off.
EWX_SHUTDOWNPowers the system off, if possible.
EWX_REBOOTReboots the system.
EWX_SHUTDOWNShuts the system down.
dwReserved LongReservedset to zero.
Return Value
LongNonzero on success, zero on error. Sets GetLastError.
Platform
Windows 95, Windows NT
Comments
This function returns immediately and the shutdown proceeds in the
background. Be sure to terminate your own application to help the
shutdown proceed smoothly. Your process must have sufficient privilege
to execute this operation.
Porting Notes
Replaces the ExitWindows API call in Win16
My note: you don't need to care about priviliges under 95/98.
3. SysTray
Goto
http://www.mvps.org/vbnet/code/shell/shellnotifybasic.htm