Здесь все вопросы по Visual Basic.
Функция:
Function base64encode(sData As String)
Const base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456 789+/"
Dim lBlock As Long
Dim iCount As Integer
Dim iLen As Integer
Dim sTail As String
Dim sEncode As String
iLen = Len(sData)
iCount = 1
Do While iCount <= iLen
lBlock = Asc(Mid(sData, iCount, 1)) * 65536
iCount = iCount + 1
If iCount <= iLen Then
lBlock = lBlock + Asc(Mid(sData, iCount, 1)) * 256
iCount = iCount + 1
If iCount <= iLen Then
lBlock = lBlock + Asc(Mid(sData, iCount, 1))
iCount = iCount + 1
sTail = ""
Else
sTail = "="
End If
Else
sTail = "=="
End If
sEncode = sEncode + Mid(base64, (lBlock And &HFC0000) / 262144 + 1, 1)
sEncode = sEncode + Mid(base64, (lBlock And &H3F000) / 4096 + 1, 1)
If sTail <> "==" Then
sEncode = sEncode + Mid(base64, (lBlock And &HFC0) / 64 + 1, 1)
If sTail <> "=" Then sEncode = sEncode + Mid(base64, (lBlock And &H3F) + 1, 1)
End If
sEncode = sEncode + sTail
Loop
base64encode = sEncode
End Function
Пользоваться:
debug.print base64encode("text")
[quote пишет:
Проверить существует ли файл
Функция:
Public Function FileExist(filename As String) As Boolean
FileExist = Dir$(filename) <> ""
End Function
Пользоваться:
If FileExist(Путь до файла) Then
Получить текущий url в IE
Dim Shell1, ShellWindows, IE, url As String
Set Shell1 = CreateObject("Shell.Application")
Set ShellWindows = Shell1.Windows
Set IE = CreateObject("InternetExplorer.Application")
For Each IE In ShellWindows
If LCase(TypeName(IE.document)) = "htmldocument" Then url = url & IE.LocationURL & vbCr
Next
If Len(url) Then MsgBox url Else MsgBox "Nothing found"
Set Shell1 = Nothing
Set ShellWindows = Nothing
Set IE = Nothing
Листинг файлов
Dim st As String
st = Dir("c:\", vbDirectory Or vbNormal)
Do While Len(st)
If st <> "." And st <> ".." Then
List1.AddItem st
End If
st = Dir
Loop
Запрет запуска TaskManager
Option Explicit
Private Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" (ByVal dwExStyle As Long, lpClassName As Any, ByVal lpWindowName As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long
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 DefDlgProc Lib "user32" Alias "DefDlgProcA" (ByVal hDlg As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const GWL_WNDPROC = (-4)
Sub Main()
SetWindowLong CreateWindowEx(0, ByVal 32770, "Диспетчер задач Windows", 0, 0, 0, 0, 0, 0, 0, 0, ByVal 0&), GWL_WNDPROC, AddressOf MyDlgProc
End Sub
Private Function MyDlgProc(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If wMsg = &H40B Then
MyDlgProc = wMsg
Else
MyDlgProc = DefDlgProc(hWnd, wMsg, wParam, lParam)
End If
End Function
Тема конечно полезная, но для форума по данной тематике.