PBXB64 Registry & System
Registry & System
Standard
Full Windows registry and system control with REGISTER KEY/SET/GET/CLOSE/DELETE, COMM OPEN/CLOSE/SET/SEND/RECV, PROCESS GET/SET PRIORITY, and MOUSEPTR. All real Win32 API calls, not stubs.
Registry Operations
Read and write registry
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN() AS LONG
LOCAL hKey AS QUAD
LOCAL value AS STRING
' Create or open a key under HKEY_CURRENT_USER (relative path)
REGISTER KEY "Software\PBXB64\FeatureDemo" TO hKey
' Write value (stored as REG_SZ text)
REGISTER SET hKey, "Setting1", "42"
REGISTER SET hKey, "OldSetting", "obsolete"
' Read value
REGISTER GET hKey, "Setting1" TO value
PRINT "Setting: "; value
' Delete a value
REGISTER DELETE VALUE hKey, "OldSetting"
' Close key
REGISTER CLOSE hKey
' Remove the demo key again (keys without subkeys only)
REGISTER DELETE KEY "Software\PBXB64\FeatureDemo"
FUNCTION = 0
END FUNCTION
REGISTER KEY path TO h opens a registry key below HKEY_CURRENT_USER (creating it if needed) and returns a handle. REGISTER SET/GET write and read string values. REGISTER CLOSE releases the handle. REGISTER DELETE VALUE removes a value and REGISTER DELETE KEY removes the key. All use real RegCreateKeyEx, RegSetValueEx, RegQueryValueEx, RegCloseKey.
Serial Port (COMM)
Serial communication
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN() AS LONG
LOCAL received AS STRING
LOCAL sent AS LONG
' Open COM port (give "COM1", not "\.\COM1")
COMM OPEN "COM1" AS #1
COMM TIMEOUT #1, 1000 ' 1 s read timeout
' Configure: baud rate, data bits, parity (0 = none)
COMM SET #1, BAUD = 9600
COMM SET #1, BYTE = 8
COMM SET #1, PARITYTYPE = 0
' Send data (TO returns the bytes written)
COMM SEND #1, "Hello Device" TO sent
' Receive up to 256 bytes
COMM RECV #1, 256, received
PRINT "Received: "; received
COMM CLOSE #1
FUNCTION = 0
END FUNCTION
COMM OPEN opens a serial port with CreateFile. COMM TIMEOUT sets the timeout. COMM SET #1, option = value changes one setting at a time (BAUD, BYTE, PARITYTYPE, ...). COMM SEND/RECV transfer data. COMM CLOSE releases the handle. Full Win32 COM port API.
Process Priority & Mouse Pointer
System control
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN() AS LONG
LOCAL priority AS LONG
' Get current process priority class (&H20 = normal)
PROCESS GET PRIORITY TO priority
PRINT "Priority: "; priority
' Set priority (NORMAL=&H20, IDLE=&H40, HIGH=&H80, REALTIME=&H100)
PROCESS SET PRIORITY &H20
' Set mouse pointer (1 = wait cursor, 0 = arrow)
MOUSEPTR 1
SLEEP 1000
MOUSEPTR 0
FUNCTION = 0
END FUNCTION
PROCESS GET PRIORITY TO reads the priority class, PROCESS SET PRIORITY sets it (&H20 normal, &H40 idle, &H80 high, &H100 realtime). MOUSEPTR selects a standard cursor by number: 0 arrow, 1 wait, 2 cross, 3 I-beam, 12 hand. All real Win32 calls.
PBXB64 is part of the PBX-Compiler package. Free for private use, cleanly licensed for business.