Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

PureBasic Examples & Discussion

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.
more like vb6 and C mix
my compiler
3k exe
5k dll
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(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?
PureBasic
use compiler options to reduce size
[Image: bitcoin.png] Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
(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.
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


Possibly Related Threads...
Thread / Author Replies Views Last Post
by lynakoubaJul 2, 2023 11:11 AM 2 126 Jul 2, 2023 11:11 AM
Last Post: HFDone
[Lua] by N.W.BApr 14, 2020 09:36 AM 1 165 Apr 14, 2020 09:36 AM
Last Post: Charger
[Help] by satryiasis23Jul 13, 2016 06:35 PM 0 157 Jul 13, 2016 06:35 PM
Last Post: satryiasis23