象外行一样思考,象专家一样实践。
coolbean | 23 九月, 2007 07:19
放弃自我辩护
你见过黑客吗?你想象中的黑客是什么模样?白永春就是一名黑客,云南大学本科毕业,曾在昆明一家科技公司工作。
被告席上,白永春看起来有点木讷。回答审判长提问的时候,他的右手不停地摩挲左手臂,云南玉溪口音浓重,不少音节略过,让他的话时而清晰时而含糊。不过,法庭上,他很配合,承认了所有指控;审判长问他是否需要自我辩护,他说不要。
但就是他,不到一个月就攻破了六七家网站,随时窥视十五六台电脑的操作者的一举一动。“这让我很有成就感,在我们黑客看来,侵入网站、操控多个服务器才算有成就。”在笔录里,白永春这样说。
下载黑客软件
白永春说,母亲生病,女朋友也生病,自己月薪虽有2000多元,但还不够给她们治病,于是想上网偷盗来钱会比较快。
“如果自己编写一套木马程序,差不多要1年多,从网上下载就方便多了。”白永春说,今年初,他上了一个黑客网站,正有人在发帖推荐木马程序的网址,他赶紧跟帖,没过多久就下载了“灰鸽子2006vip破解版”等黑客软件。然后,他用这些软件攻击了六七家网站。被害人蔡先生浏览了被攻击的网页后,电脑就自动植入了“灰鸽子”等黑客程序。
“十五六台电脑都中了木马
病毒,那些人在电脑上做些什么,我随时能看到。有一天,我看见被害人蔡先生的个人账户里竟有19万元,就打算偷了。”此后,白永春远程控制了蔡先生网上银行的账号、密码,以及电子认证证书。
冒名转账取钱
白永春在人才市场捡到一份“郭荣华”的个人简历资料,靠街头黑广告牵线搭桥,制作了一张假身份证,到银行为“郭荣华”开设账户。然后,他又回到网络世界,用被害人蔡先生的网上银行信息登录后,转账十多次,一共偷盗了16万元,再用“郭荣华”的身份去银行取钱。
前天的庭审很简短,审判长宣布择日宣判。时常行走在现实与虚拟之间的黑客白永春,驾御一套木马程序,跨过了守法的底线,面临着一段牢狱生涯。
coolbean | 19 九月, 2007 18:09
目前人们逐渐认识了磁盘阵列技术。磁盘阵列技术可以详细地划分为若干个级别0-5 RAID技术,并且又发展了所谓的 RAID Level 10, 30, 50的新的级别。RAID是廉价冗余磁盘阵列(Redundant Array of Inexpensive Disk)的简称。用RAID的好处简单的说就是:安全性高,速度快,数据容量超大。
某些级别的RAID技术可以把速度提高到单个硬盘驱动器的400%。磁盘阵列把多个硬盘驱动器连接在一起协同工作,大大提高了速度,同时把硬盘系统的可靠性提高到接近无错的境界。这些“容错”系统速度极快,同时可靠性极高。
coolbean | 18 九月, 2007 17:11
coolbean | 18 九月, 2007 17:07
coolbean | 18 九月, 2007 17:05
coolbean | 17 九月, 2007 13:13

