Unknown Visual Basic library for Freebasic?

External libraries (GTK, GSL, SDL, Allegro, OpenGL, etc) questions.
Post Reply
jepalza
Posts: 149
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Unknown Visual Basic library for Freebasic?

Post by jepalza »

This WEB:
http://vbtoolbox.kerys.co.uk/

Unknown? on the forum I can't find anything about "vbtoolbox" or "mslib145" .
The DLL is called "mslib145.dll".

The web is practically empty, there are no links to modern versions, only to V1.24:
http://vbtoolbox.kerys.co.uk/bin/vbtoolbox.zip

Also, in "https://archive.org/" there are hardly any mentions. It is the "ghost" DLL.
At least, V1.24 works, and has interesting functions.

Using "https://www.deepl.com/" Translator Free
angros47
Posts: 2321
Joined: Jun 21, 2005 19:04

Re: Unknown Visual Basic library for Freebasic?

Post by angros47 »

The file vbtoolbox.zip you linked contains that DLL, version 145, so I don't understand the issue you are having
jepalza
Posts: 149
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: Unknown Visual Basic library for Freebasic?

Post by jepalza »

Sorry, the automatic translations do not (probably) reproduce what I want to represent.
What I mean, is that I have never heard of this DLL on the forum, nor is there any information about it.
It's just an "oddity", a rarity that I have located and made available to the public, because it has some interesting functions, despite being old.
It is clearly mentioned that it is valid for both VB and FB, but nobody on the forum had talked about it, so I saw it as something different and wanted to make it known.
I don't speak English (nothing, zero) and I always use translators, and I don't know if what they translate is syntactically correct or if they don't make sense, that's why I usually leave the original text in Spanish, in case someone needs to translate it in their own way.
------

Lo siento, las traducciones automaticas no reproduden (probablemente) lo que quiero representar.
Lo que quiero decir, es que nunca habia escuchado hablar de esta DLL en el foro, ni hay información sobre ella.
Es solo una "extrañeza", una rareza que he localizado y he puesto a disposición del público, por que tiene algunas funciones interesantes, a pesar de ser antiguo.
Se menciona claramente que es válida tanto para VB como FB, pero nadie en el foro había hablado de ella, por lo que lo he visto como algo diferente y he querido darlo a conocer.
No hablo ingles (nada, cero) y siempre uso traductores, y no se si lo que traducen es correcto sintacticamente o si no tienen sentido, por eso suelo dejar ademas el texto original en español, por si alguien lo necesita traducir a su manera.
jepalza
Posts: 149
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: Unknown Visual Basic library for Freebasic?

Post by jepalza »

I have prepared the BI file for FB from VB.
Some functions of the DLL already exist in FB, others don't, it's a matter of testing which ones you like and which ones you don't.

I leave an example with some interesting ones that I have try.

Note: don't confuse the name of the DLL (MSLIB145) with the version. The number "145" is just the name of the DLL, his version is 1.24
There is a more modern 1.36 but I haven't found it.

File "MSLIB145.BI"

Code: Select all


'==================================================================================================
' MSLIB145.BAS  - Copyright (C) M Shaw - Nov 2003-August 2009
'==================================================================================================
' Purpose: VB 5 and above declares to link to MSLIB145.DLL
'==================================================================================================
' Copyright (C) M Shaw - 2003-2009 - Freeware - NO WARRANTY
' See website and any accompanying README.TXT for conditions of use
' http://software.amadis.sytes.net/vbtoolbox/
'
' Comment-out, uncomment, or copy sections of this file to your project as required
' You may freely rename declared functions using aliases if required
'
' Latest version was tested OK on Windows NT4.0(SP6a), Windows 2000 (SP4), Windows XP(SP2)
' Console/CGI functions tested on the above and OK
' NB: GetAvailableVirtualMemory and GetTotalVirtualMemory API calls do not work on NT 4.0
' This file may contain developer-only test routines at the end of the file which may be ignored

'==================================================================================================
' * WARNING * DO NOT UPX-PACK/REPACK the DLL if you use the LogEvent() functions!
'==================================================================================================

'Updates:

