小编Tec*_*ger的帖子

如何在Go中处理Windows进程?

我试图调用函数RegisterDeviceNotificationWuser32.dll.但是该函数的第一个参数是"将接收设备事件的窗口或服务的句柄"(这是我从微软获得的).

基于云打印机连接器我试图获取处理程序svc.StatusHandler(),但不适合我,每次运行时我得到以下错误:

句柄无效.

那么,使用相同的代码的例子sys我创建了自己的"服务",取代了beep通过函数RegisterDeviceNotification(相同的代码谷歌),并派我的服务,并从返回的值的名字svc.StatusHandler(),但我又收到了同样的信息: "手柄无效."

函数RegisterDeviceNotification

var (
    u32                            = syscall.MustLoadDLL("user32.dll")
    registerDeviceNotificationProc = u32.MustFindProc("RegisterDeviceNotificationW")
)   
Run Code Online (Sandbox Code Playgroud)

这是我需要发送有效处理程序的地方

func RegisterDeviceNotification(handle windows.Handle) error {

    var notificationFilter DevBroadcastDevinterface
    notificationFilter.dwSize = uint32(unsafe.Sizeof(notificationFilter))
    notificationFilter.dwDeviceType = DBT_DEVTYP_DEVICEINTERFACE
    notificationFilter.dwReserved = 0
    // BUG(pastarmovj): This class is ignored for now. Figure out what the right GUID is.
    notificationFilter.classGuid = PRINTERS_DEVICE_CLASS
    notificationFilter.szName = 0

    r1, _, err := …
Run Code Online (Sandbox Code Playgroud)

windows go

9
推荐指数
1
解决办法
798
查看次数

如何在iframe中设置base64 pdf的文件名?

我在base64中有一个PDF报告,我想显示嵌入在HTML页面中的文件.要做到这一点,我使用iFrame并工作,但问题是我无法设置PDF的名称,以便下载时它将以指定的名称保存.

我可以设置文件名吗?如果是,我该怎么办?

这是我的代码:

var iFrameBlock = $("<iframe>").attr({
      "src": base64file_encode,
      "width": "100%",
      "height": "100%",
      "frameborder": "0"
});

$("#previewPDF").html(iFrameBlock);
Run Code Online (Sandbox Code Playgroud)
结果: 预览PDF

当我尝试下载文件时,要保存的名称是"download.pdf" 保存对话框

我尝试了不同的方法,但也不工作:

  1. 添加属性download ="filename.pdf"

       
       var iFrameBlock = $("<iframe>").attr({
          "src": base64file_encode,
          "width": "100%",
          "height": "100%",
          "frameborder": "0",
          "download": "filename.pdf"
       });
       
       
    Run Code Online (Sandbox Code Playgroud)

  2. 我尝试更改iframe中的值,但我找到了正确的属性,Chrome拒绝了该操作.

       
       var iframe = $("iframe")[0];
       var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
       //here I suppose is the label of the filename
       $(iframeDocument).find("viewer-pdf-toolbar");
       
       
    Run Code Online (Sandbox Code Playgroud)

但是,我想防止使用任何其他库.

感谢您的时间

html iframe jquery

6
推荐指数
1
解决办法
3361
查看次数

标签 统计

go ×1

html ×1

iframe ×1

jquery ×1

windows ×1