Unpublished Windows functions -- 2

Source: Internet
Author: User

Unpublished Windows functions -- 2

Http://www.applevb.com
The last time I showed you how to disable or restart Windows using functions that are not publicly available in windows. During this period, I would like to introduce how to use Windows undisclosed functions to call some dialog box functions in windows. This includes how to call the system's "running program" dialog box, "find file" dialog box, and change the icon dialog box associated with the file.
Create a new project file in VB, add five commandbutton controls in form1, do not change their attributes, and then add the following code in the form1 code window:

Option explicit

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 long
End type

Const bif_returnonlyfsdirs = 1
Const 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 long
Private 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 lpstrtitle as string) as long

Private declare sub pickicondlg lib "shell32" alias "#62" (byval hwndowner as long ,_
Byval lpstrfile as string, byval nmaxfile as long, lpdwiconindex 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 long

Private sub commandementclick ()
Shrunfiledlg form1.hwnd, form1.icon. Handle, "C:/Windows", "running program Demo ",_
"Enter the program name in the text box or press the Browse key to find the program", 0
End sub

Private sub command2_click ()
Dim A as long
Dim astr as string

Astr = "C:/Windows/notepad.exe"
Pickicondlg form1.hwnd, astr, 1,
End 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 astr
End sub

Private sub command4_click ()
Dim lpidlist as long
Dim udtrauma as browseinfo

'Preliminary test of udtraumatic brain injury Structure
With udtrauma
. Hwndowner = form1.hwnd
. Ulflags = bif_returnonlyfsdirs
End

'Display folders
Lpidlist = shbrowseforfolder (udtraumatic brain injury)

If lpidlist then
'Find files
Shfindfiles lpidlist, 0
Call cotaskmemfree (lpidlist)
End if
End sub

Private sub command5_click ()
Shobjectproperties form1.hwnd, 2, "C:/Windows/notepad.exe", "samples"
End sub

Private sub form_load ()
Command1.caption = "running program"
Command2.caption = "change icon"
Command3.caption = "open a file"
Command4.caption = "Find Files"
Command5.caption = "show file attributes"
End sub
 
Run the program and click different buttons respectively. You can see that different buttons are called for different system dialogs.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.