'V1.00 23/11/2003 First version with very "basic" functions
'V1.01 15/04/2005 Updated version with encryption (code was lost c2006)
'V1.02 01/06/2008 Lost DLL C code partially reconstructed
'V1.03 02/06/2008 NumOrd, Mk*/Cv*, Windows version routines etc.
'v1.04 03/06/2008 Disk space API functs etc. Readfile fixed
'v1.05 04/06/2008 Added IP functs IPMatch, MatchCIDR, IPToLong etc.
'v1.06 05/06/2008 Added Windows mem API functs
'v1.07 15/06/2008 PHPDate added with basic functionality
'V1.08 18/06/2008 PHPDate expanded - PHPDateNow DSTAdjust
'       vbdate_to_time WinSleep Fraction/Integral etc.
'V1.09 21/06/2008 Round HexToDate/DateToHex
'V1.10 22/06/2008 Code-review - attempt to reduce garbage passed after 0x00 in strings
'   BitPack , BitUnPack, PiStrm, fixed DST bug using mktime() evaluating elmination
'   of need for vbStr() by using byte allocation API calls (means no future Unicode)
'v1.11 25/06/2008 Bugfixes. Conditional Unicode compile (off). Zstring Ptr (esp NULL) returns examined
'       Need for vbStr() eliminated
'V1.12 26/06/2008 EncodeStr64 byte len - API allocates for NULL terminator (excess removed)
'       Bugfix BinToDec() for mixed binary/alpha chars postfix
'V1.13 28/06/2008 StripX... functions changed to return a new API-allocated string via function return
'       Note documentation re: conversion of console apps to full-console mode using LINK.EXE
'v1.14 31/06/2008 Removed InNewConsole(), Replaced with InNativeConsole()
'v1.15 05/07/2008 SetConsoleAttributes,ClearConsoleAttributes, InKey, Colour constant, WhereX/Y, GotoXY
'       FileType, WriteLn (Changed), Writes, GetOpenFile, GetSave File (ready), GetArgs
'       Tokenise,
'v1.16 --/07/2008 RotateByte, RotateInt, RotateLong
'v1.17 10/07/2008 HexToLong, HexToDouble, ListFiles, FilesMatch, WildcardMatch, ShellRun
'v1.18 14/07/2008 BaseConvDouble, MapNetworkDrive, MapNextFreeNetworkDrive, UnMapDrive, GetCGIArgs, DriveType
'       IsHardDisk, IsRAMDisk, IsCDROMDisk, IsNetworkDisk, IsRemovableDisk, Variant memory
'       allocation rewritten
'v1.19 19/07/2008 CreateGUID, LogEvent, AddEventSource, RemoveEventSource, GetDLLFileName
'       IsEventSource, ReadDWORDFromRegistry, WriteDWORDToRegistry, WriteStringToRegistry
'v1.20 20/07/2009 Additional time traces for Windows 7 testing (found to be 10x slower than XP!)
'v1.21 24/08/2009 This version is a major revision
'       Renamed IsDLLInstalled to IsVBToolboxDLLInstalled. Change encryptstring len from int to long
'       added MapiSend(). Changed name of VERSION control Const to DLL_VERSION.
'       Traced memory leak in VB to returned string - thus changed EncryptString from Function to a Sub
'       Enhanced EncryptString() - new parameter ExtraSecure. New Length parameter for StrToHex to
'       accurately-control processing of strings with embedded nulls as produced by EncrytString()
'       Added new simple function: Zstring PtrToHex() to supplement complex function StrToHex()
'       Internal structure of many functions which return strings has been restructured to eliminate
'       memory leaks. The test-program was changed to enable longer-term tests including the tracking
'       of memory-allocation using Windows task-manager.
'V1.22 03/09/2009 Improved MAPISendMessage() Added GetProcessMemoryUsed(). PiStr() removed ready to migrate to
'       a separate DLL (pi.dll)
'v1.23 09/09/2009 Revised encryption method for EncryptString() now with added Salt
'v1.24 11/09/2009 Fix bitshift bug in Bin8, Bin16, Bin32
'       Implement RLECompress/RLEDecompress, RLECompressByteCount, RLEDecompressByteCount
' //////////////////////////////////////////////////////////////////////////////////////////////////////


Const VERNUM As String = "1.24" ' This test app's release version
Const DLL_VERSION As String = "1.24"    ' This VB code release ID is required (to match DLL version)
Const WEBSITE As String = "http://vbtoolbox.amadis.sytes.net"
Const DLLNAME As String = "mslib145.dll"     'Can't use this Const in Declares unfortunately
Const DLLDATE As String = "20090911"

Const HKEY_CLASSES_ROOT = &H80000000
'Public Const HKEY_LOCAL_USER = &H80000001  ' Alternate HKCU
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005

' RandomStr()
Const RandomStringMixedCase = 0
Const RandomStringLower = 1
Const RandomStringUpper = 2
Const RandomStringNumeric = 3
Const RandomStringAll = 4
Const RandomStringBinary = 5
Const RandomStringHex = 6   ' // v1.21+ // New
Const RandomStringBinaryString = 7
Const RandomStringBinaryStringBias0 = 8
Const RandomStringBinaryStringBias1 = 9

