Personal tools
You are here: Home WindowsLib
FrontPage >> MapInfoRoadmap >> MapBasicDevelopment >> Some Useful Windows Calls >>

WindowsLib

Document Actions
last edited 3 years ago by BillThoen


 PROGRAM TITLE AND DESCRIPTION
  WINDOWS.LIB
'  ----------------------------------------------------------------------------------------
        This is a library of commonly used Windows DLL functions.
  ----------------------------------------------------------------------------------------
  Written By Ian Tidy
  Date 8 August 2003
  Revision 1.00.00 - Original Development
  ---------------------------------------
  Date 12 August 2003
  Revision 1.00.01 - Added GetTempPath
'  ---------------------------------------
  Date 21 August 2003
  Revision 1.00.02 - Added GlobalMemoryStatus

******************************************************************************************* INCLUDE STATEMENTS

'******************************************************************************************* 'DEFINE VARIABLES (Constants)

'DEFINE FOR MISCELLANIOUS ---------------------------------------------- DEFINE dNULL Chr$(0) DEFINE MAX_PATH 260 DEFINE INVALID_HANDLE_VALUE -1 Almost all the defines for the "dwFileAttributes" argument of WIN32_FIND_DATA ' Only "_DIRECTORY" is required for this example DEFINE FILE_ATTRIBUTE_ARCHIVE &H20 DEFINE FILE_ATTRIBUTE_DIRECTORY &H10 DEFINE FILE_ATTRIBUTE_HIDDEN &H2 DEFINE FILE_ATTRIBUTE_NORMAL &H80 DEFINE FILE_ATTRIBUTE_READONLY &H1 DEFINE FILE_ATTRIBUTE_SYSTEM &H4 DEFINE FILE_ATTRIBUTE_TEMPORARY &H100 'GetComputerNameEx Define ComputerNameNetBIOS 0 Define ComputerNameDnsHostname 1 Define ComputerNameDnsDomain 2 Define ComputerNameDnsFullyQualified 3 Define ComputerNamePhysicalNetBIOS 4 Define ComputerNamePhysicalDnsHostName 5 Define ComputerNamePhysicalDnsDomain 6 Define ComputerNamePhysicalDnsFullyQualified 7 Define ComputerNameMax 8

******************************************************************************************* TYPE STATEMENTS TYPE FILETIME dwLowDateTime As Integer dwHighDateTime As Integer END TYPE

TYPE WIN32_FIND_DATA dwFileAttributes As Integer ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Integer nFileSizeLow As Integer dwReserved0 As Integer dwReserved1 As Integer cFileName As String MAX_PATH cAlternate As String 14 END TYPE

TYPE SECURITY_ATTRIBUTES nLength as integer lpSecurityDescriptor as integer bInheritHandle as integer END TYPE

TYPE OSVERSIONINFO dwOSVersionInfoSize As Integer 'The size of the structure. In this case (5 4 + 128)=148 dwMajorVersion As Integer 'The major version number; i.e., the part of the version number before the first period dwMinorVersion As Integer 'The minor version number; i.e., the part of the version number after the first period dwBuildNumber As Integer 'The build number of the version dwPlatformId As Integer 'Exactly one of the following flags identifying which platform of Windows is running (see below) szCSDVersion As String 128 'More information about the operating system END TYPE dwPlatformId = 0 Windows 3.x is running, using the Win32s pseudo-32-bit enhancements. = 1 Windows 95 or 98 is running. = 2 Windows NT is running

Type SYSTEMTIME wYear As Smallint Four-digit year wMonth As Smallint Month by number (1=January,...) wDayOfWeek As Smallint Day of the week by number (0=Sunday, 1=Monday ...) wDay As Smallint Day of the month by number wHour As Smallint Hour in 24 hour format wMinute As Smallint Minutes wSecond As Smallint Seconds wMilliseconds As Smallint Milliseconds End Type

Type MEMORYSTATUS dwLength As Integer 'Size of MEMORYSTATUS Structure dwMemoryLoad As Integer 'Approximate Percentage of total physical memory used dwTotalPhys As Integer 'Total Physical Memory Size dwAvailPhys As Integer 'Available Physical Memory dwTotalPageFile As Integer 'Size of Commited memory Limit dwAvailPageFile As Integer 'Available memory to commit dwTotalVirtual As Integer 'Total of user mode portion of virtual address space of the calling process dwAvailVirtual As Integer 'Size of uncommited and unreserved memory in the user mode portion End Type

