Hack Forums
PureBasic Examples & Discussion - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: PureBasic Examples & Discussion (/showthread.php?tid=6127835)



PureBasic Examples & Discussion - 0x0000005 - Dec 16, 2020

Is anyone here currently coding with or fluent with PureBasic?  Just curious as I use it a ton.  Its super easy to whip up programs, and run without dependencies creating a super small exe or dll file.  It has similarities to some languages like VB, Delphi, and C.  Here's a sample console program that compiles to 13 kb uncompressed, and displays the product key in windows using some reg queries.

Code
Procedure.s GetWindowsProductKey()
  #KEY_WOW64_64KEY = $100
  Protected hKey, Res, size = 280
  Protected i, j, x, Result.s
  Protected *mem = AllocateMemory(size)
  Protected *newmem = AllocateMemory(size)
  Protected *digits = AllocateMemory(25)
 
  PokeS(*digits, "BCDFGHJKMPQRTVWXY2346789", -1, #PB_Ascii)
 
  If OSVersion() <= #PB_OS_Windows_2000
    Res = RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows NT\CurrentVersion", 0, #KEY_READ, @hKey)
  Else
    Res = RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows NT\CurrentVersion", 0, #KEY_READ | #KEY_WOW64_64KEY, @hKey)
  EndIf
 
  If Res = #ERROR_SUCCESS
   
    RegQueryValueEx_(hKey, "DigitalProductID", 0, 0, *mem, @size)
    RegCloseKey_(hKey)
   
    If size <> 280
     
      For i = 24 To 0 Step -1
        x = 0
        For j = 66 To 52 Step -1
          x = (x << 8) + PeekA(*mem + j)
          PokeA(*mem + j, x / 24)
          x % 24
        Next
        PokeA(*newmem + i, PeekA(*digits + x))
      Next
     
      For i = 0 To 15 Step 5
        Result + PeekS(*newmem + i, 5, #PB_Ascii) + "-"
      Next
     
      Result + PeekS(*newmem + 20, 5, #PB_Ascii)
     
    EndIf
   
  EndIf
 
  FreeMemory(*mem) : FreeMemory(*newmem) : FreeMemory(*digits)
 
  ProcedureReturn Result
 
EndProcedure

OpenConsole()

PrintN(GetWindowsProductKey())

I think this language is cool as hell, like delphi was back in the 5,6,7 version era. It has lots of built-in capabilities, as well as the ability to simply call native system API's or DLL calls.

It's also compatible (sorta) with MacOS and Linux, providing your code detects different OS's at compile-time. purebasic[dot]com/documentation/index.html

I just re-signed up, so this is my random first discussion post.  I haven't been here, nor around the scene in general in a long long time.  Cool to see this site is still around.


RE: PureBasic Examples & Discussion - HFDone - Dec 17, 2020

more like vb6 and C mix
my compiler
3k exe
5k dll


RE: PureBasic Examples & Discussion - 0x0000005 - Dec 20, 2020

(Dec 17, 2020 03:55 AM)HFDone Wrote:  more like vb6 and C mix
my compiler
3k exe
5k dll

What lang. compiler? Still purebasic?


RE: PureBasic Examples & Discussion - HFDone - Dec 20, 2020

PureBasic
use compiler options to reduce size


RE: PureBasic Examples & Discussion - 0x0000005 - Dec 21, 2020

(Dec 20, 2020 08:41 AM)HFDone Wrote:  PureBasic
use compiler options to reduce size

Did you modify the compiler in any way, or just using command-line switches?

I'd like to see those settings. :D

I'm currently using PB 5.31 mostly, but have other versions installed simultaneously.


RE: PureBasic Examples & Discussion - lynakouba - Feb 21, 2022

heyyy is use purebasic since years !
I really don't understand why it has not a greater community
it deserves to be known by more people and get more support
you can do almost everything without any bs dependecies