Archive for category 代码

自定义WebBrowser版本

Posted by on 星期六, 1 四月, 2017

当在应用程序中嵌入WebBrowser控件时,会遇到使用系统IE没有问题,而WebBrowser浏览却不正常的现象。
当你在排除了跨域、可信站点、IE设置等问题却依然不正常的时候,例如CSS失效、JS错误;则可能是由于安全原因WebBrowser被限制版本了。

问题描述:http://stackoverflow.com/questions/4612255/will-the-ie9-webbrowser-control-support-all-of-ie9s-features-including-svg/5357168#5357168

可以尝试通过设置Browser Emulation来解决,如下:

原文:https://msdn.microsoft.com/en-us/library/ee330730(VS.85).aspx#browser_emulation

WebBrowser 介绍:https://msdn.microsoft.com/en-us/library/aa752040(v=vs.85).aspx

Browser Emulation

Windows Internet Explorer 8 and later. The FEATURE_BROWSER_EMULATION feature defines the default emulation mode for Internet Explorer and supports the following values.

Value Description
11001 (0x2AF9 Internet Explorer 11. Webpages are displayed in IE11 edge mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks.
11000 (0x2AF8) IE11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 edge mode. Default value for IE11.
10001 (0x2711) Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.
10000 (0x02710) Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.
9999 (0x270F) Windows Internet Explorer 9. Webpages are displayed in IE9 Standards mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks.
9000 (0x2328) Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode. Default value for Internet Explorer 9.

Important  In Internet Explorer 10, Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
8888 (0x22B8) Webpages are displayed in IE8 Standards mode, regardless of the declared !DOCTYPE directive. Failing to declare a !DOCTYPE directive causes the page to load in Quirks.
8000 (0x1F40) Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode. Default value for Internet Explorer 8

Important  In Internet Explorer 10, Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
7000 (0x1B58) Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode. Default value for applications hosting the WebBrowser Control.

 

For more information, see Defining Document Compatibility.

To control the value of this feature by using the registry, add the name of your executable file to the following setting and set the value to match the desired setting.

HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
   SOFTWARE
      Microsoft
         Internet Explorer
            Main
               FeatureControl
                  FEATURE_BROWSER_EMULATION
                     contoso.exe = (DWORD) 00009000


其中contoso.exe为你的应用程序名

			

C语言实现封装、继承和多态

Posted by on 星期二, 14 十月, 2014

作者:Dong | 新浪微博:西成懂 | 可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明
网址:http://dongxicheng.org/cpp/ooc/
本博客的文章集合:http://dongxicheng.org/recommend/


本博客微信公共账号:hadoop123(微信号为:hadoop-123),分享hadoop技术内幕,hadoop最新技术进展,发布hadoop相关职位和求职信息,hadoop技术交流聚会、讲座以及会议等。二维码如下:


1  概述

C语言是一种面向过程的程序设计语言,而C++是在C语言基础上衍生来了的面向对象的语言,实际上,很多C++实现的底层是用C语言实现的,如在Visual C++中的Interface其实就是struct,查找Interface的定义,你可以发现有这样的宏定义:

#ifndef Interface

#define Interface struct

#endif

C++在语言级别上添加了很多新机制(继承,多态等),而在C语言中,我们也可以使用这样的机制,前提是我们不得不自己实现。

本文介绍了用C语言实现封装,继承和多态的方法。

Read the rest of this entry »

VB管道操作

Posted by on 星期四, 7 四月, 2011

Visual Basic的管道操作,用于与控制台程序、DOS命令等命令行接口的程序通信,能清楚地知道命令执行情况。

源码下载:>>本地下载<<

VB枚举系统网卡代码

Posted by on 星期一, 28 三月, 2011

  通过枚举系统网卡,获得网卡名称,如果包含”TAP-Win32 Adapter”则说明找到OpenVPN的虚拟网卡。部分代码如下:

Public Function CheckTapDrive() As Long
Dim AdapterInfoSize As Long
Dim AdapterInfo As IP_ADAPTER_INFO
Dim AdapterInfoBuffer() As Byte
Dim ptr1 As Long
On Error GoTo CheckFailed
AdapterInfoSize = 0
Call GetAdaptersInfo(ByVal 0&, AdapterInfoSize)
ReDim AdapterInfoBuffer(AdapterInfoSize - 1)
If 0 = GetAdaptersInfo(AdapterInfoBuffer(0), AdapterInfoSize) Then
ptr1 = VarPtr(AdapterInfoBuffer(0))
Do While (ptr1 <> 0)
CopyMemory AdapterInfo, ByVal ptr1, IP_ADAPTER_INFO_LENGTH

If InStr(AdapterInfo.Description, "TAP-Win32 Adapter") <> 0 Then '此处即是如果找到OpenVPN的TAP虚拟网卡
CheckTapDrive = 1
Exit Function
End If
ptr1 = AdapterInfo.Next
Loop
End If
Exit Function
CheckFailed:
CheckTapDrive = -1
End Function

  完整代码下载:http://www.awolf.net/downloads/enum-network-adapter.zip

WolfLAN源码和简单原理介绍

Posted by on 星期一, 28 三月, 2011

>>WolfLAN源码下载<<


  在登录时等待OpenVPN返回“Enter Auth Username”和“Enter Auth Password”,然后将帐号密码送入管道。之后读取管道,根据OpenVPN输出来判断当前状态。


登录代码:


PipeClosed = False
txtLog.Text = Now & vbCrLf
Set OvpnPipe = New ClsPipe
OvpnPipe.ConsoleShell = strAppPath & "openvpn.exe --config " & Chr(34) & strAppPath & "Wolf.ovpn" & Chr(34) '以指定参数在管道中运行OpenVPN
OvpnPipe.Silent = True
OvpnPipe.CreateConsolePipe
tmrLog.Enabled = True
'等待输入用户名并发送用户名===================
Do While InStr(1, txtLog.Text, "Enter Auth Username:") = 0
DoEvents
Loop
lbMsg.ToolTipText = "验证用户名和密码"
OvpnPipe.WriteToPipe txtUserName.Text
'===========================================
'等待输入密码并发送密码======================
Do While InStr(1, txtLog.Text, "Enter Auth Password:") = 0
DoEvents
Loop
OvpnPipe.WriteToPipe txtPassword.Text


状态判断:


If InStr(1, txtLog.Text, "TUN/TAP interface has been stopped") <> 0 Then
ConnectError
lbMsg.Caption = "- 网卡已停止"
Exit Sub
End If
DoEvents
If InStr(1, txtLog.Text, "process exiting") <> 0 Then
ConnectError
lbMsg.Caption = "- 进程终止"
Exit Sub
End If
DoEvents
If InStr(1, txtLog.Text, "Closing TUN/TAP interface") <> 0 Then
ConnectError
lbMsg.Caption = "- 网卡关闭"
Exit Sub
End If
DoEvents
If InStr(1, txtLog.Text, "There are no TAP-Win32 adapters on this system.") <> 0 Then
ConnectError
lbMsg.Caption = "- 未找到Tap网卡"
Exit Sub
End If
DoEvents
If InStr(1, txtLog.Text, "All TAP-Win32 adapters on this system are currently in use.") <> 0 Then
ConnectError
lbMsg.Caption = "- 网卡被占用"
Exit Sub
End If
DoEvents
If (InStr(1, txtLog.Text, "TCP/UDP: Closing socket") <> 0) And (InStr(1, txtLog.Text, "Restart pause, 5 second(s)") <> 0) Then
ConnectError
lbMsg.Caption = "- 错误:Closing socket"
Exit Sub
End If
DoEvents
If InStr(1, txtLog.Text, "Exiting") <> 0 Then
ConnectError
lbMsg.Caption = "- 主动断开"
Exit Sub
End If
DoEvents
If (InStr(1, txtLog.Text, "VERIFY OK") <> 0) And (InStr(1, txtLog.Text, "--dhcp-option") = 0) Then lbMsg.ToolTipText = "建立通道"
If (InStr(1, txtLog.Text, "--dhcp-option") <> 0) And (InStr(1, txtLog.Text, "Initialization Sequence Completed") = 0) Then lbMsg.ToolTipText = "获取IP"
If (InStr(1, txtLog.Text, "Initialization Sequence Completed") <> 0) And (InStr(1, txtLog.Text, "With Errors") = 0) Then
If chkRoute.Value = 1 Then
lbMsg.ToolTipText = "设置借线"
OvpnPipe.Wait (2000)
WaitRun "route", "add 0.0.0.0 mask 0.0.0.0 192.168.27.254"
End If
lbMsg.Caption = "+ 链接成功"
SocketsInitialize
tmrStatus.Enabled = False
cmdLogin.Enabled = True
cmdLogin.Caption = "&D.断开"
PopInfo
Exit Sub
End If
DoEvents
If InStr(1, txtLog.Text, "Initialization Sequence Completed With Errors") <> 0 Then
ConnectError
lbMsg.Caption = "- Errors"
Exit Sub
End If
DoEvents