Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spriggsy's API Collection
#1
Brought back my API collection to GitHub.

Quote:REST, HTTP, HTTPS API using CURLurlmon_OPENCONNECTION (Windows)

Address Validation API (smartystreets.com)
Currency Exchange Rate API (exchangerate-api.com)
Profanity Check/Censor API (purgomalum.com)
Phone Number Verification API (apilayer.com)
Insult Generator API (evilinsult.com)
Sentiment API (sentimapi)
Breaking News API (newsapi.org)
Kitten Image Replacer API (placekitten)
Image from Hash API (robohash)
Screenshot of Webpage API (screenshotlayer.com)
NASA Astronomy Pic of the Day API (nasa.gov) Updated 08/20/2020 Updated with source I had posted elsewhere. Much more efficient code.
DCUO Census API (daybreakcensus)
Online Movie Database API (omdb) Updated 10/18/2020 (Using Wininet WinAPI for internet connectivity)
Lyrics API (lyrics.ovh)
Weather API using GeoLocation from IP Address (various API vendors) Added 08/18/20 since it was missing from collection
Owlbot Dictionary API Added 08/19/2020
Genderize API Added 09/20/2020
QR Tag API Added 09/20/2020
Gravatar Image from email address hash API (gravatar, wordpress) Updated 10/18/2020 (Using Wininet WinAPI for internet connectivity)