'For LogEvent()
Const EVENTLOG_SUCCESS = 0
Const EVENTLOG_ERROR_TYPE = 1
Const EVENTLOG_WARNING_TYPE = 2
Const EVENTLOG_INFORMATION_TYPE = 4
Const EVENTLOG_AUDIT_SUCCESS = 8
Const EVENTLOG_AUDIT_FAILURE = 10

'DLL management
Declare Function LibVersion Alias "LibVersion" () As Long

'Graphics functions
Declare Function JPEGHeader Alias "JPEGHeader" (ByVal FileName As Zstring Ptr, Width As Integer, Height As Integer, FileLength As Long) As BOOL
Declare Function JPEGCheck  Alias "JPEGCheck"  (ByVal FileName As Zstring Ptr) As BOOL
Declare Function FileCount  Alias "FileCount"  (ByVal PathSpec As Zstring Ptr) As Long

'String functions
Declare Function WildcardMatch Alias "WildcardMatch" (ByVal s As Zstring Ptr, ByVal Wildcard As Zstring Ptr, IgnoreCase As BOOL = FALSE) As BOOL
Declare Function Tokenise Alias "Tokenise" (ByVal s As Zstring Ptr, ByVal Tokens As Zstring Ptr, ByVal Basis As Integer = 0) As Integer
Declare Function CommaStr Alias "CommaStr" (ByVal s As Zstring Ptr, ByVal Decimals As Integer = 0) As Zstring Ptr
Declare Function Comma Alias "Comma" (ByVal Value As Double, ByVal Decimals As Integer = 0) As Zstring Ptr
Declare Function FillString Alias "FillString" (ByVal s As Zstring Ptr, ByVal CharToUse As Zstring Ptr) As Zstring Ptr
Declare Function InStrI Alias "InStrI" (ByVal s As Zstring Ptr, ByVal search As Zstring Ptr) As Long
Declare Function InChrRev Alias "InChrRev" (ByVal s As Zstring Ptr, ByVal iChar As Integer) As Long
Declare Function InChr Alias "InChr" (ByVal s As Zstring Ptr, ByVal iChar As Integer) As Long
'Ya en FB --> Declare Function InStrRev Alias "InStrRev" (ByVal s As Zstring Ptr, ByVal search As Zstring Ptr) As Long
Declare Function IsAllChar Alias "IsAllChar" (ByVal s As Zstring Ptr, ByVal TheChar As Zstring Ptr) As BOOL
Declare Function StripLStr Alias "StripLStr" (ByVal s As Zstring Ptr, ByVal Mask As Zstring Ptr) As Zstring Ptr
Declare Function StripL Alias "StripL" (ByVal s As Zstring Ptr, ByVal Mask As Zstring Ptr) As Zstring Ptr
Declare Function StripRStr Alias "StripRStr" (ByVal s As Zstring Ptr, ByVal Mask As Zstring Ptr) As Zstring Ptr
Declare Function StripR Alias "StripR" (ByVal s As Zstring Ptr, ByVal Mask As Zstring Ptr) As Zstring Ptr
Declare Function StrRev Alias "StrRev" (ByVal s As Zstring Ptr) As Zstring Ptr
Declare Function Replace Alias "Replace" (ByVal s As Zstring Ptr, ByVal a As Zstring Ptr, ByVal b As Zstring Ptr) As Zstring Ptr
Declare Function ReplaceChar Alias "ReplaceChar" (ByVal s As Zstring Ptr, ByVal SearchedFor As Zstring Ptr, ByVal Replacement As Zstring Ptr) As Zstring Ptr
Declare Function GetArrayDimensions Alias "GetArrayDimensions" (ByRef v As Integer) As Long

'Data conversion functions
Declare Function BaseConv Alias "BaseConv" (ByVal Value As Long, ByVal Basis As Integer) As Zstring Ptr
Declare Function BaseConvDouble Alias "BaseConvDouble" (ByVal Value As Double, ByVal Basis As Integer) As Zstring Ptr
Declare Function Bin8 Alias "Bin8" (ByVal i As Byte) As Zstring Ptr
Declare Function Bin16 Alias "Bin16" (ByVal i As Integer) As Zstring Ptr
Declare Function Bin32 Alias "Bin32" (ByVal i As Long) As Zstring Ptr
Declare Function BinToDec Alias "BinToDec" (ByVal s As Zstring Ptr) As Long
Declare Function BitPack Alias "BitPack" (ByVal s As Zstring Ptr, ByVal length As Long=0) As Zstring Ptr
Declare Function BitUnPack Alias "BitUnPack" (ByVal s As Zstring Ptr, ByVal BitPairs As Long=0) As Zstring Ptr
Declare Function RotateByte Alias "RotateByte" (ByRef b As Byte) As Byte
Declare Function RotateInt Alias "RotateInt" (ByRef i As Integer) As Integer
Declare Function RotateLong Alias "RotateLong" (ByRef l As Long) As Long

