Tuesday, July 21, 2020
Declare API
Private Declare Function InternetGetConnectedState Lib "wininet" (ByRef dwflags As Long, _
ByVal dwReserved As Long) As Long
Private Const CONNECT_LAN As Long = &H2
Private Const CONNECT_MODEM As Long = &H1
Private Const CONNECT_PROXY As Long = &H4
Private Const CONNECT_OFFLINE As Long = &H20
Private Const CONNECT_CONFIGURED As Long = &H40
Function:
Public Function IsWebConnected(Optional ByRef ConnType As String) As Boolean
Dim dwflags As Long
Dim WebTest As Boolean
ConnType = ""
WebTest = InternetGetConnectedState(dwflags, 0&)
Select Case WebTest
Case dwflags And CONNECT_LAN: ConnType = "LAN"
Case dwflags And CONNECT_MODEM: ConnType = "Modem"
Case dwflags And CONNECT_PROXY: ConnType = "Proxy"
Case dwflags And CONNECT_OFFLINE: ConnType = "Offline"
Case dwflags And CONNECT_CONFIGURED: ConnType = "Configured"
Case dwflags And CONNECT_RAS: ConnType = "Remote"
End Select
IsWebConnected = WebTest
End Function
Private Sub Command1_Click()
Dim msg As String
If IsWebConnected(msg) Then
msg = "You are connected to the Internet via: " & msg
Else
msg = "You are not connected to the Internet."
End If
MsgBox msg, vbOKOnly, "Internet Connection Status"
End Sub
[Read more…]
Thursday, June 18, 2020
Public Function ShellZip(ByRef Source As String, ByRef DestZip As String) As Boolean
CreateNewZip DestZip
On Error Resume Next
With CreateObject("Shell.Application") 'Late-bound
'With New Shell 'Referenced
If Right$(Source, 1&) = "" Then
.NameSpace(CVar(DestZip)).CopyHere .NameSpace(CVar(Source)).Items
Else
.NameSpace(CVar(DestZip)).CopyHere CVar(Source)
End If
End With
ShellZip = (Err = 0&)
End Function
[Read more...]
Declare:
Private InitDone As Boolean
Private Map1(0 To 63) As Byte
Private Map2(0 To 127) As Byte
Function:
[Read more…]
API:
Private Declare Function NtQueryInformationProcess Lib "NTDLL.DLL" (ByVal hProcess As Long, ByVal ProcessInformationClass As Long, ProcessInformation As Any, ByVal ProcessInformationLength As Long, ReturnLength As Long) As Long
Function:
Public Function ImBeingDebugged() As Boolean
Call NtQueryInformationProcess(-1, &H1E, ImBeingDebugged, ByVal 4, ByVal 0&)
End Function
API Declare:
Private Declare Function NtSetInformationThread Lib "NTDLL" (ByVal hThread As Integer, ByVal ThreadInformationClass As Integer, ByVal ThreadInformation As Integer, ByVal ThreadInformationLength As Integer) As Integer
Private Declare Function NtWriteVirtualMemory Lib "NTDLL" (ByVal ProcessHandle As Long, ByVal BaseAddress As Long, ByVal pBuffer As Long, ByVal NumberOfBytesToWrite As Long, ByRef NumberOfBytesWritten As Long) As Long
Private Declare Function CallWindowProcA Lib "USER32" (ByVal address As Any, Optional ByVal Param1 As Long, Optional ByVal Param2 As Long, Optional ByVal Param3 As Long, Optional ByVal Param4 As Long) As Long
[Read more…]
Friday, September 22, 2017
ສຳລັບບົດນີ້ ເປັນການສ້າງໂປຣແກຣມ ໃຫ້ເປີດເອງຕອນເວລາເປີດຄອມ
ມີໂຄ້ດດັ່ງນີ້
ແບບທີ່ 1
Dim Startup_key As String
Startup_key = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run"
Dim Reg As Object
Set Reg = CreateObject("wscript.shell")
Reg.RegWrite Startup_key & App.EXEName, App.Path & "" & App.EXEName & ".exe"
ສຳລັບ
- App.EXEName ແມ່ນມີຄ່າເທົ່າຊື່ຂອງໂປຣແກຣມເຮົາເອງ
- App.Path ແມ່ນ ເສັ້ນທາງທີ່ໂປຣແກຣມເຮົາເປີດຢູ່
ແບບທີ່ 2
[Read more…]
ໃນບົດນີ້ ແມ່ນການຂຽນໂປຣແກຣມໃຫ້ດາວໂຫຼດໄຟລ ຈາກອິນເຕີເນັດ
ຕົວຢ່າງ 1
ເປັນ Function ສຳລັບດາວໂຫຼດໄຟລ
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000
Public Function DownloadFile(sSourceUrl As String, _
sLocalFile As String) As Boolean
//'Download the file. BINDF_GETNEWESTVERSION forces
//'the API to download from the specified source.
//'Passing 0& as dwReserved causes the locally-cached
//'copy to be downloaded, if available. If the API
//'returns ERROR_SUCCESS (0), DownloadFile returns True.
DownloadFile = URLDownloadToFile(0&, _
sSourceUrl, _
sLocalFile, _
BINDF_GETNEWESTVERSION, _
0&) = ERROR_SUCCESS
End Function
ຕົວຢ່າງ 2
[Read more…]