日前,有部分全国政协委员曾经提议:鉴于联合国教科文组织的世界教师节、美国、中国台湾和香港的教师节,都是统一在孔子诞辰日(9月28日),建议国家教育部也应该把这一天与台湾、香港统一定为“中国教师节”。其理由:从文化、教育的角度来分析,以往所定的中国教师节(9月10日)尚未确定与我国的历史文化有任何渊源关系?我认为这一提议非常好,值得投赞成票!
coolbean | 17 九月, 2007 12:18
coolbean | 13 九月, 2007 17:40
使用Visual Basic 6实现真正实用的多线程处理
事实上使用Visual Basic的ActiveX exe技术可以轻松的实现多线程处理.
原理先不说了,先举个示例,有兴趣的话大家可以一起讨论
1.新建一个工程,类型选择ActiveX Exe,工程重命名为TestExe
在工程中添加一个Form,放上一个Timer控件.
将Class1改名为clsTest,注意其Instancing要设置为5-MultiUse, 以下是其代码:
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private WithEvents oTimer As Timer
Private frmTmp As Form1
Private lTotalLoop As Long
Private bDoStop As Boolean
Private lInterval As Long
Public Event Progress(ByVal lProgress As Long)
Public Sub StartSub(ByVal lTotal As Long)
lTotalLoop = lTotal
oTimer.Enabled = True
End Sub
Public Sub StopSub()
bDoStop = True
End Sub
Private Sub Class_Initialize()
Set frmTmp = New Form1
Load frmTmp
Set oTimer = frmTmp.Timer1
oTimer.Enabled = False
bDoStop = False
lInterval = 1
End Sub
Private Sub DoLoop()
Dim i As Long
For i = 0 To lTotalLoop
Sleep (lInterval)
RaiseEvent Progress(i)
If bDoStop = True Then
Exit Sub
End If
Next
End Sub
Private Sub Class_Terminate()
Unload frmTmp
Set frmTmp = Nothing
Set oTimer = Nothing
End Sub
Private Sub oTimer_Timer()
oTimer.Enabled = False
DoLoop
End Sub
Public Property Get lMillisecs() As Long
lMillisecs = lInterval
End Property
Public Property Let lMillisecs(ByVal vNewValue As Long)
lInterval = vNewValue
End Property
在TestExe Property(工程属性)的Threading Model中,设置Thread per Object,或者选择Thread pool中设置大于1的数值.如把Thread pool设置为2, 则调用此ActiveX Exe最多能同时有两个线程, 更多的请求将放置于队列中.
编译TestExe
下面来测试我们的多线程程序:
coolbean | 10 九月, 2007 02:16
This tip shows you how to show and hide the title bar of a window at run-time. To make a window's title bar disappear, you have to remove the control box, the maximise box and the minimise box as well as set the caption of the form to blank. Unfortunately, VB's ControlBox, MinButton and MaxButton properties of a form are read-only so you can normally only do this at design time. However, by manipulating the style of the window using API calls, you can get the same thing to happen at run-time.
Start a new project in VB. Add the following code to the project's form:
Private Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000 ' WS_BORDER Or WS_DLGFRAME
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000
Private Declare Function SetWindowPos Lib "user32" _
(ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
ByVal x As Long, ByVal y As Long, _
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Enum ESetWindowPosStyles
SWP_SHOWWINDOW = &H40
SWP_HIDEWINDOW = &H80
SWP_FRAMECHANGED = &H20 ' The frame changed: send WM_NCCALCSIZE
SWP_NOACTIVATE = &H10
SWP_NOCOPYBITS = &H100
SWP_NOMOVE = &H2
SWP_NOOWNERZORDER = &H200 ' Don't do owner Z ordering
SWP_NOREDRAW = &H8
SWP_NOREPOSITION = SWP_NOOWNERZORDER
SWP_NOSIZE = &H1
SWP_NOZORDER = &H4
SWP_DRAWFRAME = SWP_FRAMECHANGED
HWND_NOTOPMOST = -2
End Enum
Private Declare Function GetWindowRect Lib "user32" ( _
ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Function ShowTitleBar(ByVal bState As Boolean)
Dim lStyle As Long
Dim tR As RECT
' Get the window's position:
GetWindowRect Me.hwnd, tR
' Modify whether title bar will be visible:
lStyle = GetWindowLong(Me.hwnd, GWL_STYLE)
If (bState) Then
Me.Caption = Me.Tag
If Me.ControlBox Then
lStyle = lStyle Or WS_SYSMENU
End If
If Me.MaxButton Then
lStyle = lStyle Or WS_MAXIMIZEBOX
End If
If Me.MinButton Then
lStyle = lStyle Or WS_MINIMIZEBOX
End If
If Me.Caption <> "" Then
lStyle = lStyle Or WS_CAPTION
End If
Else
Me.Tag = Me.Caption
Me.Caption = ""
lStyle = lStyle And Not WS_SYSMENU
lStyle = lStyle And Not WS_MAXIMIZEBOX
lStyle = lStyle And Not WS_MINIMIZEBOX
lStyle = lStyle And Not WS_CAPTION
End If
SetWindowLong Me.hwnd, GWL_STYLE, lStyle
' Ensure the style takes and make the window the
' same size, regardless that the title bar etc
' is now a different size:
SetWindowPos Me.hwnd, _
0, tR.Left, tR.Top, _
tR.Right - tR.Left, tR.Bottom - tR.Top, _
SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED
Me.Refresh
' Ensure that your resize code is fired, as the client area
' has changed:
Form_Resize
End Function
To try out the hiding and showing the title bar, add a CheckBox to the project's form. Set the check box's Value property to 1 (Checked). Then put the following code under the Check box's click event:
Private Sub Check1_Click()
If (Check1.Value = Checked) Then
ShowTitleBar True
Else
ShowTitleBar False
End If
End Sub
When you click on the check box, the form's titlebar will be alternately hidden and shown.
coolbean | 10 九月, 2007 02:11
If you are designing a project which can use an Internet connection, it can be useful to know whether the system is connected or not. There are various methods of doing this, however the most informative and reliable method is to use the WinInet.DLL InternetGetConnectedStateEx API call. The only problem with this call is it is only implemented for the WinInet.DLL version shipped with Internet Explorer version 4.0 or higher.
To test out this function, start a new project and add the following code:
Public Declare Function InternetGetConnectedStateEx Lib "wininet.dll" _
Alias "InternetGetConnectedStateExA" _
(ByRef lpdwFlags As Long, _
ByVal lpszConnectionName As String, _
ByVal dwNameLen As Long, _
ByVal dwReserved As Long _
) As Long
Public Enum EIGCInternetConnectionState
INTERNET_CONNECTION_MODEM = &H1&
INTERNET_CONNECTION_LAN = &H2&
INTERNET_CONNECTION_PROXY = &H4&
INTERNET_RAS_INSTALLED = &H10&
INTERNET_CONNECTION_OFFLINE = &H20&
INTERNET_CONNECTION_CONFIGURED = &H40&
End Enum
Public Property Get InternetConnected( _
Optional ByRef eConnectionInfo As EIGCInternetConnectionState, _
Optional ByRef sConnectionName As String _
) As Boolean
Dim dwFlags As Long
Dim sNameBuf As String
Dim lR As Long
Dim iPos As Long
sNameBuf = String$(513, 0)
lR = InternetGetConnectedStateEx(dwFlags, sNameBuf, 512, 0&)
eConnectionInfo = dwFlags
iPos = InStr(sNameBuf, vbNullChar)
If iPos > 0 Then
sConnectionName = Left$(sNameBuf, iPos - 1)
ElseIf Not sNameBuf = String$(513, 0) Then
sConnectionName = sNameBuf
End If
InternetConnected = (lR = 1)
End Property
To try out the code, add a CommandButton and a Multi-Line TextBox to your test project's main form. Then add the following code to try the function:
Private Sub Command1_Click()
Dim eR As EIGCInternetConnectionState
Dim sMsg As String
Dim sName As String
Dim bConnected As Boolean
' Determine whether we have a connection:
bConnected = InternetConnected(eR, sName)
' The connection state info parameter provides details
' about how we connect:
If (eR And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then
sMsg = sMsg & "Connection uses a modem." & vbCrLf
End If
If (eR And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then
sMsg = sMsg & "Connection uses LAN." & vbCrLf
End If
If (eR And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then
sMsg = sMsg & "Connection is via Proxy." & vbCrLf
End If
If (eR And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE Then
sMsg = sMsg & "Connection is Off-line." & vbCrLf
End If
If (eR And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED Then
sMsg = sMsg & "Connection is Configured." & vbCrLf
Else
sMsg = sMsg & "Connection is Not Configured." & vbCrLf
End If
If (eR And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then
sMsg = sMsg & "System has RAS installed." & vbCrLf
End If
' Display the connection name and info:
If bConnected Then
Text1.Text = "Connected: " & sName & vbCrLf & vbCrLf & sMsg
Else
Text1.Text = "Not Connected: " & sName & vbCrLf & vbCrLf & sMsg
End If
End Sub
Run the project. When you click the command button, the text box will be updated with the status of the current connection, the name of RAS dial-up connection used (if applicable) and also various information about how the connection is being achieved (i.e. by modem or LAN, via a proxy and whether the connection is configured or not).
coolbean | 10 九月, 2007 02:02
Download code:
coolbean | 10 九月, 2007 01:42
Run code asynchronously with this simple and elegant design model
Ever since VB5 service pack 2, there has been the possibility of running VB applications multi-threaded by using ActiveX EXEs. However, if you try and research this you will find it is fiddly to get working. This article presents a method which makes running operations asynchronously really easy.
Although ActiveX EXEs can run in a new thread, I've never really understood how to get it working: you need to use CreateObject to make the object on a new thread, and then you need to be very careful as to how you start the work you want to do asynchronously. Most times you find that VB blocks until the method call is complete regardless of whether the object is in a new thread or not.
What you want to be able to do is to say I want to perform some operation asynchronously and I would like to be notified when it is complete. This project demonstrates a tiny code module and a type library you can add into your own ActiveX projects to do just that. It is based around a part of the MSDN "CodeFlow sample" (see downloads).
The main problem with getting a multi-threaded application up and running is how to call a method in VB without the caller being blocked. It turns out there is a simple solution to this problem. The steps are as follows:
This solves the problem because the method you call immediately yields control back to the caller, and then it is left to Windows pre-emptive multi-tasking to raise the timer event and kick off the process within the ActiveX EXE. There is no further interference because the ActiveX EXE is running in a different process to the caller.
To stop having to have a form in the ActiveX EXE, this solution is based on a Win32 API timer. Win32 API timers come in two flavours: either they notify the application when they tick by posting a WM_TIMER message to a window, or they fire a callback interface. This solution uses the callback interface, and as a consequence must be implemented within a module (because VB will not provide the address of a function to callback to for any function within an object, only one in a module).
Because the code to start the object is implemented in a module, the module must have a reference to the object instance it has to start when the timer fires. To achieve this without the possibility for errors, an interface is defined that the object can implement and the module will only use this for communication. In this sample, the interface is defined in a Type Library called Runnable. This allows you to reference the Type Library without having to declare it as a public class from the ActiveX executable.
The final implementation feature is the use of the OLE/COM API call CoLockObjectExternal to ensure that the object being started asynchronously isn't inadvertently terminated by the caller before the timer has had a chance to be fired.
Here is the code in the mStart.bas module:
coolbean | 05 九月, 2007 23:51
EnableWindow hwnd,0
Note: EnableWindow function sends WM_CANCELMODE to the combobox control.
coolbean | 02 九月, 2007 15:02
coolbean | 02 九月, 2007 15:00
| « | 九月 2010 | » | ||||
|---|---|---|---|---|---|---|
| 一 | 二 | 三 | 四 | 五 | 六 | 日 |
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||