' Charhex, HexChar, HexInt, HexLong have changed names from V1.07+
Declare Function HexToChar Alias "HexToChar" (ByVal HexPair As Zstring Ptr) As Byte
Declare Function HexToInt Alias "HexToInt" (ByVal Str As Zstring Ptr) As Integer
Declare Function HexToLong Alias "HexToLong" (ByVal Str As Zstring Ptr) As Double
Declare Function HexToDouble Alias "HexToDouble" (ByVal Str As Zstring Ptr) As Double
Declare Function CharToHex Alias "CharToHex" (ByVal i As Byte) As Zstring Ptr
Declare Function IntToHex Alias "IntToHex" (ByVal i As Integer) As Zstring Ptr
Declare Function LongToHex Alias "LongToHex" (ByVal i As Double) As Zstring Ptr
Declare Function StringToHex Alias "StringToHex" (ByVal s As Zstring Ptr) As Zstring Ptr
Declare Function StrToHex Alias "StrToHex" (ByVal s As Zstring Ptr, ByVal length As Long, ByVal WrapWidth As Integer=0) As Zstring Ptr
Declare Function HexToStr Alias "HexToStr" (ByVal s As Zstring Ptr) As Zstring Ptr
Declare Function CreateGUID Alias "CreateGUID" ( ByVal Formatted As BOOL = TRUE) As Zstring Ptr

'Legacy BASIC functions
'CV*/MK* Data Conversion - VB data types (byte sizes)
'Byte    1 byte  0 to 255
'Integer     2 bytes -32,768 to 32,767
'Long (long integer)  4 bytes -2,147,483,648 to 2,147,483,647&
'Single (single-precision floating-point)   4 bytes -3.402823E38 to -1.401298E-45 for negative values; 1.401298E-45 to 3.402823E38 for positive values
'Double (double-precision floating-point)   8 bytes -1.79769313486232E308 to
'-4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values
/' 'Ya en FB --> 
Declare Function Mki Alias "Mki" (ByVal i As Integer) As Zstring Ptr
Declare Function Cvi Alias "Cvi" (ByVal Str As Zstring Ptr) As Integer
Declare Function Mkl Alias "Mkl" (ByVal l As Long) As Zstring Ptr
Declare Function Cvl Alias "Cvl" (ByVal Str As Zstring Ptr) As Long
Declare Function Mkf Alias "Mkf" (ByVal F As Single) As Zstring Ptr
Declare Function Cvf Alias "Cvf" (ByVal Str As Zstring Ptr) As Single
Declare Function Mkd Alias "Mkd" (ByVal d As Double) As Zstring Ptr
Declare Function Cvd Alias "Cvd" (ByVal Str As Zstring Ptr) As Double
'/

'Windows API functions
'Declare Function logevent Alias "logevent" Alias "LogEvent" (ByVal AppName As Zstring Ptr, ByVal Message As Zstring Ptr, ByVal LogType As Integer, ByVal PostScript As Zstring Ptr = NULLSTR) As BOOL
Declare Function IsEventSource Alias "IsEventSource" (ByVal AppName As Zstring Ptr) As BOOL
Declare Function AddEventSource Alias "AddEventSource" (ByVal AppName As Zstring Ptr, ByVal CategoryCount As Integer = 0) As BOOL
Declare Function RemoveEventSource Alias "RemoveEventSource" (ByVal AppName As Zstring Ptr) As BOOL
Declare Function DiskFree Alias "DiskFree" (ByVal Drive As Zstring Ptr) As Double
Declare Function DiskFreeGig Alias "DiskFreeGig" (ByVal Drive As Zstring Ptr) As Double
Declare Function DiskFreeMeg Alias "DiskFreeMeg" (ByVal Drive As Zstring Ptr) As Double
'Ya en FB --> Declare Function FileExists Alias "FileExists" (ByVal Filespec As Zstring Ptr) As BOOL
Declare Function DriveExists Alias "DriveExists" (ByVal Filespec As Zstring Ptr) As BOOL
Declare Function DirExists Alias "DirExists" (ByVal Filespec As Zstring Ptr) As BOOL
Declare Function GetAvailablePhysicalMemory Alias "GetAvailablePhysicalMemory" () As Double
Declare Function GetTotalPhysicalMemory Alias "GetTotalPhysicalMemory" () As Double
Declare Function GetAvailableSwapfileMemory Alias "GetAvailableSwapfileMemory" () As Double
Declare Function GetTotalSwapfileMemory Alias "GetTotalSwapfileMemory" () As Double
Declare Function GetAvailableVirtualMemory Alias "GetAvailableVirtualMemory" () As Double
Declare Function GetTotalVirtualMemory Alias "GetTotalVirtualMemory" () As Double
Declare Function GetSystemDir Alias "GetSystemDir" () As Zstring Ptr
Declare Function GetWindowsDir Alias "GetWindowsDir" () As Zstring Ptr
Declare Function WindowsSubVersion Alias "WindowsSubVersion" () As Zstring Ptr
Declare Function WindowsVersion Alias "WindowsVersion" () As Zstring Ptr
Declare Function GetLocalDriveStrings Alias "GetLocalDriveStrings" () As Zstring Ptr
Declare Function GetDLLFileName Alias "GetDLLFileName" () As Zstring Ptr
Declare Function ShellRun Alias "ShellRun" (ByVal Command As Zstring Ptr) As BOOL
Declare Function GetDiskSize Alias "GetDiskSize" (ByVal DiskLetter As Zstring Ptr, ByVal CompensateBy10K As BOOL = TRUE) As Integer
Declare Function GetDiskSizeMb Alias "GetDiskSizeMb" (ByVal DiskLetter As Zstring Ptr) As Long
Declare Function GetDiskSizeGb Alias "GetDiskSizeGb" (ByVal DiskLetter As Zstring Ptr) As Double