'******************************************************************************************* 'GLOBAL VARIABLES

******************************************************************************************* DECLARE SUB STATEMENTS DECLARE SUB GetSystemTime Lib "KERNEL32.DLL" (lpSystemTime As SYSTEMTIME) DECLARE SUB Sleep Lib "KERNEL32.DLL" Alias "Sleep" (ByVal dwMilliSecond As Integer) DECLARE SUB GlobalMemoryStatus Lib "KERNEL32.DLL" (lpBuffer As MEMORYSTATUS) ******************************************************************************************* DECLARE FUNCTIONS STATEMENTS

'Sourced from Napier City Council DECLARE FUNCTION GetComputerName Lib "KERNEL32.DLL" Alias "GetComputerNameA" (lpBuffer As String, lpnSize As Integer) As Integer DECLARE FUNCTION GetComputerNameEx Lib "KERNEL32.DLL" Alias "GetComputerNameExA" (ByVal NameType As Integer, lpBuffer As String, lpnSize As Integer) As Integer DECLARE FUNCTION GetLastError Lib "KERNEL32.DLL" () As Integer DECLARE FUNCTION GetUserName Lib "ADVAPI32.DLL" Alias "GetUserNameA" (lpBuffer As String, nSize As Integer) As Integer DECLARE FUNCTION GetFreeSpace Lib "KERNEL32.DLL" Alias "GetDiskFreeSpaceA" (lpDirectoryName As String, lpSectorsPerCluster as Integer, lpBytesPerSector As Integer, lpFreeClusters As Integer, lpTotalClusters As Integer) As Integer DECLARE FUNCTION CreateDirectory Lib "KERNEL32.DLL" Alias "CreateDirectoryA" (ByVal lpPathName As String, ByVal lpSecurityAttributes As Integer) As Integer DECLARE FUNCTION RemoveDirectory Lib "KERNEL32.DLL" Alias "RemoveDirectoryA" (ByVal lpPathName As String) As Integer DECLARE FUNCTION CopyFile Lib "KERNEL32.DLL" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Integer) As Integer DECLARE FUNCTION DeleteFile Lib "KERNEL32.DLL" Alias "DeleteFileA" (ByVal lpFileName As String) As Integer DECLARE FUNCTION GetINISetting Lib "KERNEL32.DLL" Alias "GetPrivateProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer DECLARE FUNCTION WriteINISetting Lib "KERNEL32.DLL" Alias "WritePrivateProfileStringA" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer DECLARE FUNCTION GetFileAttributes Lib "KERNEL32.DLL" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Integer DECLARE FUNCTION LockWorkStation Lib "USER32.DLL" () As Integer DECLARE FUNCTION GetTempPath Lib "KERNEL32.DLL" Alias "GetTempPathA" (ByVal nBufferLength As Integer, lpBuffer As String) As Integer

'Sourced from Other People Declare Function FindFirstFile Lib "kernel32.dll" Alias "FindFirstFileA" (ByVal lpFileName As String,lpFindFileData As WIN32_FIND_DATA) As Integer Declare Function FindNextFile Lib "kernel32.dll" Alias "FindNextFileA" (ByVal hFindFile As Integer,lpFindFileData As WIN32_FIND_DATA) As Integer Declare Function FindClose Lib "kernel32.dll" Alias "FindClose" (ByVal hFindFile As Integer) As Integer Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Integer) As Integer Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" (ByVal lpFileName As String, ByVal dwDesiredAccess As Integer, ByVal dwShareMode As Integer, lpSecurityAttributes As SECURITY_ATTRIBUTES, ByVal dwCreationDisposition As Integer, ByVal dwFlagsAndAttributes As Integer, ByVal hTemplateFile As Integer ) As Integer Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO ) As Integer '*******************************************************************************************

« December 2008 »
Su Mo Tu We Th Fr Sa
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
 

Powered by Plone, the Open Source Content Management System

This site conforms to the following standards: