-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.frm
433 lines (416 loc) · 14.3 KB
/
Main.frm
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
VERSION 5.00
Begin VB.Form Main
Appearance = 0 '平面
BackColor = &H80000005&
BorderStyle = 1 '單線固定
Caption = "DiskHider"
ClientHeight = 2460
ClientLeft = 14040
ClientTop = 2925
ClientWidth = 4935
Icon = "Main.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2460
ScaleWidth = 4935
StartUpPosition = 2 '螢幕中央
Begin VB.Frame Frame4
Appearance = 0 '平面
BackColor = &H80000005&
Caption = "關於"
ForeColor = &H80000008&
Height = 735
Left = 2160
TabIndex = 11
Top = 1680
Width = 2655
Begin VB.CommandButton Command3
Caption = "關於(&A)"
Height = 375
Left = 120
TabIndex = 12
Top = 240
Width = 2415
End
End
Begin VB.TextBox TxtTempForLog
Appearance = 0 '平面
Height = 270
Left = 4080
TabIndex = 10
Text = "Text2"
Top = 0
Visible = 0 'False
Width = 255
End
Begin VB.Frame Frame3
Appearance = 0 '平面
BackColor = &H80000005&
Caption = "磁碟機創建狀態(&I)"
ForeColor = &H80000008&
Height = 615
Left = 2160
TabIndex = 8
Top = 960
Width = 2655
Begin VB.Label DiskInfo
Alignment = 2 '置中對齊
Appearance = 0 '平面
BackColor = &H80000005&
BorderStyle = 1 '單線固定
Caption = "無法查詢"
ForeColor = &H80000008&
Height = 285
Left = 120
TabIndex = 9
ToolTipText = "點擊以重新載入"
Top = 240
Width = 2415
End
End
Begin VB.TextBox TextForCheckSpace
Appearance = 0 '平面
Height = 270
Left = 4320
TabIndex = 7
Text = "Text2"
Top = 0
Visible = 0 'False
Width = 255
End
Begin VB.Frame Frame2
Appearance = 0 '平面
BackColor = &H80000005&
Caption = "解密(&E)"
ForeColor = &H80000008&
Height = 735
Left = 120
TabIndex = 2
Top = 120
Width = 4695
Begin VB.CommandButton Command1
Caption = "解密(&R)"
Height = 375
Left = 3720
TabIndex = 4
Top = 240
Width = 855
End
Begin VB.TextBox Text1
Appearance = 0 '平面
BeginProperty Font
Name = "YaHei Consolas Hybrid"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
IMEMode = 3 '暫止
Left = 1200
PasswordChar = "?"
TabIndex = 3
Top = 240
Width = 2415
End
Begin VB.Label Label1
Appearance = 0 '平面
BackColor = &H80000005&
Caption = "密碼(&P):"
ForeColor = &H80000008&
Height = 255
Left = 120
TabIndex = 5
ToolTipText = "此處需輸入密碼而非產生時的密鑰!"
Top = 240
Width = 975
End
End
Begin VB.Frame Frame1
Appearance = 0 '平面
BackColor = &H80000005&
Caption = "其他動作(&D)"
ForeColor = &H80000008&
Height = 1455
Left = 120
TabIndex = 0
Top = 960
Width = 1935
Begin VB.CommandButton Command2
Caption = "修改密碼(&C)"
Height = 495
Left = 120
TabIndex = 6
Top = 840
Width = 1695
End
Begin VB.CommandButton MkPwdTxt
Caption = "產生新磁碟機(&P)"
Height = 495
Left = 120
TabIndex = 1
ToolTipText = "產生帶密碼的磁碟機"
Top = 240
Width = 1695
End
End
Begin VB.Menu key
Caption = "密鑰(&K)"
Begin VB.Menu MakeKey
Caption = "產生密鑰(&M)"
Shortcut = ^M
End
Begin VB.Menu ChangePWD
Caption = "更改密碼(&C)"
End
Begin VB.Menu dash
Caption = "-"
End
Begin VB.Menu Return
Caption = "重新讀取密鑰(&R)"
Shortcut = {F5}
End
Begin VB.Menu ForgotPWD
Caption = "忘記密碼(&F)"
Shortcut = ^F
End
End
Begin VB.Menu Helper
Caption = "說明(&H)"
Begin VB.Menu LogFile
Caption = "Log記錄檔(&L)"
End
Begin VB.Menu dash1
Caption = "-"
End
Begin VB.Menu About
Caption = "關於(&A)"
Shortcut = {F1}
End
End
End
Attribute VB_Name = "Main"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim fso As FileSystemObject
Dim UserPWD As String
Option Explicit
Dim ExtractInfo As Boolean
Dim MainWidthAndHeight(1) As Long
Dim pwdIsNA As Boolean
'
' _oo0oo_
' o8888888o
' 88" . "88
' (| -_- |)
' 0\ = /0
' ___/`---'\___
' .' \\| |// '.
' / \\||| : |||// \
' / _||||| -:- |||||- \
' | | \\\ - /// | |
' | \_| ''\---/'' |_/ |
' \ .-\__ '-' ___/-. /
' ___'. .' /--.--\ `. .'___
' ."" '< `.___\_<|>_/___.' >' "".
' | | : `- \`.;`\ _ /`;.`/ - ` : | |
' \ \ `_. \_ __\ /__ _/ .-` / /
' =====`-.____`.___ \_____/___.-`___.-'=====
' `=---='
'
'
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'
' 佛祖保佑 永不當機 永無BUG
'
' 佛曰:
' 寫字樓里寫字間,寫字間里程式員;
' 程式人員寫程式,又拿程式換酒錢。
' 酒醒只在網上坐,酒醉還來網下眠;
' 酒醉酒醒日復日,網上網下年復年。
' 但願老死電腦間,不願鞠躬老闆前;
' 奔馳寶馬貴者趣,公交自行程式員。
' 別人笑我忒瘋癲,我笑自己命太賤;
' 不見滿街漂亮妹,哪個歸得程式員?
'
Private Sub About_Click()
frmAbout.Show
End Sub
Private Sub ChangePWD_Click()
If ExtractInfo Then
Dim OldPWD As String
OldPWD = InputBox("輸入舊密碼", "更改密碼")
If OldPWD = UserPWD Then
Dim newPWD, checkNewPWD, userKey
newPWD = InputBox("輸入新密碼", "更改密碼")
checkNewPWD = InputBox("確認新密碼", "更改密碼")
If newPWD = checkNewPWD Then
MsgBox "修改完成!", vbInformation
UserPWD = newPWD
newPWD = ""
checkNewPWD = ""
OldPWD = ""
userKey = AscCodePassWord(UserPWD)
InputBox "複製您更改後的新密碼並貼上至pwd.txt檔案內", "更改密碼", UserPWD
MsgBox "成功產生密鑰!" & vbNewLine & "請將待會跳出的訊息中密鑰的文字粘貼到本軟體根目錄「pwd.txt」中,如此一來," & App.Title _
& "才可以正常存取並解密,並開啟您的密碼。" & vbNewLine & "謝謝。" & vbNewLine & vbNewLine & "備註:如果根目錄下沒有pwd.txt,請自行創建並貼上密鑰。", vbInformation
End If
End If
Else
MsgBox "錯誤!" & vbNewLine & "您尚未解密或建立虛擬磁碟,解密或建立虛擬磁碟後再試試。", vbCritical
End If
End Sub
Function ReadPWD()
Retry:
LogWrite "ReadPWD"
Dim Str1 As String
TextForCheckSpace = ""
Open App.Path + "\pwd.txt" For Input As #1
On Error GoTo fileIsSpace
Line Input #1, Str1
TextForCheckSpace.Text = Str1
If TextForCheckSpace.Text = "" Or TextForCheckSpace.Text = " " Then
MsgBox "文件為空。", vbInformation
pwdIsNA = True
Close #1
Else
On Error GoTo Error
Const ForReading = 1
Dim fid As TextStream
Set fso = CreateObject("Scripting.FileSystemObject")
LogWrite "Dim Vars:" & vbNewLine & "fso As FileSystemObject" & vbNewLine & "fid As TextStream" & vbNewLine & "fso = CreateObject('Scripting.FileSystemObject')"
Set fid = fso.OpenTextFile(App.Path + "\pwd.txt", ForReading)
ReadPWD = fid.ReadLine
fid.Close
Close #1
pwdIsNA = False
End If
DiskInfo.Caption = pwdIsNA
If pwdIsNA Then
DiskInfo.BackColor = QBColor(10)
DiskInfo.ForeColor = QBColor(15)
Else
DiskInfo.BackColor = QBColor(12)
DiskInfo.ForeColor = QBColor(15)
End If
Exit Function
Close #1
Error:
Dim MsgBoxReturnValue
LogWrite "ReadPWD:Not Found pwd.txt", 1
MsgBoxReturnValue = MsgBox("錯誤!無法讀取經ASCII加密後之密碼文本,請先進行密碼文本加密並確定儲存於" + App.Path + "\pwd.txt後再行讀檔", vbCritical + vbAbortRetryIgnore)
Select Case MsgBoxReturnValue
Case vbAbort
End
LogWrite "ReadPWD-Ans:Abort", 1
Case vbRetry
GoTo Retry
LogWrite "ReadPWD-Ans:Retry", 1
Case vbIgnore
LogWrite "ReadPWD-Ans:Ignore", 1
Exit Function
End Select
LogWrite "Exit Select", 1
Exit Function
fileIsSpace:
pwdIsNA = True
LogWrite "Text is Space"
End Function
Private Sub Command1_Click()
'On Error Resume Next
If Not pwdIsNA Then
LogWrite pwdIsNA
If Text1.Text = UserPWD Then
Shell "cmd.exe /c start " & App.Path & "\About.bat", vbNormalFocus
LogWrite "Shell 'cmd.exe /c start ' & app.path & ' \ About.bat ', vbNormalFocus"
MsgBox "完成!", vbInformation
ExtractInfo = True
Else
MsgBox "密碼不正確!", vbCritical
End If
Else
Dim MsgBoxClickVal
MsgBoxClickVal = MsgBox("警告!" & vbNewLine & "尚未建立虛擬磁碟機或密鑰檔已損壞,是否重建立虛擬磁碟機?", vbExclamation + vbYesNoCancel)
Select Case MsgBoxClickVal
Case vbYes
MkPwdTxt_Click
Case Else
Exit Sub
End Select
LogWrite pwdIsNA
End If
End Sub
Private Sub Command2_Click()
ChangePWD_Click
End Sub
Private Sub Command3_Click()
frmAbout.Show
End Sub
Private Sub DiskInfo_Click()
ReadPWD
End Sub
Private Sub ForgotPWD_Click()
Dim RecoverPWD
RecoverPWD = MsgBox("抱歉!" & vbNewLine & "為了資訊安全,我們無法驗證您為虛擬硬碟擁有者,您是否願意刪除虛擬硬碟並重新建立?", vbYesNo + vbExclamation)
LogWrite "'抱歉!' & vbNewLine & '為了資訊安全,我們無法驗證您為虛擬硬碟擁有者,您是否願意刪除虛擬硬碟並重新建立?', vbYesNo + vbExclamation"
Select Case RecoverPWD
Case 7
LogWrite RecoverPWD, 3
Exit Sub
Case Else
LogWrite RecoverPWD, 3
End Select
RecoverPWD = MsgBox("請注意!" & vbNewLine & "重新建立虛擬硬碟後,原硬碟內之資訊將會被移除!" & vbNewLine & "是否要重製硬碟?", vbYesNo + vbExclamation)
Select Case RecoverPWD
Case 7
Exit Sub
Case Else
LogWrite RecoverPWD, 3
End Select
Shell "cmd.exe /c " & "rmdir /S /Q D:\RECYCLED\UDrives", vbNormalFocus
MsgBox "錯誤!" & vbNewLine & "無法重新開始新硬碟,因而未完成動作", vbCritical
End Sub
Private Sub Form_Unload(Cancel As Integer)
End
End Sub
Private Sub LogFile_Click()
Logfrm.Show
End Sub
Private Sub MakeKey_Click()
MkPwdTxt_Click
End Sub
Private Sub MkPwdTxt_Click()
If pwdIsNA Then
frmLogin.Show
Else
MsgBox "錯誤!" & vbNewLine & "此電腦已創建過虛擬磁碟機,禁止重創", vbCritical
End If
End Sub
Private Sub Form_Load()
Me.Show
Logfrm.LogLbl.Text = "[LogWrite List]"
UserPWD = ReadPWD()
If UserPWD = "" Then
UserPWD = "N/A"
End If
LogWrite "ReadPWD=" & UserPWD, 3
UserPWD = ChAscCodePassWord(UserPWD)
Debug.Print UserPWD
ExtractInfo = False
MainWidthAndHeight(0) = Me.Width
MainWidthAndHeight(1) = Me.Height
End Sub
Private Sub Picture1_Click()
Logfrm.LogLbl.Text = "[LogWrite List]"
End Sub
Private Sub Picture2_Click()
TxtSave
End Sub
Private Sub Return_Click()
Form_Load
End Sub