Declare Sub      WinSleep Alias "WinSleep" (ByVal Msecs As Integer)
Declare Function SetWallpaper Alias "SetWallpaper" (ByVal FileName As Zstring Ptr, ByVal Style As Integer = 1) As BOOL  ' Default style is centred
Declare Function GetWallpaper Alias "GetWallpaper" () As Zstring Ptr
Declare Function GetWallpaperStyle Alias "GetWallpaperStyle" () As Integer

Declare Function ReadStringFromRegistry Alias "ReadStringFromRegistry" (ByVal hKey As Long, ByVal SubKey As Zstring Ptr, ByVal Value As Zstring Ptr) As Zstring Ptr
Declare Function WriteStringToRegistry Alias "WriteStringToRegistry" (ByVal hKey As Long, ByVal SubKey As Zstring Ptr, ByVal Value As Zstring Ptr, ByVal Data As Zstring Ptr) As BOOL
Declare Function ReadDWORDFromRegistry Alias "ReadDWORDFromRegistry" (ByVal hKey As Long, ByVal SubKey As Zstring Ptr, ByVal Value As Zstring Ptr, ByRef DWORDValue As Long) As BOOL
Declare Function WriteDWORDToRegistry Alias "WriteDWORDToRegistry" (ByVal hKey As Long, ByVal SubKey As Zstring Ptr, ByVal Value As Zstring Ptr, ByVal DWORDValue As Long) As BOOL
    
Declare Function GetOpenFile Alias "GetOpenFile" (ByVal hWnd As integer, ByVal filter As Zstring Ptr, ByVal title As Zstring Ptr, ByVal InitDir As Zstring Ptr, ByVal flags As Integer) As Zstring Ptr
Declare Function GetSaveFile Alias "GetSaveFile" (ByVal hWnd As Integer, ByVal filter As Zstring Ptr, ByVal title As Zstring Ptr, ByVal InitDir As Zstring Ptr, ByVal DefaultName As Zstring Ptr, ByVal flags As Integer) As Zstring Ptr
    
Declare Function GetDiskType Alias "GetDiskType" (ByVal DriveLetter As Zstring Ptr) As Integer
Declare Function IsCDROMDisk Alias "IsCDROMDisk" (ByVal DriveLetter As Zstring Ptr) As BOOL
Declare Function IsHardDisk Alias "IsHardDisk" (ByVal DriveLetter As Zstring Ptr) As BOOL
Declare Function IsNetworkDisk Alias "IsNetworkDisk" (ByVal DriveLetter As Zstring Ptr) As BOOL
Declare Function IsRAMDisk Alias "IsRAMDisk" (ByVal DriveLetter As Zstring Ptr) As BOOL
Declare Function IsRemovableDisk Alias "IsRemovableDisk" (ByVal DriveLetter As Zstring Ptr) As BOOL
Declare Function IsValidDisk Alias "IsValidDisk" (ByVal DriveLetter As Zstring Ptr) As BOOL
    
