- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的应用程序中,我只想显示“网上邻居”,所以我使用以下代码:
Dim fbd As New FolderBrowserDialog
fbd.ShowNewFolderButton = False
Dim type As Type = fbd.[GetType]
Dim fieldInfo As Reflection.FieldInfo = type.GetField("rootFolder", _
Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance)
'========= Now set the value for Folder Dialog using DirectCast
'=== 18 = Network Neighborhood is the root
fieldInfo.SetValue(fbd, DirectCast(18, Environment.SpecialFolder))
If fbd.ShowDialog() = DialogResult.OK Then
txtNetworkDrive.Text = fbd.SelectedPath
End If
在这种情况下,还会显示“共享打印机”。
如果用户选择“打印机”,则会显示错误。
最佳答案
您可以下载 Hans 建议的工作示例 here .
为方便起见,这里有一个精简版,它使用带有按钮和字段的简单表单,但还包括其他标志及其描述。
Imports System.Runtime.InteropServices
Public Class FoldersOnly
<Flags()> _
Public Enum BrowseInfoFlags As UInteger
''' <summary>
''' Only return file system directories.
''' </summary>
BIF_RETURNONLYFSDIRS = &H1
''' <summary>
''' Do not include network folders below the domain level in the dialog box's tree view control.
''' </summary>
BIF_DONTGOBELOWDOMAIN = &H2
''' <summary>
''' Include a status area in the dialog box.
''' The callback function can set the status text by sending messages to the dialog box.
''' This flag is not supported when <bold>BIF_NEWDIALOGSTYLE</bold> is specified
''' </summary>
BIF_STATUSTEXT = &H4
''' <summary>
''' Only return file system ancestors.
''' An ancestor is a subfolder that is beneath the root folder in the namespace hierarchy.
''' If the user selects an ancestor of the root folder that is not part of the file system, the OK button is grayed
''' </summary>
BIF_RETURNFSANCESTORS = &H8
''' <summary>
''' Include an edit control in the browse dialog box that allows the user to type the name of an item.
''' </summary>
BIF_EDITBOX = &H10
''' <summary>
''' If the user types an invalid name into the edit box, the browse dialog box calls the application's BrowseCallbackProc with the BFFM_VALIDATEFAILED message.
''' This flag is ignored if <bold>BIF_EDITBOX</bold> is not specified.
''' </summary>
BIF_VALIDATE = &H20
''' <summary>
''' Use the new user interface.
''' Setting this flag provides the user with a larger dialog box that can be resized.
''' The dialog box has several new capabilities, including: drag-and-drop capability within the
''' dialog box, reordering, shortcut menus, new folders, delete, and other shortcut menu commands.
''' </summary>
BIF_NEWDIALOGSTYLE = &H40
''' <summary>
''' The browse dialog box can display URLs. The <bold>BIF_USENEWUI</bold> and <bold>BIF_BROWSEINCLUDEFILES</bold> flags must also be set.
''' If any of these three flags are not set, the browser dialog box rejects URLs.
''' </summary>
BIF_BROWSEINCLUDEURLS = &H80
''' <summary>
''' Use the new user interface, including an edit box. This flag is equivalent to <bold>BIF_EDITBOX | BIF_NEWDIALOGSTYLE</bold>
''' </summary>
BIF_USENEWUI = (BIF_EDITBOX Or BIF_NEWDIALOGSTYLE)
''' <summary>
''' hen combined with <bold>BIF_NEWDIALOGSTYLE</bold>, adds a usage hint to the dialog box, in place of the edit box. <bold>BIF_EDITBOX</bold> overrides this flag.
''' </summary>
BIF_UAHINT = &H100
''' <summary>
''' Do not include the New Folder button in the browse dialog box.
''' </summary>
BIF_NONEWFOLDERBUTTON = &H200
''' <summary>
''' When the selected item is a shortcut, return the PIDL of the shortcut itself rather than its target.
''' </summary>
BIF_NOTRANSLATETARGETS = &H400
''' <summary>
''' Only return computers. If the user selects anything other than a computer, the OK button is grayed.
''' </summary>
BIF_BROWSEFORCOMPUTER = &H1000
''' <summary>
''' Only allow the selection of printers. If the user selects anything other than a printer, the OK button is grayed
''' </summary>
BIF_BROWSEFORPRINTER = &H2000
''' <summary>
''' The browse dialog box displays files as well as folders.
''' </summary>
BIF_BROWSEINCLUDEFILES = &H4000
''' <summary>
''' The browse dialog box can display shareable resources on remote systems.
''' </summary>
BIF_SHAREABLE = &H8000
''' <summary>
''' Allow folder junctions such as a library or a compressed file with a .zip file name extension to be browsed.
''' </summary>
BIF_BROWSEFILEJUNCTIONS = &H10000
End Enum
Private Structure BrowseInfo
Public hWndOwner As IntPtr
Public pidlRoot As Integer
Public sDisplayName As String
Public sTitle As String
Public ulFlags As Integer
Public lpfn As Integer
Public lParam As Integer
Public iImage As Integer
End Structure
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal nPidl As Integer, ByVal pszPath As String) As Integer
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (ByRef lpBrowseInfo As BrowseInfo) As Integer
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal PV_Renamed As Integer)
Private Const BIF_RETURNONLYFSDIRS As Short = &H1S
Private Const BIF_DONTGOBELOWDOMAIN As Short = &H2S
Private Const BIF_STATUSTEXT As Short = &H4S
Private Const BIF_RETURNFSANCESTORS As Short = &H8S
Private Const BIF_BROWSEFORCOMPUTER As Short = &H1000S
Private Const BIF_BROWSEFORPRINTER As Short = &H2000S
Private Const MAX_PATH As Short = 256
' Let the user browse for a folder.
' Return the folder or Nothing if the user cancels.
Public Function BrowseForFolder(ByRef dialog_title As _
String, ByRef frm As Form) As String
Try
Dim browse_info As BrowseInfo
With browse_info
.hWndOwner = frm.Handle
.pidlRoot = 0
.sDisplayName = Space$(260)
.sTitle = dialog_title
.ulFlags = BrowseInfoFlags.BIF_RETURNONLYFSDIRS
.lpfn = 0
.lParam = 0
.iImage = 0
End With
Dim item As Integer = _
SHBrowseForFolder(browse_info)
Dim path As String = New String(" "c, MAX_PATH)
If SHGetPathFromIDList(item, path) = 0 Then
path = Nothing
Else
path = path.Trim
End If
CoTaskMemFree(item)
Return path
Catch ex As Exception
MessageBox.Show(ex.Message)
Return Nothing
End Try
End Function
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
txtNetworkDrive.Text = BrowseForFolder("test", Me)
End Sub
End Class
关于vb.net - 如何在文件夹浏览器对话框中排除共享打印机?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17017668/
我有一个代理类,它接收请求并将请求发送到另一台服务器,获取响应并将其定向回原始请求者。我使用套接字连接到服务器并使用 Printwriter 对其进行写入。像这样的事情 private Pri
我想使用 Java Swing 为医疗商店开发一个独立的应用程序。强制要求在没有打印对话框的情况下单击一下即可打印小尺寸(219 毫米至 140 毫米)的纸张。他们需要间歇性地将报告从不同的打印机打印
我是一名学生,需要创建一个 silten 打印功能,希望能够打印 PDF。这个需要基于Java。 我在 Google 上搜索并找到了一个无需对话框即可打印的代码。但如果源是 .txt 文件,它就会正确
我正在寻找 POS 打印的解决方案。 场景是: 一家餐厅目前有一个 POS 系统启动并运行,他们从店内的 iPad 上接受订单,并有一个网络设置来处理订单并在厨房的热敏打印机上自动打印出来(很酷,对吧
尝试使用以下代码示例,它在 WinForm 应用程序中运行良好,但在 VSTO 中运行不佳。是否有某种允许访问的权限? 可以设置默认打印机,但不能获取或设置打印机设置。 从插件中获取以下异常: Sys
我必须通过蓝牙将字体文件发送到我的打印机 Zebra RW420。我正在使用 Zebra Windows Mobile SDK,但无法找到任何方式将其发送和存储在打印机上。我可以通过 Label Vi
我需要创建一个“粉碎”的虚拟打印机 基本上这是我的问题。我有一个软件程序需要在保存文件之前“打印”文件。我希望能够打印到我的碎纸机,以便它保存文档,但实际上我不想打印文档。所以我需要打印到一个程序,该
我在吃 Argox 标签打印机时遇到了麻烦,只是仍然无法向她发送任何内容。型号为 Argox OS214 tt,ANPP,接受 PPLB。 使用通用类连接串行设备,我将她用于多个财务打印机和秤,附后。
我正在编写一些在 org.eclipse.swt.printing.Printer 上打印的代码。所以第一步是看看我如何测试它,但似乎架构不允许我定义自己的打印机,因为 PrinterData 和 P
我有一个标签列表,数据如下。 ['id', 'Version', 'chip_name', 'xversion', 'device', 'opt_param', 'place_effort'][1,
我正在开发一个应用程序,在该应用程序中,我通过 IP 地址和端口号从我的手机向 WiFi 打印机发送文件,这些文件是 .txt、.png、.jpg、.doc。它们应该从打印机打印出来。我尝试了以下代码
我正在尝试使用以下代码打印图像,但文档只是停留在打印作业队列中,拒绝打印。在 (windows) 打印作业队列中,我得到: DocumentName: Printing an image Status
这个问题在这里已经有了答案: 关闭 10 年前。 Possible Duplicate: Print preview ZPL II commands using .NET WinForm befor
我有什么 我目前正在编写一个程序,它接受一个指定的文件并对其执行一些操作。目前它打开它,和/或将它附加到电子邮件并将其邮寄到指定地址。 文件可以是以下格式:Excel、Excel Report、Wor
我将这台 Zebra ZM400 打印机连接到网络 (192.168.1.50)。我正在尝试直接从 PHP 将内容推送到这台打印机。 这就是我的想法,但我无法做到这一点。我尝试了 file_put_c
我想显示一个列表,其中包含设备可通过 AirPrint 访问的所有打印机。 我使用 UIPrinterPickerController 让它工作。 是否有以自定义方式显示此 PickerControl
我想将任何办公文件传输到 Wi-ifi 打印机。我完全不知道如何开始。 发现没有用于无线打印的公共(public) API。 谁能分享一些意见? 提前致谢! 最佳答案 您可以首先扫描 WiFi 设备并
有什么方法可以让我在蓝牙热敏打印机上打印收据,因为我真的很难在 flutter 上找到解决方案?任何事情都有帮助,我真的很感激这些答案 最佳答案 我试过 esc_pos_bluetooth 包,但它不
为了在我的 mac 上模拟 ZPL 打印机,我在互联网上搜索了几天。最后,我有一个解决方案可以在这里发布,这样其他用户可能会发现它有帮助。我想在这里发布我的解决方案 Emulate Zebra pri
是否有 ZPL 命令来简单地重启 Zebra 打印机?到目前为止,我只能找到 ~JR 命令,这对我来说看起来不像我正在寻找的东西。我只需要一种方法来重新启动打印机,而无需重置其任何配置。 最佳答案 以
我是一名优秀的程序员,十分优秀!