WinAPI Libraries (Windows)
UuidCreateUuidCreateSequentialUuidHash (rpcrt4Wininet) UUID Creation and MAC Address Lookup (uuidtools and macvendors.com) Updated 10/17/2020
SHFileOperation (Shell32Added 09/22/2020
GetComputerNameGetUsername (Kernel32 Advapi32Added 09/22/2020
FindExecutableA (Shell32Added 09/26/2020
ShellAboutA (Shell32Added 09/26/2020
mciSendStringA (WINMM) Record and playback audio (updated source with ffmpeg waveform drawing.) Added 09/26/2020
DoEnvironmentSubstAGetEnvironmentVariableAExpandEnvironmentStringsA (Shell32) (Works similarly to ENVIRON$ but with some extra functionality and speed. Added 09/26/2020
ExractIconDrawIcon (Shell32 User32Added 09/27/2020
SetWindowPosGetForegroundWindow (User32) Credit to Pete and visionmercer, original post here Added 09/27/2020
AnimateWindow (User32Added 09/30/2020
FlashWindow/FlashWindowEx (User32Added 10/02/2020
capCreateCaptureWindow (Avicap32) Records webcam footage to AVI file Added 10/02/2020
OpenProcessTerminateProcess (Kernel32) Kill process by name or PID Added 10/05/2020
MessageBeep (User32) Plays WAV audio for common message sounds Added 10/05/2020
OpenClipboardGetClipboardData (User32Added 10/07/2020
GetBinaryType (Kernel32Added 10/09/2020
GetTempPathGetTempFileName (Kernel32Added 10/09/2020
GetDateFormatGetCurrencyFormat (Kernel32Added 10/09/2020
OpenProcessReadProcessMemoryWriteProcessMemory (Kernel32Complete rewrite 02/17/21 (Peeping Tom, a powerful PEEK/POKE library for QB64)
XInputGetStateXInputSetStateXInputGetBatteryInformation (Xinput1_4) Tests an XInput enabled controller Added 10/26/2020
(Wininet) Various Wininet FTP functions for uploading, downloading, directory listing, etc. Added 11/17/2020
SHOpenWithDialog (Shell32) Invokes the "Open With" dialog in Windows Added 02/06/2021


Cross-Platform Libraries (Windows, Macintosh, and Linux)
pipecom $INCLUDE file that pipes console output to QB64. Win (using WinAPI), Mac, and Linux (using C libraries).Added 02/12/2021
encodeBase64decodeBase64 (Crypt32base64 (Linux and Mac)Added 11/05/2020
mapvargetmappedvalue (mappedvar) Header file that creates variables mapped to strings. Added 12/20/2020
(preproc) Header file that allows for usage of multiple preprocessor macros available to us in C++. Added 12/23/2020


Miscellaneous APIs / Libraries
hid_readhid_write (hidapi) Provides HID access to devices over Bluetooth and USB connection (Windows) Test source for interfacing with Nintendo Switch Pro Controller over Bluetooth HID. Added 12/07/2020.



spriggsyspriggs/Spriggsy-s-API-Collection: Spriggsy's API Collection


Originally posted here:
Spriggsy's API Collection
Tread on those who tread on you

Reply
#2
Quality stuff!

I'm going to check this weekend if I have one of your recycle bin api utilities on one of my drives.

+2 for re-upping these goodies.

Pete
Reply
#3
That sounds familiar, Pete. I think you and I talked about that a while back.
Tread on those who tread on you

Reply
#4
Sweet! Thanks for bringing the repo back @SpriggsySpriggs

Glad YOU seem to be back too?
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply
#5
Spriggsy, you are a genius!

I found it, and it worked as advertised, to recycle a file. What I did not try is the bin info and the empty bin functions.

I forgot that the routines also do copy and rename.

Anyway, for those who are interested, here is the code Spriggsy put together...

Code: (Select All)
'$CONSOLE:ONLY
'_DEST _CONSOLE

'To - From, From - To Flags
CONST FO_MOVE = &H1
CONST FO_COPY = &H2
CONST FO_DELETE = &H3
CONST FO_RENAME = &H4

'File Op Flags
CONST FOF_MULTIDESTFILES = &H1
CONST FOF_CONFIRMMOUSE = &H2
CONST FOF_SILENT = &H4
CONST FOF_RENAMEONCOLLISION = &H8
CONST FOF_NOCONFIRMATION = &H10
CONST FOF_WANTMAPPINGHANDLE = &H20
CONST FOF_ALLOWUNDO = &H40
CONST FOF_FILESONLY = &H80
CONST FOF_SIMPLEPROGRESS = &H100
CONST FOF_NOCONFIRMMKDIR = &H200
CONST FOF_NOERRORUI = &H400
CONST FOF_NOCOPYSECURITYATTRIBS = &H800
CONST FOF_NORECURSION = &H1000
CONST FOF_NO_CONNECTED_ELEMENTS = &H2000
CONST FOF_WANTNUKEWARNING = &H4000
CONST FOF_NORECURSEREPARSE = &H8000
CONST FOF_NO_UI = FOF_SILENT

'Return Values
CONST DE_SAMEFILE = &H71
CONST DE_MANYSRC1DEST = &H72
CONST DE_DIFFDIR = &H73
CONST DE_ROOTDIR = &H74
CONST DE_OPCANCELLED = &H75
CONST DE_DESTSUBTREE = &H76
CONST DE_ACCESSDENIEDSRC = &H78
CONST DE_PATHTOODEEP = &H79
CONST DE_MANYDEST = &H7A
CONST DE_INVALIDFILES = &H7C
CONST DE_DESTSAMETREE = &H7D
CONST DE_FLDDESTISFILE = &H7E
CONST DE_FILEDESTISFLD = &H80
CONST DE_FILENAMETOOLONG = &H81
CONST DE_DEST_IS_CDROM = &H82
CONST DE_DEST_IS_DVD = &H83
CONST DE_DEST_IS_CDRECORD = &H84
CONST DE_FILE_TOO_LARGE = &H85
CONST DE_SRC_IS_CDROM = &H86
CONST DE_SRC_IS_DVD = &H87
CONST DE_SRC_IS_CDRECORD = &H88
CONST DE_ERROR_MAX = &HB7
CONST UNKNOWN = &H402
CONST ERRORONDEST = &H10000
CONST DE_ROOTDIR_ERRORONDEST = &H10074

TYPE SHFILEOPSTRUCTA
    hwnd AS _OFFSET
    $IF 64BIT THEN
        wfunc AS _UNSIGNED _INTEGER64 'To - From, From - To Flags
    $ELSE
    wfunc AS _UNSIGNED LONG
    $END IF
    pFrom AS _OFFSET
    pTo AS _OFFSET
    fFlags AS LONG
    fAnyOperationsAborted AS _BYTE
    hNameMappings AS _OFFSET
    lpszProgressTitle AS _OFFSET
END TYPE

TYPE SHQUERYRBINFO
    $IF 64BIT THEN
        cbsize AS _INTEGER64
        i64Size AS _INTEGER64
        i64NumItems AS _INTEGER64
    $ELSE
    cbsize AS LONG
    i64Size AS _INTEGER64
    i64NumItems AS _INTEGER64
    $END IF
END TYPE

DECLARE DYNAMIC LIBRARY "Shell32"
    FUNCTION FileOperation% ALIAS SHFileOperationA (lpFileOp AS SHFILEOPSTRUCTA)
    FUNCTION EmptyRecycleBin% ALIAS SHEmptyRecycleBinA (BYVAL hwnd AS LONG, BYVAL pszRootPath AS _OFFSET, BYVAL dwFlags AS LONG)
    FUNCTION QueryRecycleBin~& ALIAS SHQueryRecycleBinA (pszRootPath AS STRING, pSHQueryRBInfo AS SHQUERYRBINFO)
END DECLARE

'Test code
IF _FILEEXISTS(_DIR$("desktop") + "this is a test.txt") = 0 THEN
    OPEN _DIR$("desktop") + "this is a test.txt" FOR OUTPUT AS #1
    CLOSE #1
END IF
PRINT Copy(_DIR$("desktop") + "this is a test.txt", _DIR$("desktop") + "this is a test as well.txt")
_DELAY 2
PRINT Rename(_DIR$("desktop") + "this is a test as well.txt", _DIR$("desktop") + "this is a test also.txt")
_DELAY 2
PRINT Recycle(_DIR$("desktop") + "this is a test also.txt")
_DELAY 2
PRINT GetRecycleInfo
_DELAY 2
PRINT EmptyBin


FUNCTION GetRecycleInfo$
    DIM RecycleInfo AS SHQUERYRBINFO
    DIM path AS STRING
    DIM a~&
    path = "" + CHR$(0)
    RecycleInfo.cbsize = LEN(RecycleInfo)
    a~& = QueryRecycleBin(path, RecycleInfo)
    GetRecycleInfo = _TRIM$(STR$(RecycleInfo.i64Size)) + " " + _TRIM$(STR$(RecycleInfo.i64NumItems))
END FUNCTION

FUNCTION Recycle% (file AS STRING)
    DIM lpFileOp AS SHFILEOPSTRUCTA
    DIM doublenull AS STRING
    doublenull = CHR$(0) + CHR$(0)
    file = file + doublenull
    lpFileOp.hwnd = _WINDOWHANDLE
    lpFileOp.wfunc = FO_DELETE
    lpFileOp.pFrom = _OFFSET(file)
    lpFileOp.fFlags = FOF_ALLOWUNDO + FOF_WANTNUKEWARNING
    Recycle = FileOperation(lpFileOp)
END FUNCTION

FUNCTION Copy% (file AS STRING, dest AS STRING)
    DIM lpFileOp AS SHFILEOPSTRUCTA
    DIM doublenull AS STRING
    doublenull = CHR$(0) + CHR$(0)
    file = file + doublenull
    dest = dest + doublenull
    lpFileOp.hwnd = _WINDOWHANDLE
    lpFileOp.wfunc = FO_COPY
    lpFileOp.pFrom = _OFFSET(file)
    lpFileOp.pTo = _OFFSET(dest)
    lpFileOp.fFlags = FOF_ALLOWUNDO
    Copy = FileOperation(lpFileOp)
END FUNCTION

FUNCTION Move% (file AS STRING, dest AS STRING)
    DIM lpFileOp AS SHFILEOPSTRUCTA
    DIM doublenull AS STRING
    doublenull = CHR$(0) + CHR$(0)
    file = file + doublenull
    dest = dest + doublenull
    lpFileOp.hwnd = _WINDOWHANDLE
    lpFileOp.wfunc = FO_MOVE
    lpFileOp.pFrom = _OFFSET(file)
    lpFileOp.pTo = _OFFSET(dest)
    lpFileOp.fFlags = FOF_ALLOWUNDO
    Move = FileOperation(lpFileOp)
END FUNCTION

FUNCTION Rename% (file AS STRING, newname AS STRING)
    DIM lpFileOp AS SHFILEOPSTRUCTA
    DIM doublenull AS STRING
    doublenull = CHR$(0) + CHR$(0)
    file = file + doublenull
    newname = newname + doublenull
    lpFileOp.hwnd = _WINDOWHANDLE
    lpFileOp.wfunc = FO_RENAME
    lpFileOp.pFrom = _OFFSET(file)
    lpFileOp.pTo = _OFFSET(newname)
    lpFileOp.fFlags = FOF_ALLOWUNDO
    Rename = FileOperation(lpFileOp)
END FUNCTION

FUNCTION EmptyBin%
    DIM drive AS STRING
    drive = ""
    EmptyBin = EmptyRecycleBin(0, _OFFSET(drive), 0)
END FUNCTION

So what I did was modified it to use my own folder, instead of the desktop...

Code: (Select All)
Print "Press any key to start...": Sleep
'Test code
If _FileExists("c:\temporary\" + "this is a test.txt") = 0 Then
    Open ("c:\temporary\" + "this is a test.txt") For Output As #1
    Close #1
End If
Print Copy("c:\temporary\" + "this is a test.txt", "c:\temporary\" + "this is a test as well.txt")
Print "A copy was made. Ready to rename the copy?": Sleep
Print Rename("c:\temporary\" + "this is a test as well.txt", "c:\temporary\" + "this is a test also.txt")
Print "Ready to recycle?": Sleep
Print Recycle("c:\temporary\" + "this is a test also.txt")

So another +2 for you!

Pete
Reply
#6
Oof! I can definitely tell that is some old code lol. I need to rewrite that code!

(12-15-2024, 12:10 PM)grymmjack Wrote: Sweet! Thanks for bringing the repo back @SpriggsySpriggs

Glad YOU seem to be back too?

I mostly brought it back for one specific user. And I got tired of hunting stuff down in my zip folder so I just went ahead and made it a public repo again so I don't have to do that.
Tread on those who tread on you

Reply
#7
(12-13-2024, 07:38 PM)SpriggsySpriggs Wrote: Brought back my API collection to GitHub.
...
spriggsyspriggs/Spriggsy-s-API-Collection: Spriggsy's API Collection
...

Thanks Spriggsy! These help make the impossible possible.

I wonder, do we have a resident Linux or Mac expert that can figure out the equivalents for those platforms, to help make this cross-platform?
Reply
#8
I have no idea if we've got a Linux expert. I know Luke is really good at Linux. He made a video player in QB64 using it.
Tread on those who tread on you

Reply
#9
It turns out I'll need to go through these things to make them v4.0 compatible. Sad
Tread on those who tread on you

Reply




Users browsing this thread: 1 Guest(s)