by Written by (FULL CREDITS) Karthikeyan, compiled by DiskJunky (1 Submission)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Fri 15th December 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This Includes ALL of Karthikeyans API Code into module-type procedures.
API Declarations
'got to Karthikeyan for writing all these procedures and
'functions.
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function SetComputerName Lib "kernel32" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Long, ByVal lpBuffer As String) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Sub SHAddToRecentDocs Lib "shell32.dll" (ByVal uFlags As Long, ByVal pv As Any)
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long)
Private Declare Function SwapMouseButton Lib "user32" (ByVal bSwap As Long) As Long
Private Declare Function WNetConnectionDialog Lib "mpr.dll" (ByVal hwnd As Long, ByVal dwType As Long) As Long
Private Declare Function WNetDisconnectDialog Lib "mpr.dll" (ByVal hwnd As Long, ByVal dwType As Long) As Long
Private Declare Function ShellAbout Lib "shell32.dll" Alias "ShellAboutA" (ByVal hWnd As Long, ByVal szApp As String, ByVal szOtherStuff As String, ByVal hIcon As Long) As Long
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function CopyFile Lib "kernel32.dll" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
Private Declare Function MoveFile Lib "kernel32.dll" Alias "MoveFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String) As Long
Private Const SHARD_PIDL = 1
Private Const SHARD_PATH = 2
Private Const Show = 1
Private Const Hide = 0
Private Const Swap = 1
Private Const Normal = 0
Private Const NetDialogue = 1
Private Const LPTDialogue = 2
Dim retval As Long ' return value
retval = MoveFile(Source, Destination)
If retval = 0 Then
' "File not found"
Else
' "File Move successful"
End If
End
end sub
public sub CopyTo(Source as string, Destination as String)
Dim retval As Long ' return value
' copy the file
retval = CopyFile(Source ,Distination, 1)
if retval = 0 then
'error: file exists
else
'copy successfull
end if
end sub
public function GetNetworkUserName() as string
Dim b As String * 128
WNetGetUser "", b, 128
GetNetworkUserName = b
end function
public Function GetLoggedInUserName() as string
Dim cn As String
dim Name as String
Dim ls As Long
Dim res As Long
cn = String(1024, 0)
ls = 1024
res = GetUserName(cn, ls)
If res <> 0 Then
name = Mid(cn, 1, InStr(cn, Chr(0)) - 1)
Else
name = ""
End If
GetLoggedInUserName = Name
end function
public Sub ShowAbout(MyForm as Form, Name as string, Message as string)
ShellAbout myform.hWnd, Name, Message, myform.hIcon
End sub
public sub ShowDisConnectLPT(MyForm as Form)
'Disconnect LPT Port
xyz = WNetDisconnectDialog(MyForm.hwnd, LPTDialogue)
end sub
public sub ShowConnectLPT(MyForm as Form)
'Connect LPT Port
xyz = WNetConnectionDialog(MyForm.hwnd, LPTDialogue)
end sub
public sub ShowDisConnectNetDrive(MyForm as Form)
xyz = WNetDisconnectDialog(MyForm.hwnd, NetDialogue)
end sub
public sub ShowConnectNetDrive(MyForm as Form)
'Connect Network Drive
xyz = WNetConnectionDialog(MyForm.hwnd, NetDialogue)
end sub
public sub NormalMouse()
SwapMouseButton (normal)
end sub
public sub SwapButtons()
SwapMouseButton (swap)
end sub
public Sub HideCur()
showcuror (Hide)
end sub
public Sub ShowCur()
showcuror (show)
end sub
public sub AddToRecentDocs(FileName as string)
'FileName should provide the COMPLETE path. - DiskJunky
SHAddToRecentDocs SHARD_PATH, FileName
end sub
public sub ClearRecentDocs()
'Don't know waht value Nodocs is - DiskJunky
SHAddToRecentDocs 0, Nodocs
End Sub
public function GetWinFolder() as String
Dim a As String * 256
GetWindowsDirectory a, 256
GetWinFolder = Left(a, InStr(a, Chr(0)) - 1)
End Function
public function GetTempFolder() as string
Dim a As String * 256
GetTempPath 256, a
GetTempFolder = Left(a, InStr(a, Chr(0)) - 1)
end function
public function GetSysFolder() as String
Dim a As String * 256
GetSystemDirectory a, 256
GetSysFolder = Left(a, InStr(a, Chr(0)) - 1)
End function
public Function GetCompName() as string
Dim a As String * 256
x = GetComputerName(a, 256)
GetCompName = Left(a, InStr(a, Chr(0)) - 1)
end function
public sub SetCompName(Name as string)
SetComputerName Name
end sub
No comments have been posted about This Includes ALL of Karthikeyans API Code into module-type procedures.. Why not be the first to post a comment about This Includes ALL of Karthikeyans API Code into module-type procedures..