WINDOWS unless disclosed function -
Http://www.applevb.com I showed you how to use the Windows unappromated function to shut down or restart Windows. In this issue I want to introduce you how to use the Windows Unappromested Function to Call Some dialogs in the Windows system. These include how to call the system's Runner dialog, "Find File" dialog, change the icon dialog associated with the file, and so on. First establish a new project file in VB, then add five CommandButton controls in Form1, do not change their properties, then add the following code in the Form1's code window:
Option expedition
Private Type Browseinfo HWNDOWNER AS Long Pidlroot As Long PszdisplayName As Long Lpsztitle As Long Ulflags As Long Lpfncallback As Long LPARAM As Long IImage As Longend Type
Const bif_returnnlyfsdirs = 1const max_path = 260
Private Declare Function ShobjectProperties Lib "Shell32" Alias "# 178" _ (Byval Hwndowner As Long, _ Byval Uflags as long, _ byval lpstrname as string, _ byval lpstrpar as string AS Long
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long) Private Declare Function SHBrowseForFolder Lib "Shell32" (lpbi _ As BrowseInfo) As LongPrivate Declare Function SHFindFiles Lib "Shell32" Alias "# 90" _ (ByVal pIDLRoot As Long , _ ByVal pidlSavedSearch As Long) As Long Private Declare Function GetFileNameFromBrowse Lib "Shell32" Alias "# 63" (_ ByVal hwndOwner As Long, _ ByVal lpstrFile As String, _ ByVal nMaxFile As Long, _ ByVal lpstrInitDir As String, _ ByVal lpstrDefExt AS String, _ Byval LPSTRFILTER AS STRING, _ BYVAL LPSTRTILE AS STRING AS Long
Private Declare Sub Pickicondlg Lib "Shell32" Alias "# 62" (Byval Hwndowner As String, Byval NmaxFile As Long, LPDWICONDEX AS Long)
Private Declare Function SHRunFileDlg Lib "Shell32" Alias "# 61" _ (ByVal hOwner As Long, _ ByVal hIcon As Long, _ ByVal lpstrDirectory As String, _ ByVal szTitle As String, _ ByVal szPrompt As String, _ ByVal uFlags As Long) As longprivate sub mess1_click () shrunfiledlg form1.hwnd, form1.icon.handle, "c: / windows", "Running program", _ "In the text box, enter the program name or press Browse button", 0nd Sub
Private submmand2_click () Dim A as long Dim astr as string astr = "c: /windows/notepad.exe" pickicondlg form1.hwnd, Astr, 1, Aend Sub
Private Sub Command3_Click () Dim Astr AS String * 256 Dim Bstr AS String BSTR = "C: / Windows" getFileNameFromBrowse form1.hwnd, astr, 256, bstr, "* .txt", _ "text file * .txt", " Open sample "debug.print Astrend Sub
Private Sub Command4_Click () Dim Lpidlist As Long Dim Udtbi as Browseinfo
'Fun Days udtBI structure With udtBI .hwndOwner = Form1.hWnd .ulFlags = BIF_RETURNONLYFSDIRS End With' pop-up folder view window lpIDList = SHBrowseForFolder (udtBI) If lpIDList Then 'find the file SHFindFiles lpIDList, 0 Call CoTaskMemFree (lpIDList) End IfEnd Sub
Private submmand5_click () ShobjectProperties Form1.hWnd, 2, "C: /Windows/NotepAd.exe", "Samples" End Sub
Private submmand1.caption = "Run the program" command2.caption = "change icon" command3.caption = "Open File" Command4.caption = "Find File" Command5.caption = "Display File Property" End Sub Runner Click Different Buttons, you can see the different buttons to achieve calls to different system dialogs.