{"id":1337,"date":"2024-08-08T08:00:00","date_gmt":"2024-08-08T00:00:00","guid":{"rendered":"http:\/\/www.wyrcad.com\/?p=1337"},"modified":"2024-08-08T08:13:32","modified_gmt":"2024-08-08T00:13:32","slug":"%e5%af%b9%e8%af%9d%e6%a1%86%e5%87%bd%e6%95%b0%e7%b3%bb%e5%88%97%e4%b9%8b%e4%b8%80","status":"publish","type":"post","link":"https:\/\/www.wyrcad.com\/?p=1337","title":{"rendered":"\u5bf9\u8bdd\u6846\u51fd\u6570\u7cfb\u5217\u4e4b\u4e00"},"content":{"rendered":"\n<p>Option Explicit<\/p>\n\n\n\n<p>Private Type OPENFILENAME<br>lStructSize As Long<br>hwnd As Long<br>hInstance As Long<br>lpstrFilter As String<br>lpstrCustomFilter As String<br>nMaxCustFilter As Long<br>nFilterIndex As Long<br>lpstrFile As String<br>nMaxFile As Long<br>lpstrFileTitle As String<br>nMaxFileTitle As Long<br>lpstrInitialDir As String<br>lpstrTitle As String<br>Flags As Long<br>nFileOffset As Integer<br>nFileExtension As Integer<br>lpstrDefExt As String<br>lCustData As Long<br>lpfnHook As Long<br>lpTemplateName As String<br>End Type<\/p>\n\n\n\n<p>Private Type COLORSTRUC<br>lStructSize As Long<br>hwnd As Long<br>hInstance As Long<br>rgbResult As Long<br>lpCustColors As String<br>Flags As Long<br>lCustData As Long<br>lpfnHook As Long<br>lpTemplateName As String<br>End Type<\/p>\n\n\n\n<p>Private Const LF_FACESIZE = 32<\/p>\n\n\n\n<p>Private Type LogFont<br>lfHeight As Long<br>lfWidth As Long<br>lfEscapement As Long<br>lfOrientation As Long<br>lfWeight As Long<br>lfItalic As Byte<br>lfUnderline As Byte<br>lfStrikeOut As Byte<br>lfCharSet As Byte<br>lfOutPrecision As Byte<br>lfClipPrecision As Byte<br>lfQuality As Byte<br>lfPitchAndFamily As Byte<br>lfFaceName(LF_FACESIZE) As Byte<br>End Type<\/p>\n\n\n\n<p>Private Type FONTSTRUC<br>lStructSize As Long<br>hwnd As Long<br>hDC As Long<br>lpLogFont As Long<br>iPointSize As Long<br>Flags As Long<br>rgbColors As Long<br>lCustData As Long<br>lpfnHook As Long<br>lpTemplateName As String<br>hInstance As Long<br>lpszStyle As String<br>nFontType As Integer<br>MISSING_ALIGNMENT As Integer<br>nSizeMin As Long<br>nSizeMax As Long<br>End Type<\/p>\n\n\n\n<p>Public Type DEVMODE<br>dmDeviceName As String * 32<br>dmSpecVersion As Integer<br>dmDriverVersion As Integer<br>dmSize As Integer<br>dmDriverExtra As Integer<br>dmFields As Long<br>dmOrientation As Integer<br>dmPaperSize As Integer<br>dmPaperLength As Integer<br>dmPaperWidth As Integer<br>dmScale As Integer<br>dmCopies As Integer<br>dmDefaultSource As Integer<br>dmPrintQuality As Integer<br>dmColor As Integer<br>dmDuplex As Integer<br>dmYResolution As Integer<br>dmTTOption As Integer<br>dmCollate As Integer<br>dmFormName As String * 32<br>dmUnusedPadding As Integer<br>dmBitsPerPel As Integer<br>dmPelsWidth As Long<br>dmPelsHeight As Long<br>dmDisplayFlags As Long<br>dmDisplayFreq As Long<br>End Type<\/p>\n\n\n\n<p>Private Type PRINTDLGSTRUC<br>lStructSize As Long<br>hwnd As Long<br>hDevMode As Long<br>hDevNames As Long<br>hDC As Long<br>Flags As Long<br>nFromPage As Integer<br>nToPage As Integer<br>nMinPage As Integer<br>nMaxPage As Integer<br>nCopies As Integer<br>hInstance As Long<br>lCustData As Long<br>lpfnPrintHook As Long<br>lpfnSetupHook As Long<br>lpPrintTemplateName As String<br>lpSetupTemplateName As String<br>hPrintTemplate As Long<br>hSetupTemplate As Long<br>End Type<\/p>\n\n\n\n<p>Public Type PRINTPROPS<br>Cancel As Boolean<br>Device As String<br>Copies As Integer<br>Collate As Boolean<br>File As Boolean<br>All As Boolean<br>Pages As Boolean<br>Selection As Boolean<br>FromPage As Integer<br>ToPage As Integer<br>DM As DEVMODE<br>End Type<\/p>\n\n\n\n<p>Private Type SHITEMID<br>cb As Long<br>abID As Byte<br>End Type<\/p>\n\n\n\n<p>Private Type ITEMIDLIST<br>mkid As SHITEMID<br>End Type<\/p>\n\n\n\n<p>Private Type BROWSEINFO<br>hOwner As Long \u2018\u4e3b\u53e5\u67c4<br>pidlRoot As Long \u2018\u5c55\u5f00\u6839\u76ee\u5f55<br>pszDisplayName As String<br>lpszTitle As String \u2018\u5217\u8868\u6846\u6807\u9898,\u8fd9\u91cc\u662f\u7528\u7684long,\u6240\u4ee5\u5f97\u7528lstrcat\u83b7\u53d6\u5b57\u7b26\u6307\u9488\u4e86<br>ulFlags As Long \u2018\u89c4\u5b9a\u53ea\u80fd\u9009\u62e9\u6587\u4ef6\u5939\uff0c\u5176\u4ed6\u65e0\u6548<br>\u2018lpfn As Long<br>lpfnCallback As Long<br>lParam As Long<br>iImage As Long<br>End Type<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ Win32s (Private Functions for Wrappers Below)<br>\u2018\/\/<\/p>\n\n\n\n<p>Private Declare Function GetOpenFileName Lib \u201ccomdlg32.dll\u201d Alias \u201cGetOpenFileNameA\u201d (pOpenfilename As OPENFILENAME) As Long<br>Private Declare Function GetSaveFileName Lib \u201ccomdlg32.dll\u201d Alias \u201cGetSaveFileNameA\u201d (pOpenfilename As OPENFILENAME) As Long<br>Private Declare Function PrintDlg Lib \u201ccomdlg32.dll\u201d Alias \u201cPrintDlgA\u201d (pPrintdlg As PRINTDLGSTRUC) As Long<br>Private Declare Function ChooseColor Lib \u201ccomdlg32.dll\u201d Alias \u201cChooseColorA\u201d (pChoosecolor As COLORSTRUC) As Long<br>Private Declare Function ChooseFont Lib \u201ccomdlg32.dll\u201d Alias \u201cChooseFontA\u201d (pChoosefont As FONTSTRUC) As Long<br>Private Declare Function GlobalAlloc Lib \u201ckernel32\u201d (ByVal wFlags As Long, ByVal dwBytes As Long) As Long<br>Private Declare Function GlobalFree Lib \u201ckernel32\u201d (ByVal hMem As Long) As Long<br>Private Declare Function GlobalLock Lib \u201ckernel32\u201d (ByVal hMem As Long) As Long<br>Private Declare Function GlobalUnlock Lib \u201ckernel32\u201d (ByVal hMem As Long) As Long<br>Private Declare Sub CopyMemory Lib \u201ckernel32\u201d Alias \u201cRtlMoveMemory\u201d (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)<br>Private Declare Function SHGetPathFromIDList Lib \u201cshell32.dll\u201d Alias \u201cSHGetPathFromIDListA\u201d (ByVal pidl As Long, ByVal pszPath As String) As Long<br>Private Declare Function SHGetSpecialFolderLocation Lib \u201cshell32.dll\u201d (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long<br>Private Declare Function SHBrowseForFolder Lib \u201cshell32.dll\u201d Alias \u201cSHBrowseForFolderA\u201d (lpBrowseInfo As BROWSEINFO) As Long \u2018ITEMIDLIST<br>Private Declare Function WriteProfileString Lib \u201ckernel32\u201d Alias \u201cWriteProfileStringA\u201d (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long<br>Private Declare Function GetProfileString Lib \u201ckernel32\u201d Alias \u201cGetProfileStringA\u201d (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long) As Long<br>Private Declare Function SendMessageByString Lib \u201cuser32\u201d Alias \u201cSendMessageA\u201d (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long<br>Private Declare Function SendMessage Lib \u201cuser32\u201d Alias \u201cSendMessageA\u201d (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal IParam As String) As Long<br>Private Declare Function lstrcat Lib \u201ckernel32\u201d Alias \u201clstrcatA\u201d (ByVal lpStringl As String, ByVal lpString2 As String) As Long<br>Private Declare Sub CoTaskMemFree Lib \u201cole32.dll\u201d (ByVal hMem As Long)<br>\u2018\/\/<br>\u2018\/\/ Win32s (Public)<br>\u2018\/\/<\/p>\n\n\n\n<p>Declare Function WinHelp Lib \u201cuser32\u201d Alias \u201cWinHelpA\u201d (ByVal hwnd As Long, ByVal lpHelpFile As String, ByVal wCommand As Long, ByVal dwData As Any) As Long<br>Declare Function HTMLHelp Lib \u201chhctrl.ocx\u201d Alias \u201cHtmlHelpA\u201d (ByVal hwnd As Long, ByVal szFilename As String, ByVal dwCommand As Long, ByVal dwData As Any) As Long<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ Constants (Public for Print Dialog Box)<br>\u2018\/\/<\/p>\n\n\n\n<p>Public Const PD_NOSELECTION = &amp;H4<br>Public Const PD_DISABLEPRINTTOFILE = &amp;H80000<br>Public Const PD_PRINTTOFILE = &amp;H20<br>Public Const PD_RETURNDC = &amp;H100<br>Public Const PD_RETURNDEFAULT = &amp;H400<br>Public Const PD_RETURNIC = &amp;H200<br>Public Const PD_SELECTION = &amp;H1<br>Public Const PD_SHOWHELP = &amp;H800<br>Public Const PD_NOPAGENUMS = &amp;H8<br>Public Const PD_PAGENUMS = &amp;H2<br>Public Const PD_ALLPAGES = &amp;H0<br>Public Const PD_COLLATE = &amp;H10<br>Public Const PD_HIDEPRINTTOFILE = &amp;H100000<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ Constants (Public for WinHelp)<br>\u2018\/\/<\/p>\n\n\n\n<p>Public Const HELP_COMMAND = &amp;H102&amp;<br>Public Const HELP_CONTENTS = &amp;H3&amp;<br>Public Const HELP_CONTEXT = &amp;H1<br>Public Const HELP_CONTEXTPOPUP = &amp;H8&amp;<br>Public Const HELP_FORCEFILE = &amp;H9&amp;<br>Public Const HELP_HELPONHELP = &amp;H4<br>Public Const HELP_INDEX = &amp;H3<br>Public Const HELP_KEY = &amp;H101<br>Public Const HELP_MULTIKEY = &amp;H201&amp;<br>Public Const HELP_PARTIALKEY = &amp;H105&amp;<br>Public Const HELP_QUIT = &amp;H2<br>Public Const HELP_SETCONTENTS = &amp;H5&amp;<br>Public Const HELP_SETINDEX = &amp;H5<br>Public Const HELP_SETWINPOS = &amp;H203&amp;<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ Constants (Public for HTMLHelp)<br>\u2018\/\/<\/p>\n\n\n\n<p>Public Const HH_DISPLAY_TOPIC = &amp;H0&amp;<br>Public Const HH_HELP_FINDER = &amp;H0&amp;<br>Public Const HH_DISPLAY_TOC = &amp;H1&amp; \u2018\/\/ Currently Not Implemented<br>Public Const HH_DISPLAY_INDEX = &amp;H2&amp; \u2018\/\/ Currently Not Implemented<br>Public Const HH_DISPLAY_SEARCH = &amp;H3&amp; \u2018\/\/ Currently Not Implemented<br>Public Const HH_SET_WIN_TYPE = &amp;H4&amp;<br>Public Const HH_GET_WIN_TYPE = &amp;H5&amp;<br>Public Const HH_GET_WIN_HANDLE = &amp;H6&amp;<br>Public Const HH_ENUM_INFO_TYPE = &amp;H7&amp;<br>Public Const HH_SET_INFO_TYPE = &amp;H8&amp;<br>Public Const HH_SYNC = &amp;H9&amp;<br>Public Const HH_ADD_NAV_UI = &amp;H10&amp; \u2018\/\/ Currently Not Implemented<br>Public Const HH_ADD_BUTTON = &amp;H11&amp; \u2018\/\/ Currently Not Implemented<br>Public Const HH_GETBROWSER_APP = &amp;H12&amp; \u2018\/\/ Currently Not Implemented<br>Public Const HH_KEYWORD_LOOKUP = &amp;H13&amp;<br>Public Const HH_DISPLAY_TEXT_POPUP = &amp;H14&amp;<br>Public Const HH_HELP_CONTEXT = &amp;H15&amp;<br>Public Const HH_TP_HELP_CONTEXTMENU = &amp;H16&amp;<br>Public Const HH_TP_HELP_WM_HELP = &amp;H17&amp;<br>Public Const HH_CLOSE_ALL = &amp;H18&amp;<br>Public Const HH_ALINK_LOOKUP = &amp;H19&amp;<br>Public Const HH_GET_LAST_ERROR = &amp;H20&amp; \u2018\/\/ Currently Not Implemented<br>Public Const HH_ENUM_CATEGORY = &amp;H21&amp;<br>Public Const HH_ENUM_CATEGORY_IT = &amp;H22&amp;<br>Public Const HH_RESET_IT_FILTER = &amp;H23&amp;<br>Public Const HH_SET_INCLUSIVE_FILTER = &amp;H24&amp;<br>Public Const HH_SET_EXCLUSIVE_FILTER = &amp;H25&amp;<br>Public Const HH_SET_GUID = &amp;H26&amp;<br>Public Const HH_INTERNAL = &amp;H255&amp;<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ Constants (Private)<br>\u2018\/\/<\/p>\n\n\n\n<p>Private Const FW_BOLD = 700<br>Private Const GMEM_MOVEABLE = &amp;H2<br>Private Const GMEM_ZEROINIT = &amp;H40<br>Private Const GHND = (GMEM_MOVEABLE Or GMEM_ZEROINIT)<br>Private Const OFN_ALLOWMULTISELECT = &amp;H200<br>Private Const OFN_CREATEPROMPT = &amp;H2000<br>Private Const OFN_ENABLEHOOK = &amp;H20<br>Private Const OFN_ENABLETEMPLATE = &amp;H40<br>Private Const OFN_ENABLETEMPLATEHANDLE = &amp;H80<br>Private Const OFN_EXPLORER = &amp;H80000<br>Private Const OFN_EXTENSIONDIFFERENT = &amp;H400<br>Private Const OFN_FILEMUSTEXIST = &amp;H1000<br>Private Const OFN_HIDEREADONLY = &amp;H4<br>Private Const OFN_LONGNAMES = &amp;H200000<br>Private Const OFN_NOCHANGEDIR = &amp;H8<br>Private Const OFN_NODEREFERENCELINKS = &amp;H100000<br>Private Const OFN_NOLONGNAMES = &amp;H40000<br>Private Const OFN_NONETWORKBUTTON = &amp;H20000<br>Private Const OFN_NOREADONLYRETURN = &amp;H8000<br>Private Const OFN_NOTESTFILECREATE = &amp;H10000<br>Private Const OFN_NOVALIDATE = &amp;H100<br>Private Const OFN_OVERWRITEPROMPT = &amp;H2<br>Private Const OFN_PATHMUSTEXIST = &amp;H800<br>Private Const OFN_READONLY = &amp;H1<br>Private Const OFN_SHAREAWARE = &amp;H4000<br>Private Const OFN_SHAREFALLTHROUGH = 2<br>Private Const OFN_SHARENOWARN = 1<br>Private Const OFN_SHAREWARN = 0<br>Private Const OFN_SHOWHELP = &amp;H10<br>Private Const PD_ENABLEPRINTHOOK = &amp;H1000<br>Private Const PD_ENABLEPRINTTEMPLATE = &amp;H4000<br>Private Const PD_ENABLEPRINTTEMPLATEHANDLE = &amp;H10000<br>Private Const PD_ENABLESETUPHOOK = &amp;H2000<br>Private Const PD_ENABLESETUPTEMPLATE = &amp;H8000<br>Private Const PD_ENABLESETUPTEMPLATEHANDLE = &amp;H20000<br>Private Const PD_NONETWORKBUTTON = &amp;H200000<br>Private Const PD_PRINTSETUP = &amp;H40<br>Private Const PD_USEDEVMODECOPIES = &amp;H40000<br>Private Const PD_USEDEVMODECOPIESANDCOLLATE = &amp;H40000<br>Private Const PD_NOWARNING = &amp;H80<br>Private Const CF_ANSIONLY = &amp;H400&amp;<br>Private Const CF_APPLY = &amp;H200&amp;<br>Private Const CF_BITMAP = 2<br>Private Const CF_PRINTERFONTS = &amp;H2<br>Private Const CF_PRIVATEFIRST = &amp;H200<br>Private Const CF_PRIVATELAST = &amp;H2FF<br>Private Const CF_RIFF = 11<br>Private Const CF_SCALABLEONLY = &amp;H20000<br>Private Const CF_SCREENFONTS = &amp;H1<br>Private Const CF_BOTH = (CF_SCREENFONTS Or CF_PRINTERFONTS)<br>Private Const CF_DIB = 8<br>Private Const CF_DIF = 5<br>Private Const CF_DSPBITMAP = &amp;H82<br>Private Const CF_DSPENHMETAFILE = &amp;H8E<br>Private Const CF_DSPMETAFILEPICT = &amp;H83<br>Private Const CF_DSPTEXT = &amp;H81<br>Private Const CF_EFFECTS = &amp;H100&amp;<br>Private Const CF_ENABLEHOOK = &amp;H8&amp;<br>Private Const CF_ENABLETEMPLATE = &amp;H10&amp;<br>Private Const CF_ENABLETEMPLATEHANDLE = &amp;H20&amp;<br>Private Const CF_ENHMETAFILE = 14<br>Private Const CF_FIXEDPITCHONLY = &amp;H4000&amp;<br>Private Const CF_FORCEFONTEXIST = &amp;H10000<br>Private Const CF_GDIOBJFIRST = &amp;H300<br>Private Const CF_GDIOBJLAST = &amp;H3FF<br>Private Const CF_INITTOLOGFONTSTRUCT = &amp;H40&amp;<br>Private Const CF_LIMITSIZE = &amp;H2000&amp;<br>Private Const CF_METAFILEPICT = 3<br>Private Const CF_NOFACESEL = &amp;H80000<br>Private Const CF_NOVERTFONTS = &amp;H1000000<br>Private Const CF_NOVECTORFONTS = &amp;H800&amp;<br>Private Const CF_NOOEMFONTS = CF_NOVECTORFONTS<br>Private Const CF_NOSCRIPTSEL = &amp;H800000<br>Private Const CF_NOSIMULATIONS = &amp;H1000&amp;<br>Private Const CF_NOSIZESEL = &amp;H200000<br>Private Const CF_NOSTYLESEL = &amp;H100000<br>Private Const CF_OEMTEXT = 7<br>Private Const CF_OWNERDISPLAY = &amp;H80<br>Private Const CF_PALETTE = 9<br>Private Const CF_PENDATA = 10<br>Private Const CF_SCRIPTSONLY = CF_ANSIONLY<br>Private Const CF_SELECTSCRIPT = &amp;H400000<br>Private Const CF_SHOWHELP = &amp;H4&amp;<br>Private Const CF_SYLK = 4<br>Private Const CF_TEXT = 1<br>Private Const CF_TIFF = 6<br>Private Const CF_TTONLY = &amp;H40000<br>Private Const CF_UNICODETEXT = 13<br>Private Const CF_USESTYLE = &amp;H80&amp;<br>Private Const CF_WAVE = 12<br>Private Const CF_WYSIWYG = &amp;H8000<br>Private Const CFERR_CHOOSEFONTCODES = &amp;H2000<br>Private Const CFERR_MAXLESSTHANMIN = &amp;H2002<br>Private Const CFERR_NOFONTS = &amp;H2001<br>Private Const CC_ANYCOLOR = &amp;H100<br>Private Const CC_CHORD = 4<br>Private Const CC_CIRCLES = 1<br>Private Const CC_ELLIPSES = 8<br>Private Const CC_ENABLEHOOK = &amp;H10<br>Private Const CC_ENABLETEMPLATE = &amp;H20<br>Private Const CC_ENABLETEMPLATEHANDLE = &amp;H40<br>Private Const CC_FULLOPEN = &amp;H2<br>Private Const CC_INTERIORS = 128<br>Private Const CC_NONE = 0<br>Private Const CC_PIE = 2<br>Private Const CC_PREVENTFULLOPEN = &amp;H4<br>Private Const CC_RGBINIT = &amp;H1<br>Private Const CC_ROUNDRECT = 256 \u2018<br>Private Const CC_SHOWHELP = &amp;H8<br>Private Const CC_SOLIDCOLOR = &amp;H80<br>Private Const CC_STYLED = 32<br>Private Const CC_WIDE = 16<br>Private Const CC_WIDESTYLED = 64<br>Private Const CCERR_CHOOSECOLORCODES = &amp;H5000<br>Private Const LOGPIXELSY = 90<br>Private Const CCHDEVICENAME = 32<br>Private Const CCHFORMNAME = 32<br>Private Const SIMULATED_FONTTYPE = &amp;H8000<br>Private Const PRINTER_FONTTYPE = &amp;H4000<br>Private Const SCREEN_FONTTYPE = &amp;H2000<br>Private Const BOLD_FONTTYPE = &amp;H100<br>Private Const ITALIC_FONTTYPE = &amp;H200<br>Private Const REGULAR_FONTTYPE = &amp;H400<br>Private Const WM_CHOOSEFONT_GETLOGFONT = (&amp;H400 + 1)<br>Private Const LBSELCHSTRING = \u201ccommdlg_LBSelChangedNotify\u201d<br>Private Const SHAREVISTRING = \u201ccommdlg_ShareViolation\u201d<br>Private Const FILEOKSTRING = \u201ccommdlg_FileNameOK\u201d<br>Private Const COLOROKSTRING = \u201ccommdlg_ColorOK\u201d<br>Private Const SETRGBSTRING = \u201ccommdlg_SetRGBColor\u201d<br>Private Const FINDMSGSTRING = \u201ccommdlg_FindReplace\u201d<br>Private Const HELPMSGSTRING = \u201ccommdlg_help\u201d<br>Private Const CD_LBSELNOITEMS = -1<br>Private Const CD_LBSELCHANGE = 0<br>Private Const CD_LBSELSUB = 1<br>Private Const CD_LBSELADD = 2<br>Private Const NOERROR = 0<br>Private Const CSIDL_DESKTOP = &amp;H0<br>Private Const CSIDL_PROGRAMS = &amp;H2<br>Private Const CSIDL_CONTROLS = &amp;H3<br>Private Const CSIDL_PRINTERS = &amp;H4<br>Private Const CSIDL_PERSONAL = &amp;H5<br>Private Const CSIDL_FAVORITES = &amp;H6<br>Private Const CSIDL_STARTUP = &amp;H7<br>Private Const CSIDL_RECENT = &amp;H8<br>Private Const CSIDL_SENDTO = &amp;H9<br>Private Const CSIDL_BITBUCKET = &amp;HA<br>Private Const CSIDL_STARTMENU = &amp;HB<br>Private Const CSIDL_DESKTOPDIRECTORY = &amp;H10<br>Private Const CSIDL_DRIVES = &amp;H11<br>Private Const CSIDL_NETWORK = &amp;H12<br>Private Const CSIDL_NETHOOD = &amp;H13<br>Private Const CSIDL_FONTS = &amp;H14<br>Private Const CSIDL_TEMPLATES = &amp;H15<br>Private Const BIF_RETURNONLYFSDIRS = &amp;H1<br>Private Const BIF_DONTGOBELOWDOMAIN = &amp;H2<br>Private Const BIF_STATUSTEXT = &amp;H4<br>Private Const BIF_RETURNFSANCESTORS = &amp;H8<br>Private Const BIF_BROWSEFORCOMPUTER = &amp;H1000<br>Private Const BIF_BROWSEFORPRINTER = &amp;H2000<br>Private Const HWND_BROADCAST = &amp;HFFFF&amp;<br>Private Const WM_WININICHANGE = &amp;H1A<br>Private Const WM_USER = &amp;H400<br>Private Const BFFM_INITIALIZED = 1<br>Private Const BFFM_SELCHANGED = 2<br>Private Const BFFM_SETSTATUSTEXT = (WM_USER + 100)<br>Private Const BFFM_SETSelectION = (WM_USER + 102)<br>Private Const BIF_USENEWUI = &amp;H40 \u2018\u5bf9\u8bdd\u6846\u4e0a\u5e26\u201c\u65b0\u5efa\u6587\u4ef6\u5939\u201d\u6309\u94ae<\/p>\n\n\n\n<p>Private m_CurrentDirectory As String \u2018The current directory<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ SetDefaultPrinter Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Sets the user\u2019s default printer to the printer represented by the passed printer object.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ BOOL = SetDefaultPrinter(object)<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ Dim objNewPrinter As Printer<br>\u2018\/\/ Set objNewPrinter = Printers(2)<br>\u2018\/\/ SetDefaultPrinter objNewPrinter<br>\u2018\/\/<br>Public Function SetDefaultPrinter(objPrn As Printer) As Boolean<br>Dim szTmp As String<br>szTmp = objPrn.DeviceName &amp; \u201c,\u201d &amp; objPrn.DriverName &amp; \u201c,\u201d &amp; objPrn.Port<br>lRet = WriteProfileString(\u201cwindows\u201d, \u201cdevice\u201d, szTmp)<br>lRet = SendMessageByString(HWND_BROADCAST, WM_WININICHANGE, 0&amp;, \u201cwindows\u201d)<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ GetDefaultPrinter Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Retuns the device name of the default printer.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ StrVar = GetDefaultPrinter()<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ szDefPrinter = GetDefaultPrinter<br>\u2018\/\/<br>Public Function GetDefaultPrinter() As String<br>Dim szTmp As String, dwBuf As Long<br>dwBuf = 1024<br>szTmp = Space$(dwBuf + 1)<br>lRet = GetProfileString(\u201cwindows\u201d, \u201cdevice\u201d, \u201c\u201d, szTmp, dwBuf)<br>GetDefaultPrinter = Trim(Left(szTmp, lRet))<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ ResetDefaultPrinter Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Resets the default printer to the passed device name.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ BOOL = ResetDefaultPrinter(StrVar)<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ szDefPrinter = GetDefaultPrinter()<br>\u2018\/\/ If Not ResetDefaultPrinter(szDefPrinter) Then<br>\u2018\/\/ MsgBox \u201cCould not reset default printer.\u201d, vbExclamation<br>\u2018\/\/ End If<br>\u2018\/\/<br>Public Function ResetDefaultPrinter(szBuf As String) As Boolean<br>lRet = WriteProfileString(\u201cwindows\u201d, \u201cdevice\u201d, szBuf)<br>lRet = SendMessageByString(HWND_BROADCAST, WM_WININICHANGE, 0&amp;, \u201cwindows\u201d)<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ BrowseFolder Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Allows the user to interactively browse and select a folder found in the file system.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ StrVar = BrowseFolder(lhWnd, StrVar)<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ szFilename = BrowseFolder(Me.hWnd, \u201cBrowse for application folder:\u201d)<br>\u2018\/\/<br>Public Function BrowseFolder(lhWnd As Long, szDialogTitle As String) As String<br>Dim BI As BROWSEINFO, dwIList As Long, szPath As String, wPos As Integer<br>BI.hOwner = lhWnd<br>BI.lpszTitle = szDialogTitle<br>BI.ulFlags = BIF_RETURNONLYFSDIRS<br>dwIList = SHBrowseForFolder(BI)<br>szPath = Space$(512)<br>lRet = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)<br>If lRet Then<br>wPos = InStr(szPath, Chr(0))<br>BrowseFolder = Left$(szPath, wPos \u2013 1)<br>Else<br>BrowseFolder = \u201c\u201d<br>End If<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ DialogConnectToPrinter Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Allows users to interactively selection and connect to local and network printers.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ DialogConnectToPrinter<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ DialogConnectToPrinter<br>\u2018\/\/<br>Public Function DialogConnectToPrinter() As Boolean<br>Shell \u201crundll32.exe shell32.dll,SHHelpShortcuts_RunDLL AddPrinter\u201d, vbNormalFocus<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ ByteToString Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Converts an array of bytes into a string<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ StrVar = ByteToString(ARRAY)<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ szBuf = BytesToString(aChars(10))<br>\u2018\/\/<br>Private Function ByteToString(aBytes() As Byte) As String<br>Dim dwBytePoint As Long, dwByteVal As Long, szOut As String<br>dwBytePoint = LBound(aBytes)<br>While dwBytePoint &lt;= UBound(aBytes)<br>dwByteVal = aBytes(dwBytePoint)<br>If dwByteVal = 0 Then<br>ByteToString = szOut<br>Exit Function<br>Else<br>szOut = szOut &amp; Chr$(dwByteVal)<br>End If<br>dwBytePoint = dwBytePoint + 1<br>Wend<br>ByteToString = szOut<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ DialogColor Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Displays the Color common dialog box and sets a passed controls foreground color.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ BOOL = DialogColor(lhWnd, CONTROL)<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ Dim yn as Boolean<br>\u2018\/\/ yn = DialogColor(Me.hWnd, txtEditor)<br>\u2018\/\/<br>Public Function DialogColor(lhWnd As Long, C As Control) As Boolean<br>Dim CS As COLORSTRUC, CustColor(16) As Long<br>CS.lStructSize = Len(CS)<br>CS.hwnd = lhWnd<br>CS.hInstance = App.hInstance<br>CS.Flags = CC_SOLIDCOLOR<br>CS.lpCustColors = String$(16 * 4, 0)<br>lRet = ChooseColor(CS)<br>If lRet = 0 Then<br>DialogColor = False<br>Else<br>DialogColor = True<br>C.ForeColor = CS.rgbResult<br>End If<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ DialogFont Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Displays the Font common dialog box and sets a passed controls font properties.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ BOOL = DialogFont(lhWnd, CONTROL)<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ Dim yn as Boolean<br>\u2018\/\/ yn = DialogFont(Me.hWnd, txtEditor)<br>\u2018\/\/<br>Public Function DialogFont(lhWnd As Long, C As Control) As Boolean<br>Dim lf As LogFont, FS As FONTSTRUC<br>Dim lLogFontAddress As Long, lMemHandle As Long<br>If C.Font.Bold Then lf.lfWeight = FW_BOLD<br>If C.Font.Italic = True Then lf.lfItalic = 1<br>If C.Font.Underline = True Then lf.lfUnderline = 1<br>FS.lStructSize = Len(FS)<br>lMemHandle = GlobalAlloc(GHND, Len(lf))<br>If lMemHandle = 0 Then<br>DialogFont = False<br>Exit Function<br>End If<br>lLogFontAddress = GlobalLock(lMemHandle)<br>If lLogFontAddress = 0 Then<br>DialogFont = False<br>Exit Function<br>End If<br>CopyMemory ByVal lLogFontAddress, lf, Len(lf)<br>FS.lpLogFont = lLogFontAddress<br>FS.iPointSize = C.Font.Size * 10<br>FS.Flags = CF_SCREENFONTS Or CF_EFFECTS<br>If ChooseFont(FS) = 1 Then<br>CopyMemory lf, ByVal lLogFontAddress, Len(lf)<br>If lf.lfWeight &gt;= FW_BOLD Then<br>C.Font.Bold = True<br>Else<br>C.Font.Bold = False<br>End If<br>If lf.lfItalic = 1 Then<br>C.Font.Italic = True<br>Else<br>C.Font.Italic = False<br>End If<br>If lf.lfUnderline = 1 Then<br>C.Font.Underline = True<br>Else<br>C.Font.Underline = False<br>End If<br>C.Font.Name = ByteToString(lf.lfFaceName())<br>C.Font.Size = CLng(FS.iPointSize \/ 10)<br>DialogFont = True<br>Else<br>DialogFont = False<br>End If<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ DialogFile Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Displays the File Open\/Save As common dialog boxes.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ StrVar = DialogFile(lhWnd, IntVar, StrVar, StrVar, StrVar, StrVar, StrVar, IntVar)<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ szFilename = DialogFile(Me.hWnd, 1, \u201cOpen\u201d, \u201cMyFileName.doc\u201d, \u201cDocuments\u201d &amp; \u201c|\u201d &amp; \u201c.doc\u201d &amp; \u201c|\u201d &amp; \u201cAll files\u201d &amp; \u201c|\u201d &amp; \u201c.*\u201d, App.Path, \u201cdoc\u201d, Path, 1)<br>\u2018\/\/<br>Public Function DialogFile(lhWnd As Long, wMode As Integer, szDialogTitle As String, ByVal szFilename As String, szFilter As String, ByVal szDefDir As String, szDefExt As String, szDestDir As String, ByVal iFilterIndex As Integer) As String<br>szFilter = Replace(szFilter, \u201c|\u201d, Chr(0), 1, -1, vbBinaryCompare)<br>Dim OFN As OPENFILENAME, szFile As String, szFileTitle As String<br>OFN.lStructSize = Len(OFN)<br>OFN.hwnd = lhWnd<br>OFN.lpstrTitle = szDialogTitle<br>OFN.lpstrFile = szFilename &amp; String$(250 \u2013 Len(szFilename), 0)<br>OFN.nMaxFile = BUFFER<br>OFN.lpstrFileTitle = String$(BUFFER, 0)<br>OFN.nMaxFileTitle = BUFFER<br>OFN.lpstrFilter = szFilter<br>OFN.nFilterIndex = iFilterIndex<br>OFN.lpstrInitialDir = szDefDir<br>OFN.lpstrDefExt = szDefExt<br>If wMode = 1 Then<br>OFN.Flags = OFN_HIDEREADONLY Or OFN_PATHMUSTEXIST Or OFN_FILEMUSTEXIST<br>lRet = GetOpenFileName(OFN)<br>Else<br>OFN.Flags = OFN_HIDEREADONLY Or OFN_OVERWRITEPROMPT Or OFN_PATHMUSTEXIST<br>lRet = GetSaveFileName(OFN)<br>End If<br>If lRet &lt;&gt; 0 Then<br>\u2018\/\/ If InStr(OFN.lpstrFileTitle, Chr$(0)) &gt; 0 Then<br>\u2018\/\/ szFileTitle = Left$(OFN.lpstrFileTitle, InStr(OFN.lpstrFileTitle, Chr$(0)) \u2013 1)<br>\u2018\/\/ End If<br>If InStr(OFN.lpstrFile, Chr$(0)) &gt; 0 Then<br>szFile = Left$(OFN.lpstrFile, InStr(OFN.lpstrFile, Chr$(0)) \u2013 1)<br>End If<br>\u2018\/\/ OFN.nFileOffset is the number of characters from the beginning of the<br>\u2018\/\/ full path to the start of the file name<br>\u2018\/\/ OFN.nFileExtension is the number of characters from the beginning of the<br>\u2018\/\/ full path to the file\u2019s extention, including the (.)<br>\u2018\/\/ MsgBox \u201cFile Name is \u201d &amp; szFileTitle &amp; Chr$(13) &amp; Chr$(10) &amp; \u201cFull path and file is \u201d &amp; szFile, , \u201cOpen\u201d<\/p>\n\n\n\n<p>&#8216;\/\/ DialogFile = szFile &amp; &#8220;|&#8221; &amp; szFileTitle<br>DialogFile = szFile<br>szDestDir = Left(szFile, OFN.nFileOffset)<br>Else<br>DialogFile = &#8220;&#8221;<br>End If<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ DialogOpenFile Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Displays the MultiFile Open As common dialog boxes.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ StrVar = DialogOpenFile(lhWnd, StrVar, StrVar, StrVar)<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ szFilename = DialogOpenFile(Me.hWnd, \u201cOpen MultiFile\u201d, \u201cDocuments\u201d &amp; \u201c|\u201d &amp; \u201c.doc\u201d &amp; \u201c|\u201d &amp; \u201cAll files\u201d &amp; \u201c|\u201d &amp; \u201c.*\u201d, App.Path)<br>\u2018\/\/<br>Public Function DialogOpenFile(lhWnd As Long, szDialogTitle As String, szFilter As String, ByVal szDefDir As String) As String<br>szFilter = Replace(szFilter, \u201c|\u201d, Chr(0), 1, -1, vbBinaryCompare)<br>Dim OFN As OPENFILENAME, szFile As String, szFileTitle As String<br>OFN.lStructSize = Len(OFN)<br>OFN.hwnd = lhWnd<br>OFN.lpstrTitle = szDialogTitle<br>OFN.lpstrFile = Space$(BUFFER \u2013 1) \u2018String$(BUFFER, 0) \u2018szFilename &amp; String$(250 \u2013 Len(szFilename), 0)<br>OFN.nMaxFile = BUFFER<br>OFN.lpstrFileTitle = Space$(BUFFER \u2013 1) \u2018String$(BUFFER, 0)<br>OFN.nMaxFileTitle = BUFFER<br>OFN.lpstrFilter = szFilter<br>\u2018OFN.nFilterIndex = iFilterIndex<br>OFN.lpstrInitialDir = szDefDir<br>\u2018OFN.lpstrDefExt = szDefExt<br>OFN.Flags = OFN_ALLOWMULTISELECT Or OFN_EXPLORER Or OFN_FILEMUSTEXIST<br>lRet = GetOpenFileName(OFN)<br>If lRet &lt;&gt; 0 Then<br>DialogOpenFile = OFN.lpstrFile<br>Else<br>DialogOpenFile = \u201c\u201d<br>End If<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ DialogPrint Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Displays the Print common dialog box and returns a structure containing user entered<br>\u2018\/\/ information from the common dialog box.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ PRINTPROPS = DialogPrint(lhWnd, BOOL, DWORD)<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ Dim PP As PRINTPROPS<br>\u2018\/\/ PP = DialogPrint(Me.hWnd, True, PD_PAGENUMS or PD_SELECTION or PD_SHOWHELP)<br>\u2018\/\/<br>Public Function DialogPrint(lhWnd As Long, bPages As Boolean, Flags As Long) As PRINTPROPS<br>Dim DM As DEVMODE, PD As PRINTDLGSTRUC<br>Dim lpDM As Long, wNull As Integer, szDevName As String<br>PD.lStructSize = Len(PD)<br>PD.hwnd = lhWnd<br>PD.hDevMode = 0<br>PD.hDevNames = 0<br>PD.hDC = 0<br>PD.Flags = Flags<br>PD.nFromPage = 0<br>PD.nToPage = 0<br>PD.nMinPage = 0<br>If bPages Then PD.nMaxPage = bPages \u2013 1<br>PD.nCopies = 0<br>DialogPrint.Cancel = True<br>If PrintDlg(PD) Then<br>lpDM = GlobalLock(PD.hDevMode)<br>CopyMemory DM, ByVal lpDM, Len(DM)<br>lpDM = GlobalUnlock(PD.hDevMode)<br>DialogPrint.Cancel = False<br>DialogPrint.Device = Left$(DM.dmDeviceName, InStr(DM.dmDeviceName, Chr(0)) \u2013 1)<br>DialogPrint.FromPage = 0<br>DialogPrint.ToPage = 0<br>DialogPrint.All = True<br>If PD.Flags And PD_PRINTTOFILE Then DialogPrint.File = True Else DialogPrint.File = False<br>If PD.Flags And PD_COLLATE Then DialogPrint.Collate = True Else DialogPrint.Collate = False<br>If PD.Flags And PD_PAGENUMS Then<br>DialogPrint.Pages = True<br>DialogPrint.All = False<br>DialogPrint.FromPage = PD.nFromPage<br>DialogPrint.ToPage = PD.nToPage<br>Else<br>DialogPrint.Pages = False<br>End If<br>If PD.Flags And PD_SELECTION Then<br>DialogPrint.Selection = True<br>DialogPrint.All = False<br>Else<br>DialogPrint.Pages = False<br>End If<br>If PD.nCopies = 1 Then<br>DialogPrint.Copies = DM.dmCopies<br>End If<br>DialogPrint.DM = DM<br>End If<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ DialogPrintSetup Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Displays the Print Setup common dialog box.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ BOOL = DialogPrintSetup(lhWnd)<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ If DialogPrintSetup(Me.hWnd) Then<br>\u2018\/\/ End If<br>\u2018\/\/<br>Public Function DialogPrintSetup(lhWnd As Long) As Boolean<br>Dim PD As PRINTDLGSTRUC<br>PD.lStructSize = Len(PD)<br>PD.hwnd = lhWnd<br>PD.Flags = PD_PRINTSETUP<br>lRet = PrintDlg(PD)<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ BrowseForFolder Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Allows the user to interactively browse and select a folder found from a folder in the file system.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ StrVar = BrowseForFolder(lhWnd, StrVar, StrVar)<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ szFilename = BrowseForFolder(Me.hWnd, \u201cBrowse for application folder:\u201d, App.Path)<br>\u2018\/\/<br>\u2018Public Function BrowseForFolder(oWner As Form, sTitle As String, sStartDir As String) As String<br>Public Function BrowseForFolder(lhWnd As Long, sTitle As String, sStartDir As String) As String<br>Dim lpIDList As Long<br>Dim szTitle As String<br>Dim sBuffer As String<br>Dim tBrowseInfo As BROWSEINFO<br>m_CurrentDirectory = sStartDir &amp; vbNullChar<br>szTitle = sTitle<br>With tBrowseInfo<br>.hOwner = lhWnd<br>.lpszTitle = szTitle \u2018lstrcat(szTitle, \u201c\u201d)<br>.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN + BIF_STATUSTEXT<br>.lpfnCallback = GetAddressofFunction(AddressOf BrowseCallbackProc) \u2018get address of function.<br>End With<br>lpIDList = SHBrowseForFolder(tBrowseInfo)<br>If (lpIDList) Then<br>sBuffer = Space$(BUFFER)<br>SHGetPathFromIDList lpIDList, sBuffer<br>sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) \u2013 1)<br>BrowseForFolder = sBuffer<br>Else<br>BrowseForFolder = \u201c\u201d<br>End If<br>End Function<\/p>\n\n\n\n<p>\u2018\/\/<br>\u2018\/\/ BrowseForNewFolder Function<br>\u2018\/\/<br>\u2018\/\/ Description:<br>\u2018\/\/ Allows the user to interactively browse and select a folder found from a folder in the file system with new folder.<br>\u2018\/\/<br>\u2018\/\/ Syntax:<br>\u2018\/\/ StrVar = BrowseForNewFolder(lhWnd, StrVar, StrVar)<br>\u2018\/\/<br>\u2018\/\/ Example:<br>\u2018\/\/ szFilename = BrowseForNewFolder(Me.hWnd, \u201cBrowse for application folder:\u201d, App.Path)<br>\u2018\/\/<br>\u2018Public Function BrowseForNewFolder(oWner As Form, sTitle As String, sStartDir As String) As String<br>Public Function BrowseForNewFolder(lhWnd As Long, sTitle As String, sStartDir As String) As String<br>Dim iNull As Integer<br>Dim lpIDList As Long<br>Dim szTitle As String<br>Dim sBuffer As String<br>Dim tBrowseInfo As BROWSEINFO<br>m_CurrentDirectory = sStartDir &amp; vbNullChar<br>szTitle = sTitle<br>With tBrowseInfo<br>.hOwner = lhWnd \u2018\u8bbe\u7f6e\u4e3b\u7a97\u4f53\u53e5\u67c4<br>.lpszTitle = szTitle \u2018lstrcat(szTitle, \u201c\u201d)<br>.ulFlags = BIF_RETURNONLYFSDIRS Or BIF_USENEWUI \u2018\u65b0\u5efa\u6587\u4ef6\u5939<br>.lpfnCallback = GetAddressofFunction(AddressOf BrowseCallbackProc) \u2018get address of function.<br>End With<br>\u2018\u663e\u793a\u5217\u8868\u6846<br>lpIDList = SHBrowseForFolder(tBrowseInfo)<br>If (lpIDList) Then<br>sBuffer = String$(BUFFER, 0)<br>\u2018\u83b7\u53d6\u8fd4\u56de\u7684\u8def\u5f84<br>SHGetPathFromIDList lpIDList, sBuffer<br>\u2018\u91ca\u653e\u5185\u5b58\u5757<br>CoTaskMemFree lpIDList<br>iNull = InStr(sBuffer, vbNullChar) \u2018\u53bb\u9664\u7a7a\u683c\u7b26<br>If iNull Then sBuffer = Left$(sBuffer, iNull \u2013 1)<br>End If<br>BrowseForNewFolder = sBuffer<br>End Function<\/p>\n\n\n\n<p>Private Function BrowseCallbackProc(ByVal lhWnd As Long, ByVal uMsg As Long, ByVal lp As Long, ByVal pData As Long) As Long<br>Dim lpIDList As Long<br>Dim sBuffer As String<br>If Not ExposeError Then On Error Resume Next<br>Select Case uMsg<br>Case BFFM_INITIALIZED<br>Call SendMessage(lhWnd, BFFM_SETSelectION, 1, m_CurrentDirectory)<br>Case BFFM_SELCHANGED<br>sBuffer = Space$(BUFFER)<br>lRet = SHGetPathFromIDList(lp, sBuffer)<br>If lRet = 1 Then<br>Call SendMessage(lhWnd, BFFM_SETSTATUSTEXT, 0, sBuffer)<br>End If<br>End Select<br>BrowseCallbackProc = 0<br>End Function<\/p>\n\n\n\n<p>Private Function GetAddressofFunction(lAdd As Long) As Long<br>GetAddressofFunction = lAdd<br>End Function<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Option Explicit Private Type OPENFILENAMElStructSize As &hellip; <a href=\"https:\/\/www.wyrcad.com\/?p=1337\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u5bf9\u8bdd\u6846\u51fd\u6570\u7cfb\u5217\u4e4b\u4e00\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[24,17],"class_list":["post-1337","post","type-post","status-publish","format-standard","hentry","category-bianchengyuandi","tag-vb","tag-biancheng"],"_links":{"self":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1337","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1337"}],"version-history":[{"count":2,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1337\/revisions"}],"predecessor-version":[{"id":1508,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=\/wp\/v2\/posts\/1337\/revisions\/1508"}],"wp:attachment":[{"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1337"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wyrcad.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}