' File functions
Declare Function AddTrailingSlash Alias "AddTrailingSlash" (ByVal FileName As Zstring Ptr) As Zstring Ptr
Declare Function FilenameMatch Alias "FilenameMatch" (ByVal FileName As Zstring Ptr, ByVal Wildcard As Zstring Ptr) As BOOL
Declare Function FileType Alias "FileType" (ByVal FileName As Zstring Ptr) As Zstring Ptr
Declare Function GetNormalisedPath Alias "GetNormalisedPath" (ByVal Path As Zstring Ptr) As Zstring Ptr
Declare Function ListFiles Alias "ListFiles" (ByVal PathSpec As Zstring Ptr, ByVal FileSpecs As Zstring Ptr = NULLSTR, ByVal ArrayBase As Integer = 0) As Integer
Declare Function ReadFile Alias "ReadFile" (ByVal FileName As Zstring Ptr, ByVal Bytes As Long=0) As Zstring Ptr

'Date and time functions
Declare Function ISOToUKDate Alias "ISOToUKDate" (ByVal YYYYMMDD As Zstring Ptr) As Zstring Ptr
Declare Function UKToISODate Alias "UKToISODate" (ByVal DDsMMsYYYY As Zstring Ptr) As Zstring Ptr
Declare Function UKShortToISODate Alias "UKShortToISODate" (ByVal DDsMMsYY As Zstring Ptr) As Zstring Ptr
Declare Function IsLeapYear Alias "IsLeapYear" (ByVal Year As Integer) As BOOL
Declare Function NumOrd Alias "NumOrd" (ByVal N As Integer) As Zstring Ptr
'Declare Function PHPDate Alias "PHPDate" (ByVal d As Date, ByVal s As Zstring Ptr="") As Zstring Ptr
'Declare Function PHPDateNow Alias "PHPDateNow" (ByVal s As Zstring Ptr="") As Zstring Ptr
'Declare Function VBDate Alias "VBDate" (ByVal d As Date) As Zstring Ptr
'Declare Function VBDateMsecs Alias "VBDateMsecs" (ByVal d As Date) As Integer
'Declare Function VBDateToCTime Alias "VBDateToCTime" (ByVal d As Date) As Double
'Declare Function CTimeToVBDate Alias "CTimeToVBDate" (ByVal d As Double) As Date
'Declare Function DSTAdjust Alias "DSTAdjust" (ByVal d As Date) As Double
'Declare Function DateToHex Alias "DateToHex" (ByVal d As Date) As Zstring Ptr
'Declare Function HexToDate Alias "HexToDate" (ByVal s As Zstring Ptr) As Double

'Maths functions (algunas en "crt\math.bi")
Declare Function Gcd Alias "Gcd" (ByVal a As Long, ByVal b As Long) As Long
Declare Function Max Alias "Max" (ByVal a As Integer, ByVal b As Integer) As Integer
Declare Function Min Alias "Min" (ByVal a As Integer, ByVal b As Integer) As Integer
Declare Function Integral Alias "Integral" (ByVal d As Double) As Double
Declare Function Fraction Alias "Fraction" (ByVal d As Double) As Double
Declare Function Round Alias "Round" (ByVal d As Double, ByVal Places As Integer=0) As Double

'IP address Network and Internet
Declare Function IPMatch Alias "IPMatch" (ByVal Mask As Zstring Ptr, ByVal IP As Zstring Ptr) As BOOL
Declare Function IPToLong Alias "IPToLong" (ByVal IP As Zstring Ptr) As Double
Declare Function LongToIP Alias "LongToIP" (ByVal IP As Double) As Zstring Ptr
Declare Function MatchCIDR Alias "MatchCIDR" (ByVal Mask As Zstring Ptr, ByVal IP As Zstring Ptr) As BOOL
Declare Function URLEncode Alias "URLEncode" (ByVal s As Zstring Ptr) As Zstring Ptr
Declare Function URLDecode Alias "URLDecode" (ByVal s As Zstring Ptr) As Zstring Ptr
Declare Function MapNetworkDrive Alias "MapNetworkDrive" (ByVal ServerPath As Zstring Ptr, ByVal DriveLetter As Zstring Ptr, ByVal UserName As Zstring Ptr, ByVal Password As Zstring Ptr, ByRef ErrorCode As Long, ByVal Persistent As BOOL = FALSE, OfferPromptForLogin As BOOL = FALSE) As BOOL
Declare Function MapNextFreeNetworkDrive Alias "MapNextFreeNetworkDrive" (ByVal ServerPath As Zstring Ptr, ByVal UserName As Zstring Ptr, ByVal Password As Zstring Ptr, ByRef ErrorCode As Long, ByVal Persistent As BOOL = FALSE, ByVal OfferPromptForLogin As BOOL = FALSE) As Zstring Ptr
Declare Function UnMapNetworkDrive Alias "UnMapNetworkDrive" (ByVal DriveLetter As Zstring Ptr, ByVal Persistent As BOOL = FALSE, ByVal ForceIt As BOOL = FALSE) As Long
Declare Function DisconnectFromServer Alias "DisconnectFromServer" (ByVal ServerName As Zstring Ptr, ByVal ForceIt As BOOL = FALSE) As Long
Declare Function GetCGIArgs Alias "GetCGIArgs" (ByVal s As Zstring Ptr, ByRef v As Integer) As Integer
Declare Function ArgFound Alias "ArgFound" (ByRef v As Integer, ByVal s As Zstring Ptr, ByVal IgnoreCase As BOOL = TRUE) As BOOL
Declare Function ArgVal Alias "ArgVal" (ByRef v As Integer, ByVal s As Zstring Ptr, ByVal IgnoreCase As BOOL = TRUE) As Zstring Ptr
    
