关于HTML使用ComDlg ActiveX 无法弹出相应对话框的问题1

最近发现,开发的Web应用在客户的某些IE(8,9,11)中弹出不了Windows的字体对话框。

通过 F12 跟踪,错误代码是“-2146827850”,错误信息是“ 对象不支持ShowFont属性和方法”

 

问题的原因分析:

      应该是IE无法正确载入相应的ActiveX控件引起的。几种情况

1、客户电脑上没有注册好  ComDlg32.ocx

     解决方法:

  对于32位Windows: 把 ComDlg32.ocx 拷贝到 C:\windows\system32 目录下;

      对于64位Windows: 把 ComDlg32.ocx 拷贝到 C:\windows\sysWOW64 目录下;

  使用管理员身份,运行  regsvr32 C:\windows\system32\ComDlg32.ocx

2、HTML中没有按微软的要求编写ActiveX 的引用声明

   如果缺少以下代码,也会出现之上的问题

   <object classid="clsid:5220cb21-c88d-11cf-b347-00aa00a28331">
         <param name="LPKPath" value="comdlg.lpk">
   </object> 

      解决方法:加入相应的声明

 3、因为安全原因,IE 禁止了相关 ActiveX控件的使用

    解决方法:使用regedit, 对于comdlg32.ocx 相应的注册项是 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility{F9043C85-F6F2-101A-A3C9-08002B2F49FB},找到并删除它。

  

参考链接:

http://stackoverflow.com/questions/1146872/comdlg32-ocx-error-object-doesnt-support-this-property-or-method

http://stackoverflow.com/questions/5705138/internet-explorer-9-ie9-hangs-after-closing-activex-form-e-g-common-dialog-c

https://support.microsoft.com/zh-cn/help/240797/how-to-stop-an-activex-control-from-running-in-internet-explorer
https://answers.microsoft.com/en-us/ie/forum/ie9-windows_7/ie9-internet-explorer-window-becomes-disabled-when/7bd351e9-c94f-e011-8dfc-68b599b31bf5

 

 

 


测试代码:http://files.cnblogs.com/files/finema/ComDlgTest.rar

转载于:https://www.cnblogs.com/finema/p/6741744.html

要实现WindTerm中rz命令弹出文件选择框的功能,需要使用go语言编写一个WinAPI程序,并在WindTerm中调用它。以下是基本的代码示例: ```go package main import ( "fmt" "syscall" "unsafe" ) var ( comdlg32 = syscall.NewLazyDLL("comdlg32.dll") getOpenFileName = comdlg32.NewProc("GetOpenFileNameW") getSaveFileName = comdlg32.NewProc("GetSaveFileNameW") ole32 = syscall.NewLazyDLL("ole32.dll") coTaskMemFree = ole32.NewProc("CoTaskMemFree") shell32 = syscall.NewLazyDLL("shell32.dll") dragQueryFileW = shell32.NewProc("DragQueryFileW") dragFinish = shell32.NewProc("DragFinish") shellExecuteExW = shell32.NewProc("ShellExecuteExW") shellNotifyIconW = shell32.NewProc("Shell_NotifyIconW") shellGetImageLists = shell32.NewProc("SHGetImageList") user32 = syscall.NewLazyDLL("user32.dll") sendMessageW = user32.NewProc("SendMessageW") postMessageW = user32.NewProc("PostMessageW") ) type openfilename struct { structSize uint32 hwndOwner uintptr hInstance uintptr filter *uint16 customFilter *uint16 maxCustomFilter uint32 filterIndex uint32 file *uint16 maxFile uint32 fileTitle *uint16 maxFileTitle uint32 initialDir *uint16 title *uint16 flags uint32 fileOffset uint16 fileExtension uint16 defExt *uint16 custData uintptr hook uintptr templateName *uint16 reserved uintptr flagsEx uint32 } func rzFileDialog() (string, error) { var ofn openfilename ofn.structSize = uint32(unsafe.Sizeof(ofn)) ofn.flags |= 0x00080000 | 0x00001000 | 0x00000800 | 0x00000200 // OFN_EXPLORER | OFN_NOCHANGEDIR | OFN_ALLOWMULTISELECT | OFN_PATHMUSTEXIST ofn.filter = syscall.StringToUTF16Ptr("All Files (*.*)\x00*.*\x00\x00") ofn.file = syscall.StringToUTF16Ptr(string(make([]uint16, 8192))) ofn.maxFile = uint32(len([]uint16(*ofn.file))) ofn.fileTitle = syscall.StringToUTF16Ptr(string(make([]uint16, 8192))) ofn.maxFileTitle = uint32(len([]uint16(*ofn.fileTitle))) ret, _, _ := getOpenFileName.Call(uintptr(unsafe.Pointer(&ofn))) if ret == 0 { return "", syscall.GetLastError() } defer coTaskMemFree.Call(uintptr(unsafe.Pointer(ofn.file))) defer coTaskMemFree.Call(uintptr(unsafe.Pointer(ofn.fileTitle))) return syscall.UTF16ToString((*[8192]uint16)(unsafe.Pointer(ofn.file))[:]), nil } func main() { file, err := rzFileDialog() if err != nil { fmt.Println("Error:", err) return } fmt.Println("Selected file:", file) } ``` 在WindTerm中,可以使用以下命令来调用此程序: ``` rz | go run filedialog.go ``` 这将在WindTerm中启动rz命令,并弹出文件选择框。选择文件后,程序将在WindTerm中输出所选文件的路径。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值