Author Topic: Base64 Encoding/Decoding with Windows, Mac, and Linux  (Read 5740 times)

0 Members and 1 Guest are viewing this topic.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Base64 Encoding/Decoding with Windows, Mac, and Linux
« on: November 05, 2020, 10:55:21 am »
Below is code that uses the WinAPI Crypt32 DLL to encode and decode strings (which is also now in my API collection). Also, there is code for using the built-in base64 command from Mac and Linux which will use my pipecom library attached below. I have some code in the $IF block that uses a built-in certutil command in Windows with my pipecom library should you wish to use that rather than WinAPI (you shouldn't). I know that as soon as I post this code someone will either link or post code written entirely in QB64 that encodes and decodes text using the base64 algorithm. I am aware there is a way to do that. I also do not care. This is just to show another way.

Code: QB64: [Select]
  1.  
  2. DIM encode AS STRING
  3. encode = encodeBase64("My name is Inigo Montoya")
  4.  
  5. PRINT encode
  6.  
  7. DIM decode AS STRING
  8. decode = decodeBase64(encode)
  9.  
  10. PRINT decode
  11. $IF WIN THEN
  12.     'DECLARE LIBRARY ".\pipecom"
  13.     '    FUNCTION pipecom$ (cmd AS STRING)
  14.     'END DECLARE
  15.     'FUNCTION encodeBase64$ (encode AS STRING)
  16.     '    DIM encoded AS STRING
  17.     '    DIM encodefile AS INTEGER
  18.     '    encodefile = FREEFILE
  19.     '    OPEN "3nc0deb64" FOR OUTPUT AS #encodefile
  20.     '    PRINT #encodefile, encode
  21.     '    CLOSE #encodefile
  22.     '    encoded = pipecom("certutil -encode 3nc0deb64 3nc0dedb64 && type 3nc0dedb64 && del 3nc0dedb64 && del 3nc0deb64")
  23.     '    encoded = MID$(encoded, INSTR(encoded, "-----BEGIN CERTIFICATE-----") + LEN("-----BEGIN CERTIFICATE-----") + 1)
  24.     '    encoded = MID$(encoded, 1, INSTR(encoded, "-----END CERTIFICATE-----") - 2)
  25.     '    encodeBase64 = encoded
  26.     'END FUNCTION
  27.  
  28.     'FUNCTION decodeBase64$ (decode AS STRING)
  29.     '    DIM decoded AS STRING
  30.     '    DIM decodefile AS INTEGER
  31.     '    decodefile = FREEFILE
  32.     '    OPEN "d3c0deb64" FOR OUTPUT AS #decodefile
  33.     '    PRINT #decodefile, decode
  34.     '    CLOSE #decodefile
  35.     '    decoded = pipecom("certutil -decode d3c0deb64 d3c0dedb64 && type d3c0dedb64 && del d3c0deb64 && del d3c0dedb64")
  36.     '    decoded = MID$(decoded, _INSTRREV(decoded, "successfully.") + 1 + LEN("successfully."))
  37.     '    decoded = MID$(decoded, 1, LEN(decoded) - 1)
  38.     '    decodeBase64 = decoded
  39.     'END FUNCTION
  40.  
  41.     DECLARE DYNAMIC LIBRARY "Crypt32"
  42.         FUNCTION CryptBinaryToString%% ALIAS CryptBinaryToStringA (BYVAL pbBinary AS _OFFSET, BYVAL cbBinary AS LONG, BYVAL dwFlags AS LONG, BYVAL pszString AS _OFFSET, BYVAL pcchString AS _OFFSET)
  43.         FUNCTION CryptStringToBinary%% ALIAS CryptStringToBinaryA (BYVAL pszString AS _OFFSET, BYVAL cchString AS LONG, BYVAL dwFlags AS LONG, BYVAL pbBinary AS _OFFSET, BYVAL pcbBinary AS _OFFSET, BYVAL pdwSkip AS _OFFSET, BYVAL pdwFlags AS _OFFSET)
  44.     END DECLARE
  45.  
  46.     FUNCTION encodeBase64$ (encode AS STRING)
  47.         CONST CRYPT_STRING_NOCRLF = &H40000000
  48.         CONST CRYPT_STRING_BASE64 = &H00000001
  49.  
  50.         DIM a AS _BYTE
  51.         DIM lengthencode AS LONG
  52.         DIM encoded AS STRING
  53.         DIM lengthencoded AS LONG
  54.  
  55.         encode = encode + CHR$(0)
  56.         lengthencode = LEN(encode)
  57.  
  58.         a = CryptBinaryToString(_OFFSET(encode), lengthencode, CRYPT_STRING_BASE64 OR CRYPT_STRING_NOCRLF, 0, _OFFSET(lengthencoded))
  59.         'Calculate buffer length
  60.         IF a <> 0 THEN
  61.             encoded = SPACE$(lengthencoded)
  62.         ELSE
  63.             encodeBase64 = ""
  64.             EXIT FUNCTION
  65.         END IF
  66.         a = CryptBinaryToString(_OFFSET(encode), lengthencode, CRYPT_STRING_BASE64 OR CRYPT_STRING_NOCRLF, _OFFSET(encoded), _OFFSET(lengthencoded))
  67.         'Acual conversion
  68.         IF a <> 0 THEN
  69.             encodeBase64 = encoded
  70.         ELSE
  71.             encodeBase64 = ""
  72.         END IF
  73.  
  74.     FUNCTION decodeBase64$ (decode AS STRING)
  75.         CONST CRYPT_STRING_BASE64_ANY = &H00000006
  76.  
  77.         DIM a AS _BYTE
  78.         DIM lengthdecode AS LONG
  79.         DIM decoded AS STRING
  80.         DIM lengthdecoded AS LONG
  81.  
  82.         decode = decode + CHR$(0)
  83.         lengthdecode = LEN(decode) - 1
  84.         a = CryptStringToBinary(_OFFSET(decode), lengthdecode, CRYPT_STRING_BASE64_ANY, 0, _OFFSET(lengthdecoded), 0, 0)
  85.         'Calculate buffer length
  86.         IF a <> 0 THEN
  87.             decoded = SPACE$(lengthdecoded)
  88.         ELSE
  89.             decodeBase64 = ""
  90.             EXIT FUNCTION
  91.         END IF
  92.         a = CryptStringToBinary(_OFFSET(decode), lengthdecode, CRYPT_STRING_BASE64_ANY, _OFFSET(decoded), _OFFSET(lengthdecoded), 0, 0)
  93.         'Actual conversion
  94.         IF a <> 0 THEN
  95.             decodeBase64 = decoded
  96.         ELSE
  97.             decodeBase64 = ""
  98.         END IF
  99.     DECLARE LIBRARY "./pipecom"
  100.     FUNCTION pipecom$ (cmd AS STRING)
  101.     END DECLARE
  102.  
  103.     FUNCTION encodeBase64$ (encode AS STRING)
  104.     DIM encoded AS STRING
  105.     DIM encodefile AS INTEGER
  106.     encodefile = FREEFILE
  107.     OPEN "3nc0deb64" FOR OUTPUT AS #encodefile
  108.     PRINT #encodefile, encode
  109.     CLOSE #encodefile
  110.     encoded = pipecom("base64 3nc0deb64")
  111.     KILL "3nc0deb64"
  112.     encodeBase64 = MID$(encoded, 1, LEN(encoded) - 1)
  113.  
  114.     FUNCTION decodeBase64$ (decode AS STRING)
  115.     DIM decoded AS STRING
  116.     DIM decodefile AS INTEGER
  117.     decodefile = FREEFILE
  118.     OPEN "d3c0deb64" FOR OUTPUT AS #decodefile
  119.     PRINT #decodefile, decode
  120.     CLOSE #decodefile
  121.     decoded = pipecom("base64 -d d3c0deb64")
  122.     KILL "d3c0deb64"
  123.     decodeBase64 = decoded
* pipecom.h (Filesize: 2.54 KB, Downloads: 161)
« Last Edit: November 05, 2020, 12:53:47 pm by SpriggsySpriggs »
Shuwatch!

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #1 on: November 05, 2020, 11:11:52 am »
Cool. You're really on a roll with the API stuff.  I appreciate your efforts. 

- Dav

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #2 on: November 05, 2020, 11:15:19 am »
Cool. You're really on a roll with the API stuff.  I appreciate your efforts. 

- Dav
@Dav Thanks! Yeah, when I get itchin' on a particular subject I've been checking to see if WinAPI has something for it and if Mac and Linux have an alternative. I'm trying to make my API collection contain a balance of Windows & Mac/Linux.
Shuwatch!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #3 on: November 05, 2020, 11:49:17 am »
Nice and useful thing, SpriggsySpriggs. I want to ask you - I don't know exactly how to describe it - is there any way to use API calls to pull dialogs, which use scrollbars and check boxes from Windows? Is it possible to create a sliding window using windows libraries? There are already ways to call the open / save dialog in the wiki, as well as how to call the message box. I think this would also be very useful.

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #4 on: November 05, 2020, 11:59:36 am »
@Petr I'm not sure what you mean by sliding windows but as for the dialogs with check boxes; that is only available in Windows Vista using the WinAPI :(
Shuwatch!

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #5 on: November 05, 2020, 12:04:02 pm »
I have some API code that mcaulkins made that goes into that area.  Had radio buttons, scroll bar, edit box I think.  I'll try to dig it up.

- Dav

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #6 on: November 05, 2020, 12:06:23 pm »
I have some API code that mcaulkins made that goes into that area.  Had radio buttons, scroll bar, edit box I think.  I'll try to dig it up.

- Dav
@Dav Excited to see it!
Shuwatch!

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #7 on: November 05, 2020, 12:16:35 pm »
I also want to dig up something he made that sends a program to the system tray area of the task bar.  Looking for them now...

- Dav

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #8 on: November 05, 2020, 12:40:26 pm »
Perfect. I'm also looking forward :)

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #9 on: November 05, 2020, 12:54:02 pm »
Here's the GUI he made that makes buttons, scroll bar and edit area using API.   It uses an .h file to get WindowProc.  Still looking for the system tray code.  Maybe @Pete would have some snippets like these too - they came off the old qbasic forum.  This is old code by the way, QB64 has come a long way since.

- Dav

Save as win.h
Quote
ptrszint FUNC_WINDOWPROC(ptrszint*_FUNC_WINDOWPROC_OFFSET_HWND,uint32*_FUNC_WINDOWPROC_ULONG_UMSG,uptrszint*_FUNC_WINDOWPROC_UOFFSET_WPARAM,ptrszint*_FUNC_WINDOWPROC_OFFSET_LPARAM);

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
 return FUNC_WINDOWPROC((ptrszint *) (& hwnd), & uMsg, & wParam, (ptrszint *) (& lParam));
}