'Encoding
Declare Function Base64Filter Alias "Base64Filter" (ByVal s As Zstring Ptr) As Zstring Ptr
Declare Function EncodeString64 Alias "EncodeString64" (ByRef sInput As Zstring Ptr, ByVal WrapWidth As Integer = 0) As Zstring Ptr
Declare Function DecodeString64 Alias "DecodeString64" (ByRef sInput As Zstring Ptr, ByRef NewLength As Long) As Zstring Ptr

'Random number
Declare Sub      Randomise Alias "Randomise" (ByVal Seed As Integer=0)
'Ya en FB --> Public Declare Function Random Lib "mslib145.dll" (ByVal Lo As Long, ByVal Hi As Long) As Long
Declare Function RandomStr Alias "RandomStr" (ByVal length As Long, ByVal Style As Integer = RandomStringMixedCase) As Zstring Ptr
Declare Function EncryptString Alias "EncryptString" (ByVal s As Zstring Ptr, ByVal length As Long, ByVal Password As Zstring Ptr, ByVal ExtraSecure As BOOL = TRUE, ByVal Salt As Zstring Ptr) As BOOL
    
' Console colours as per "C" conventions ///////////////////////////////////////////////
Const BACKGROUND_BLACK = 0
Const FOREGROUND_BLACK = 0
Const FOREGROUND_BLUE = 1
Const FOREGROUND_GREEN = 2
Const FOREGROUND_CYAN = 3
Const FOREGROUND_RED = 4
Const FOREGROUND_MAGENTA = 5
Const FOREGROUND_YELLOW = 6
Const FOREGROUND_GRAY = 7   ' Yep, American spelling
Const FOREGROUND_GREY = 7   ' UK (correct) spelling
Const FOREGROUND_INTENSITY = 8   ' Intensify the text colour

Const FOREGROUND_LIGHTBLUE = 1 Or FOREGROUND_INTENSITY
Const FOREGROUND_LIGHTGREEN = 2 Or FOREGROUND_INTENSITY
Const FOREGROUND_LIGHTCYAN = 3 Or FOREGROUND_INTENSITY
Const FOREGROUND_LIGHTRED = 4 Or FOREGROUND_INTENSITY
Const FOREGROUND_LIGHTMAGENTA = 5 Or FOREGROUND_INTENSITY
Const FOREGROUND_LIGHTYELLOW = 6 Or FOREGROUND_INTENSITY
Const FOREGROUND_WHITE = FOREGROUND_GREY Or FOREGROUND_INTENSITY

Const BACKGROUND_BLUE = 16
Const BACKGROUND_GREEN = 32
Const BACKGROUND_CYAN = 48
Const BACKGROUND_RED = 64
Const BACKGROUND_MAGENTA = 80
Const BACKGROUND_YELLOW = 96 ' Mustard
Const BACKGROUND_GRAY = 112
Const BACKGROUND_GREY = 112
Const BACKGROUND_INTENSITY = 128
Const BACKGROUND_WHITE = BACKGROUND_GRAY Or BACKGROUND_INTENSITY

'Console functions
Declare Function OpenConsole Alias "OpenConsole" () As Long
Declare Function InNativeConsole Alias "InNativeConsole" () As BOOL
Declare Function ConsoleOpen Alias "ConsoleOpen" () As Integer
Declare Sub      CloseConsole Alias "CloseConsole" () 
Declare Sub      SetConsoleAttributes Alias "SetConsoleAttributes" (ByVal Foreground As Integer, ByVal Background As Integer)
Declare Sub      ClearConsoleAttributes Alias "ClearConsoleAttributes" () 
Declare Function HideConsole Alias "HideConsole" () As Long
Declare Function ShowConsole Alias "ShowConsole" () As Long
Declare Function ConsoleTitle Alias "ConsoleTitle" (ByVal s As Zstring Ptr) As Long
Declare Function WriteLn Alias "WriteLn" (ByVal s As Zstring Ptr = NULLSTR) As Long
'We can use WriteLn as a command to write a CRLF
Declare Function Writes Alias "Writes" (ByVal s As Zstring Ptr) As Long
Declare Function ReadLn Alias "ReadLn" (ByVal l As Long) As Zstring Ptr
Declare Sub      Pause Alias "Pause" (ByVal s As Zstring Ptr = StrPtr("Press a key...") )
Declare Sub      ConsoleCls Alias "Cls" () 
Declare Function WhereX Alias "WhereX" () As Integer
Declare Function WhereY Alias "WhereY" () As Integer
Declare Sub      GotoXY Alias "GotoXY" (ByVal x As Integer, ByVal y As Integer)
Declare Function ConsoleInKey Alias "InKey" () As Integer
Declare Function GetArgs Alias "GetArgs" (ByVal s As Zstring Ptr, ByRef v As Integer) As Integer
    
'Process info
Declare Function GetPID Alias "GetPID" () As Long
Declare Function GetProcessMemoryUsed Alias "GetProcessMemoryUsed" (ByVal PID As Long) As Long
    
'MAPI Email
Declare Function MapiSend Alias "MapiSend" (ByVal hWindParent As Long, ByVal strAttachmentName As Zstring Ptr = NULLSTR, ByVal strSubject As Zstring Ptr = NULLSTR, ByVal strMessage As Zstring Ptr = NULLSTR) As BOOL
    
'Compression
Declare Function RLECompressByteCount Alias "RLECompressByteCount" (ByVal sInput As Zstring Ptr, ByVal length As Long) As Long
Declare Function RLEUncompressByteCount Alias "RLEUncompressByteCount" (ByVal sInput As Zstring Ptr, ByVal length As Long) As Long
Declare Function RLEUncompress Alias "RLEUncompress" (ByVal sInput As Zstring Ptr, ByVal length As Long, ByRef NewLength As Long=0) As Zstring Ptr
Declare Function RLECompress Alias "RLECompress" (ByVal sInput As Zstring Ptr, ByVal length As Long, ByRef NewLength As Long=0) As Zstring Ptr
Example:

Code: Select all

 
 #Ifndef BOOL
   #Define BOOL UByte
   #Define TRUE 1
   #Define FALSE 0
 #EndIf
 
 #Define NULLSTR StrPtr("-1")
 
 #Inclib "mslib145"
 #Include "mslib145.bi"

 Var sa="XX BB CC"
 Var sb="XX"
 Var sc="AA"
 
 'Print *Replace(sa,Chr(9),sc)
 
 Print "Replace 'XX' to 'AA' from:";sa
 Print *ReplaceChar(sa,sb,sc)
 Print
 Print "String 'ABCDEF' to HEX:"
 Print *StringToHex("ABCDEF")
 Print
 Print "Files in actual Dir:"
 Print FileCount("*.*")
 Print
 Print "Free Disc C:"
 Print DiskFreeGig("c:")
 Print
 Print "Wallpaper Windows:"
 Print *GetWallpaper()
 Print
 Print "Read String From Registry to key '.text':"
 Print *ReadStringFromRegistry(HKEY_CLASSES_ROOT,".text","PerceivedType")
 Print
 Print "Encoded 64bits text 'Encoded Text'":
 Dim As ZString Ptr text=StrPtr("Encoded Text")
 Dim As ZString Ptr encoded64 = EncodeString64(text,64)
 Print Left(*encoded64,64); " (Only 64 chars show)"
 print
 Print "Decoded 64bits text:":
 Print *DecodeString64(encoded64,Len(text))
 Print
 Print "Get Process ID:"
 Print Hex(GetPID(),8)
 Print
 Print "Send EMAIL with this window:"
 Print MapiSend(GetPID(),"example@example.com","subject","text to send")
 
 Print
 Print "--------------------------------"
 Print "Press Any Key to Console Test...":Sleep
 
 ' console
 OpenConsole()

 SetConsoleAttributes(FOREGROUND_RED,BACKGROUND_YELLOW)
 ConsoleCls()
 
 Print "Console is Opened? ";IIf(ConsoleOpen(), "True","False")
 Print
 Print "Console Title To 'FreeBasic'"
 ConsoleTitle("FreeBasic")
 Print
 GotoXY(10,10)
 Print "Set Pos At 10,10"
 WriteLn("WriteLN test...")
 
 print
 Pause("Press Any Key to Close Console")
 CloseConsole()
 
 
Post Reply