void * GetWindowProc() {
 return (void *) WindowProc;

QB64 Code....
Code: QB64: [Select]
  1. 'DEFSTR A-Z
  2.  
  3. ' public domain, michael calkins
  4. ' revision 2012 09 12
  5. ' very much experimental. I am a noob at GUI stuff, and might be doing multiple things wrong or in unideal ways.
  6. ' rough translation of:
  7. ' http://www.network54.com/Forum/613583/message/1347419042/
  8. ' with a few liberties taken.
  9.  
  10. ' not only might I be doing things wrong, but I am also not doublechecking the function declarations, type definitions, and constant values. They could be wrong.
  11.  
  12.  
  13. ' get more constants from winuser.h as needed.
  14.  
  15. CONST IDC_ARROW = &H7F00
  16. CONST COLOR_WINDOW = 5
  17.  
  18. CONST WS_OVERLAPPED = 0
  19. CONST WS_CHILD = &H40000000
  20. CONST WS_VISIBLE = &H10000000
  21. CONST WS_MAXIMIZE = &H01000000
  22. CONST WS_CAPTION = &H00C00000
  23. CONST WS_VSCROLL = &H00200000
  24. CONST WS_HSCROLL = &H00100000
  25. CONST WS_SYSMENU = &H00080000
  26. CONST WS_THICKFRAME = &H00040000
  27. CONST WS_TABSTOP = &H00010000
  28. CONST WS_MINIMIZEBOX = &H00020000
  29. CONST WS_MAXIMIZEBOX = &H00010000
  30. CONST WS_OVERLAPPEDWINDOW = WS_OVERLAPPED OR WS_CAPTION OR WS_SYSMENU OR WS_THICKFRAME OR WS_MINIMIZEBOX OR WS_MAXIMIZEBOX
  31.  
  32. CONST CW_USEDEFAULT = &H80000000&
  33.  
  34. CONST BS_PUSHBUTTON = 0
  35. CONST BS_AUTOCHECKBOX = 3
  36. CONST BS_GROUPBOX = 7
  37. CONST BS_AUTORADIOBUTTON = 9
  38. CONST BS_TEXT = 0
  39.  
  40. CONST BN_CLICKED = 0
  41.  
  42. CONST BM_GETCHECK = &HF0
  43.  
  44. CONST ES_LEFT = 0
  45. CONST ES_MULTILINE = 4
  46. CONST ES_AUTOVSCROLL = &H0040
  47. CONST ES_AUTOHSCROLL = &H0080
  48. CONST ES_WANTRETURN = &H1000
  49.  
  50. CONST WM_DESTROY = 2
  51. CONST WM_GETTEXT = &H000D
  52. CONST WM_CLOSE = &H0010
  53. CONST WM_COMMAND = &H0111
  54.  
  55. CONST SW_SHOWDEFAULT = &HA
  56.  
  57.     FUNCTION GetWindowProc%& ()
  58.  
  59.     FUNCTION SendMessageA%& (BYVAL hWnd%&, BYVAL Msg~&, BYVAL wParam~%&, BYVAL lParam%&)
  60.     FUNCTION DefWindowProcA%& (BYVAL hWnd%&, BYVAL Msg~&, BYVAL wParam~%&, BYVAL lParam%&)
  61.     SUB PostQuitMessage (BYVAL nExitCode&)
  62.     FUNCTION LoadCursorW%& (BYVAL hInstance%&, BYVAL lpCursorName%&)
  63.     FUNCTION RegisterClassA~% (BYVAL lpWndClass%&)
  64.     FUNCTION CreateWindowExA%& (BYVAL dwExStyle~&, BYVAL lpClassName%&, BYVAL lpWindowName%&, BYVAL dwStyle~&, BYVAL x&, BYVAL y&, BYVAL nWidth&, BYVAL nHeight&, BYVAL hWndParent%&, BYVAL hMenu%&, BYVAL hInstance%&, BYVAL lpParam%&)
  65.     FUNCTION ShowWindow& (BYVAL hWnd%&, BYVAL nCmdShow&)
  66.     FUNCTION UpdateWindow& (BYVAL hWnd%&)
  67.     FUNCTION GetMessageA& (BYVAL lpMsg%&, BYVAL hWnd%&, BYVAL wMsgFilterMin~&, BYVAL wMsgFilterMax~&)
  68.     FUNCTION TranslateMessage& (BYVAL lpMsg%&)
  69.     FUNCTION DispatchMessageA%& (BYVAL lpmsg%&)
  70.  
  71.     FUNCTION GetModuleHandleW%& (BYVAL lpModuleName%&)
  72.     FUNCTION GetLastError~& ()
  73.  
  74.     x AS LONG
  75.     y AS LONG
  76.  
  77. TYPE MSG
  78.     hwnd AS _OFFSET
  79.     message AS _UNSIGNED LONG
  80.     wParam AS _UNSIGNED _OFFSET 'unsigned pointer sized integer
  81.     lParam AS _OFFSET 'pointer sized integer
  82.     time AS _UNSIGNED LONG
  83.     pt AS POINT
  84.  
  85. TYPE WNDCLASSA
  86.     style AS _UNSIGNED LONG
  87.     lpfnWndProc AS _OFFSET
  88.     cbClsExtra AS LONG
  89.     cbWndExtra AS LONG
  90.     hInstance AS _OFFSET
  91.     hIcon AS _OFFSET
  92.     hCursor AS _OFFSET
  93.     hbrBackground AS _OFFSET
  94.     lpszMenuName AS _OFFSET
  95.     lpszClassName AS _OFFSET
  96.  
  97. DIM SHARED wc AS WNDCLASSA
  98. DIM SHARED msg AS MSG
  99.  
  100. DIM SHARED buf AS STRING * 4096
  101.  
  102. DIM SHARED discardb AS LONG
  103. DIM SHARED discardp AS _OFFSET
  104.  
  105. DIM SHARED MainClassName AS STRING * 5
  106. MainClassName = "main" + CHR$(0)
  107. DIM SHARED crlf AS STRING * 2
  108. crlf = MKI$(&HA0D)
  109.  
  110. hi = GetModuleHandleW(0)
  111.  
  112. wc.style = 0
  113. wc.lpfnWndProc = GetWindowProc
  114. wc.cbClsExtra = 0
  115. wc.cbWndExtra = 0
  116. wc.hInstance = hi
  117. wc.hIcon = 0
  118. wc.hCursor = LoadCursorW(0, IDC_ARROW)
  119. wc.hbrBackground = COLOR_WINDOW + 1
  120. wc.lpszMenuName = 0
  121. wc.lpszClassName = _OFFSET(MainClassName)
  122.  
  123. at = RegisterClassA(_OFFSET(wc)): IF 0 = at THEN SYSTEM
  124.  
  125. t1 = "title" + CHR$(0)
  126. hw = CreateWindowExA(0, at AND &HFFFF~&, _OFFSET(t1), WS_HSCROLL OR WS_OVERLAPPEDWINDOW OR WS_VSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hi, 0): IF 0 = hw THEN SYSTEM
  127. t0 = "BUTTON" + CHR$(0)
  128. t1 = "Button 0" + CHR$(0)
  129. hwb0 = CreateWindowExA(0, _OFFSET(t0), _OFFSET(t1), WS_TABSTOP OR WS_VISIBLE OR WS_CHILD OR BS_PUSHBUTTON OR BS_TEXT, 10, 10, 150, 40, hw, 0, hi, 0): IF 0 = hw THEN SYSTEM
  130. t1 = "Button 1" + CHR$(0)
  131. hwb1 = CreateWindowExA(0, _OFFSET(t0), _OFFSET(t1), WS_TABSTOP OR WS_VISIBLE OR WS_CHILD OR BS_PUSHBUTTON OR BS_TEXT, 10, 60, 150, 40, hw, 0, hi, 0): IF 0 = hwb0 THEN SYSTEM
  132. t1 = "Chk box" + CHR$(0)
  133. hwcb = CreateWindowExA(0, _OFFSET(t0), _OFFSET(t1), WS_TABSTOP OR WS_VISIBLE OR WS_CHILD OR BS_AUTOCHECKBOX OR BS_TEXT, 10, 110, 150, 40, hw, 0, hi, 0): IF 0 = hwb1 THEN SYSTEM
  134. t1 = "Group box" + CHR$(0)
  135. hwgb = CreateWindowExA(0, _OFFSET(t0), _OFFSET(t1), WS_VISIBLE OR WS_CHILD OR BS_GROUPBOX OR BS_TEXT, 10, 160, 400, 80, hw, 0, hi, 0): IF 0 = hwgb THEN SYSTEM
  136. t1 = "Radio 0" + CHR$(0)
  137. hwr0 = CreateWindowExA(0, _OFFSET(t0), _OFFSET(t1), WS_TABSTOP OR WS_VISIBLE OR WS_CHILD OR BS_AUTORADIOBUTTON OR BS_TEXT, 10, 30, 150, 30, hwgb, 0, hi, 0): IF 0 = hwr0 THEN SYSTEM
  138. t1 = "Radio 1" + CHR$(0)
  139. hwr1 = CreateWindowExA(0, _OFFSET(t0), _OFFSET(t1), WS_TABSTOP OR WS_VISIBLE OR WS_CHILD OR BS_AUTORADIOBUTTON OR BS_TEXT, 210, 30, 150, 30, hwgb, 0, hi, 0): IF 0 = hwr1 THEN SYSTEM
  140. t0 = "EDIT" + CHR$(0)
  141. t1 = "This is a" + crlf + "multiline edit control." + crlf + "Click in me and type." + crlf + "It should scroll automatically in both directions, but there aren't any scroll bars." + crlf + "Close the window to see the text printed to the console." + CHR$(0)
  142. hwe = CreateWindowExA(0, _OFFSET(t0), _OFFSET(t1), WS_TABSTOP OR WS_VISIBLE OR WS_CHILD OR ES_AUTOHSCROLL OR ES_AUTOVSCROLL OR ES_LEFT OR ES_MULTILINE OR ES_WANTRETURN, 10, 300, 400, 200, hw, 0, hi, 0): IF 0 = hwe THEN SYSTEM
  143.  
  144. discardb = ShowWindow(hw, SW_SHOWDEFAULT)
  145. discardb = UpdateWindow(hw)
  146.     bRet = GetMessageA(_OFFSET(msg), 0, 0, 0)
  147.     SELECT CASE bRet
  148.         CASE 0, -1: EXIT DO
  149.     END SELECT
  150.     discardb = TranslateMessage(_OFFSET(msg))
  151.     discardp = DispatchMessageA(_OFFSET(msg))
  152.  
  153. ' Hopefully the user is running this console program from the command prompt.
  154. ' If not, the half second delay should remind them.
  155. ' I think that Sleep is okay here, because I assume we shouldn't be getting any more messages.
  156. ' We're out of the message loop anyway...
  157.  
  158. FUNCTION WindowProc%& (hWnd AS _OFFSET, uMsg AS _UNSIGNED LONG, wParam AS _UNSIGNED _OFFSET, lParam AS _OFFSET)
  159.  
  160.     SELECT CASE uMsg
  161.  
  162.         CASE WM_CLOSE
  163.  
  164.             discardp = SendMessageA(hwe, WM_GETTEXT, LEN(buf), _OFFSET(buf))
  165.             PRINT: PRINT "First part of the edit control text:": PRINT
  166.             PRINT buf: PRINT
  167.             PRINT "Radio 0: 0x"; HEX$(SendMessageA(hwr0, BM_GETCHECK, 0, 0))
  168.             PRINT "Radio 1: 0x"; HEX$(SendMessageA(hwr1, BM_GETCHECK, 0, 0))
  169.  
  170.             WindowProc = DefWindowProcA(hWnd, uMsg, wParam, lParam): EXIT FUNCTION
  171.  
  172.         CASE WM_DESTROY
  173.  
  174.             PostQuitMessage 0
  175.             WindowProc = 0: EXIT FUNCTION
  176.  
  177.         CASE WM_COMMAND
  178.  
  179.             IF wParam \ &H10000 = BN_CLICKED THEN
  180.                 SELECT CASE lParam
  181.                     CASE hwb0: PRINT "Button 0 pressed"
  182.                     CASE hwb1: PRINT "Button 1 pressed"
  183.                     CASE hwcb: PRINT "Check box pressed"
  184.  
  185.                         ' The following two lines are useless, because the Group Box is getting the message, not us.
  186.                     CASE hwr0: PRINT "Radio 0 pressed"
  187.                     CASE hwr1: PRINT "Radio 1 pressed"
  188.                 END SELECT
  189.                 WindowProc = 0: EXIT FUNCTION
  190.             ELSE
  191.                 WindowProc = DefWindowProcA(hWnd, uMsg, wParam, lParam): EXIT FUNCTION
  192.             END IF
  193.  
  194.         CASE ELSE
  195.  
  196.             WindowProc = DefWindowProcA(hWnd, uMsg, wParam, lParam): EXIT FUNCTION
  197.     END SELECT
  198.  
  199.  
« Last Edit: November 05, 2020, 01:01:48 pm by Dav »

Offline SpriggsySpriggs

  • Forum Resident
  • Posts: 1145
  • Larger than life
    • View Profile
    • GitHub
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #10 on: November 05, 2020, 12:58:38 pm »
@Dav You might want to modify the message so that the code you are pasting for the win.h is set for C++ or something that way it doesn't fail compilation. Since RETURN is capitalized it fails. The code seems to work in 32 but not in 64. WOW. It's amazing! I've been trying to get that to work forever but I just never could figure out how to make it work!
« Last Edit: November 05, 2020, 01:00:32 pm by SpriggsySpriggs »
Shuwatch!

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #11 on: November 05, 2020, 01:02:17 pm »
Corrected it.  Thanks.

- Dav

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #12 on: November 05, 2020, 01:04:24 pm »
Michael is very knowledgable programmer. I saved most of the API things he's posted over the years.

EDIT: sorry for the extra post comment  - meant to add this the above one.

- Dav
« Last Edit: November 05, 2020, 01:05:38 pm by Dav »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #13 on: November 05, 2020, 01:25:56 pm »
Perfect work!, Dav, bug in C code! Add } to the end! Thank you for sharing!

FellippeHeitor

  • Guest
Re: Base64 Encoding/Decoding with Windows, Mac, and Linux
« Reply #14 on: November 05, 2020, 01:35:24 pm »
And a pointer to a qb64 function being passed to the API! That's very valuable!