You can call C++ directly but requires a bit more work.
You could always write a parser that reads the headers and generates all this stuff.
Code: Select all
EnableExplicit
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86 And #PB_Compiler_Debugger
  DisableDebugger
CompilerEndIf
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
  
  Macro steam_thiscall(__OBJECT__)
    MOV ecx, __OBJECT__
  EndMacro
  Macro steam_thiscall_var(__OBJECT__)
    !MOV ecx, [p.v_#__OBJECT__]
  EndMacro
  
  Macro steam_thiscall_ptr(__OBJECT__)
    !MOV ecx, [p.p_#__OBJECT__]
  EndMacro
  
CompilerElse
  
  Macro steam_thiscall(__OBJECT__)
  EndMacro
  Macro steam_thiscall_var(__OBJECT__)
  EndMacro
  
  Macro steam_thiscall_ptr(__OBJECT__)
  EndMacro
  
CompilerEndIf
#STEAMCLIENT_INTERFACE_VERSION_012 = "SteamClient012"
#STEAMFRIENDS_INTERFACE_VERSION_013 = "SteamFriends013"
;- ISteamClient012
Interface ISteamClient012
  ; Creates a communication pipe to the Steam client
  CreateSteamPipe()
  
  ; Releases a previously created communications pipe
  BReleaseSteamPipe(hSteamPipe)
  
	; connects To an existing Global user, failing If none exists
	; used by the game To coordinate With the steamUI
	ConnectToGlobalUser(hSteamPipe)
	
	; used by game servers, create a steam user that won't be shared with anyone else
	CreateLocalUser(*phSteamPipe, eAccountType)
	
	; removes an allocated user
	ReleaseUser(hSteamPipe, hUser)
	
	; retrieves the ISteamUser interface associated with the handle
	GetISteamUser(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
	; retrieves the ISteamGameServer interface associated with the handle
	GetISteamGameServer(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
  ; set the local IP And Port To bind To
	; This must be set before CreateLocalUser()
	SetLocalIPBinding(unIP, usPort)
	
	; returns the ISteamFriends interface
	GetISteamFriends(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
	; returns the ISteamUtils interface
	GetISteamUtils(hSteamPipe, pchVersion.p-ascii)
	
	; returns the ISteamMatchmaking interface
	GetISteamMatchmaking(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
	; returns the ISteamMasterServerUpdater interface
	GetISteamMasterServerUpdater(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
	; returns the ISteamMatchmakingServers interface
	GetISteamMatchmakingServers(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
	; returns a generic interface
	GetISteamGenericInterface(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
	; returns the ISteamUserStats interface
	GetISteamUserStats(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
	; returns game server stats interface
	GetISteamGameServerStats(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
	; returns apps interface
	GetISteamApps(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
	; networking
	GetISteamNetworking(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
	; remote storage
	GetISteamRemoteStorage(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
  GetISteamScreenshots(hSteamUser, hSteamPipe, pchVersion.p-ascii)
  
	; This needs To be called every frame To process matchmaking results
	; redundant If you're already calling SteamAPI_RunCallbacks()
	RunFrame()
	
	; returns the number of IPC calls made since the last time This function was called
	; Used For perf debugging so you can understand how many IPC calls your game makes per frame
	; Every IPC call is at minimum a thread context switch If Not a process one so you want To rate
	; control how often you do them.
	GetIPCCallCount()
	
	; API warning handling
	; 'int' is the severity; 0 for msg, 1 for warning
	; 'const char *' is the text of the message
	; callbacks will occur directly after the API function is called that generated the warning Or message
	SetWarningMessageHook(pFunction)
	
	; Trigger global shutdown for the DLL
	BShutdownIfAllPipesClosed()
	
	; Trigger global shutdown for the DLL
	GetISteamHTTP(hSteamUser, hSteamPipe, pchVersion.p-ascii)
	
	GetISteamUnifiedMessages(hSteamUser, hSteamPipe, pchVersion.p-ascii)
EndInterface
;- ISteamFriends013
Interface ISteamFriends013
	; returns the local players name - guaranteed To Not be NULL.
	; This is the same name As on the users community profile page
	; This is stored in UTF-8 format
	; like all the other Interface functions that Return a char *, it's important that this pointer is not saved
	; off; it will eventually be free'd or re-allocated
	GetPersonaName()
	
	; sets the player name, stores it on the server and publishes the changes to all friends who are online
	SetPersonaName(*pchPersonaName)
	
	; gets the status of the current user
	GetPersonaState()
	
  ; friend iteration
	; takes a set of k_EFriendFlags, And returns the number of users the client knows about who meet that criteria
	; then GetFriendByIndex() can then be used To Return the id's of each of those users
	GetFriendCount(iFriendFlags)
	
	; returns the steamID of a user
	; iFriend is a index of range [0, GetFriendCount())
	; iFriendsFlags must be the same value As used in GetFriendCount()
	; the returned CSteamID can then be used by all the functions below To access details about the use
	
	; STEAMWORKS_STRUCT_RETURN_2(CSteamID, GetFriendByIndex, int, iFriend, int, iFriendFlags) /*virtual CSteamID GetFriendByIndex( int iFriend, int iFriendFlags ) = 0;*/
	GetFriendByIndex(iFriend, iFriendFlags)
	
	; returns a relationship to a user
	GetFriendRelationship(steamIDFriend)
	
	; returns the current status of the specified user
	; This will only be known by the local user If steamIDFriend is in their friends List; on the same game server; in a chat room or lobby; or in a small group with the local user
	GetFriendPersonaState(steamIDFriend)
	
	; returns the name another user - guaranteed To Not be NULL.
	; same rules As GetFriendPersonaState() apply As To whether Or Not the user knowns the name of the other user
	; note that on first joining a lobby, chat room Or game server the local user will Not known the name of the other users automatically; that information will arrive asyncronously
	; 
	GetFriendPersonaName(steamIDFriend)
	
	; returns true if the friend is actually in a game, and fills in pFriendGameInfo with an extra details 
	GetFriendGamePlayed(steamIDFriend, *pFriendGameInfo)
	; accesses old friends names - returns an empty string when their are no more items in the history
	GetFriendPersonaNameHistory(steamIDFriend, iPersonaName)
	
	; returns true If the specified user meets any of the criteria specified in iFriendFlags
	; iFriendFlags can be the union (binary Or, |) of one Or more k_EFriendFlags values
	HasFriend(steamIDFriend, iFriendFlags)
	
	; clan (group) iteration and access functions
	GetClanCount()
	
	; STEAMWORKS_STRUCT_RETURN_1(CSteamID, GetClanByIndex, int, iClan) /*virtual CSteamID GetClanByIndex( int iClan ) = 0;*/
  GetClanByIndex(iClan)
  GetClanName(steamIDClan)
  GetClanTag(steamIDClan)
  
	GetClanActivityCounts(steamID, *pnOnline, *pnInGame, *pnChatting)
	DownloadClanActivityCounts(groupIDs, nIds)
	
	; iterators For getting users in a chat room, lobby, game server Or clan
	; note that large clans that cannot be iterated by the local user
	; steamIDSource can be the steamID of a group, game server, lobby Or chat room
	GetFriendCountFromSource(steamIDSource)
	
	; STEAMWORKS_STRUCT_RETURN_2(CSteamID, GetFriendFromSourceByIndex, CSteamID, steamIDSource, int, iFriend) /*virtual CSteamID GetFriendFromSourceByIndex( CSteamID steamIDSource, int iFriend ) = 0;*/
  GetFriendFromSourceByIndex(steamIDSource, iFriend)
  
  ; returns true if the local user can see that steamIDUser is a member or in steamIDSource
  IsUserInSource(steamIDUser, steamIDSource)
  
  ; User is in a game pressing the talk button (will suppress the microphone for all voice comms from the Steam friends UI)
  SetInGameVoiceSpeaking(steamIDUser, bSpeaking.b)
  
	; activates the game overlay, With an optional dialog To open 
	; valid options are "Friends", "Community", "Players", "Settings", "LobbyInvite", "OfficialGameGroup", "Stats", "Achievements"
	ActivateGameOverlay(*pchDialog)
	
	; activates game overlay To a specific place
	; valid options are
	;		"steamid" - opens the overlay web browser To the specified user Or groups profile
	;		"chat" - opens a chat window To the specified user, Or joins the group chat 
	;		"stats" - opens the overlay web browser To the specified user's stats
	;		"achievements" - opens the overlay web browser To the specified user's achievements
	ActivateGameOverlayToUser(*pchDialog, steamID)
	
	; activates game overlay web browser directly To the specified URL
	; full address With protocol type is required, e.g. http://www.steamgames.com/	
	ActivateGameOverlayToWebPage(*pchURL)
	
	; activates game overlay to store page for app
	ActivateGameOverlayToStore(nAppID, eFlag)
	
	; Mark a target user As 'played with'. This is a client-side only feature that requires that the calling user is 
	; in game 
	SetPlayedWith(steamIDUserPlayedWith)
	
	; activates game overlay To open the invite dialog. Invitations will be sent For the provided lobby.
	; You can also use ActivateGameOverlay( "LobbyInvite" ) To allow the user To create invitations For their current Public lobby.	
	ActivateGameOverlayInviteDialog(steamIDLobby)
	
	; gets the small (32x32) avatar of the current user, which is a handle to be used in IClientUtils::GetImageRGBA(), or 0 if none set
	GetSmallFriendAvatar(steamIDFriend)
	
	; gets the medium (64x64) avatar of the current user, which is a handle to be used in IClientUtils::GetImageRGBA(), or 0 if none set
	GetMediumFriendAvatar(steamIDFriend)
	
	; gets the large (184x184) avatar of the current user, which is a handle To be used in IClientUtils::GetImageRGBA(), Or 0 If none set
	; returns -1 If This image has yet To be loaded, in This Case wait For a AvatarImageLoaded_t callback And then call This again
	GetLargeFriendAvatar(steamIDFriend)
	
	; requests information about a user - persona name & avatar
	; If bRequireNameOnly is set, then the avatar of a user isn't downloaded 
	; - it's a lot slower to download avatars and churns the local cache, so if you don't need avatars, don't request them
	; If returns true, it means that Data is being requested, And a PersonaStateChanged_t callback will be posted when it's retrieved
	; If returns false, it means that we already have all the details about that user, And functions can be called immediately
	RequestUserInformation(steamIDUser, bRequireNameOnly.b)
	
	; requests information about a clan officer List
	; when complete, Data is returned in ClanOfficerListResponse_t call result
	; This makes available the calls below
	; you can only ask about clans that a user is a member of
	; note that This won't download avatars automatically; if you get an officer,
	; And no avatar image is available, call RequestUserInformation( steamID, false ) To download the avatar
	RequestClanOfficerList(steamIDClan)
	; iteration of clan officers - can only be done when a RequestClanOfficerList() call has completed
	
	; returns the steamID of the clan owner
	; STEAMWORKS_STRUCT_RETURN_1(CSteamID, GetClanOwner, CSteamID, steamIDClan) /*virtual CSteamID GetClanOwner( CSteamID steamIDClan ) = 0;*/
	GetClanOwner(steamIDClan)
	
	; returns the number of officers in a clan (including the owner)
	GetClanOfficerCount(steamIDClan)
	
	; returns the steamID of a clan officer, by index, of range [0,GetClanOfficerCount)
	; STEAMWORKS_STRUCT_RETURN_2(CSteamID, GetClanOfficerByIndex, CSteamID, steamIDClan, int, iOfficer) /*virtual CSteamID GetClanOfficerByIndex( CSteamID steamIDClan, int iOfficer ) = 0;*/
	GetClanOfficerByIndex(steamIDClan, iOfficer)
	
	; If current user is chat restricted, he can't send or receive any text/voice chat messages.
	; the user can't see custom avatars. But the user can be online and send/recv game invites.
	; a chat restricted user can't add friends or join any groups.
	GetUserRestrictions()
	
	; Rich Presence Data is automatically Shared between friends who are in the same game
	; Each user has a set of Key/Value pairs
	; Up To 20 different keys can be set
	; There are two magic keys:
	;		"status"  - a UTF-8 string that will show up in the 'view game info' dialog in the Steam friends List
	;		"connect" - a UTF-8 string that contains the command-line For how a friend can connect To a game
	; GetFriendRichPresence() returns an empty string "" If no value is set
	; SetRichPresence() To a NULL Or an empty string deletes the key
	; You can iterate the current set of keys For a friend With GetFriendRichPresenceKeyCount()
	; And GetFriendRichPresenceKeyByIndex() (typically only used For debugging)
	SetRichPresence(*pchKey, *pchValue)
  ClearRichPresence()
  GetFriendRichPresence(steamIDFriend, *pchKey)
  GetFriendRichPresenceKeyCount(steamIDFriend)
  GetFriendRichPresenceKeyByIndex(steamIDFriend, iKey)
  equestFriendRichPresence(steamIDFriend)
  
	; rich invite support
	; If the target accepts the invite, the pchConnectString gets added To the command-line For launching the game
	; If the game is already running, a GameRichPresenceJoinRequested_t callback is posted containing the connect string
	; invites can only be sent To friends
	InviteUserToGame(steamIDFriend, *pchConnectString)
	
	; recently-played-With friends iteration
	; This iterates the entire List of users recently played With, across games
	; GetFriendCoplayTime() returns As a unix time
	GetCoplayFriendCount()
	
	; STEAMWORKS_STRUCT_RETURN_1(CSteamID, GetCoplayFriend, int, iCoplayFriend) /*virtual CSteamID GetCoplayFriend( int iCoplayFriend ) = 0;*/
	GetCoplayFriend(iCoplayFriend)
	
  GetFriendCoplayTime(steamIDFriend)
  GetFriendCoplayGame(steamIDFriend)
  
	; chat Interface For games
	; this allows in-game access To group (clan) chats from in the game
	; the behavior is somewhat sophisticated, because the user may Or may Not be already in the group chat from outside the game Or in the overlay
	; use ActivateGameOverlayToUser( "chat", steamIDClan ) To open the in-game overlay version of the chat
	JoinClanChatRoom(steamIDClan)
	LeaveClanChatRoom(steamIDClan)
	GetClanChatMemberCount(steamIDClan)
	
	;STEAMWORKS_STRUCT_RETURN_2(CSteamID, GetChatMemberByIndex, CSteamID, steamIDClan, int, iUser) /*virtual CSteamID GetChatMemberByIndex( CSteamID steamIDClan, int iUser ) = 0;*/
	GetChatMemberByIndex(steamIDClan, iUser)
	
	SendClanChatMessage(steamIDClanChat, *pchText)
	GetClanChatMessage(steamIDClanChat, iMessage,  *prgchText, cchTextMax, *peChatEntryType,*pSteamIDChatter)
	IsClanChatAdmin(steamIDClanChat, steamIDUser)
	
	; interact With the Steam (game overlay / desktop)
	IsClanChatWindowOpenInSteam(steamIDClanChat)
	OpenClanChatWindowInSteam(steamIDClanChat)
	CloseClanChatWindowInSteam(steamIDClanChat)
	
	; peer-To-peer chat interception
	; this is so you can show P2P chats inline in the game
	SetListenForFriendsMessages(bInterceptEnabled)
	ReplyToFriendMessage(steamIDFriend, *pchMsgToSend)
	GetFriendMessage(steamIDFriend, iMessageID, *pvData, cubData, *peChatEntryType)
	; following apis
	GetFollowerCount(steamID)
	IsFollowing(steamID)
	EnumerateFollowingList(unStartIndex)
EndInterface
;- PROTOTYPES 
PrototypeC.i CreateInterfaceFn(pName.p-ascii, *pReturnCode.LONG)
;- GLOBALS
Global g_steamDir.s
Global g_steamClientFullPath.s
Global steam_CreateInterface.CreateInterfaceFn
Global g_steamclient.ISteamClient012
Procedure.i StringToUnicode(Value.s)
  Protected *buffer
  Protected StringLen.i
  
  StringLen = StringByteLength(Value, #PB_Unicode) + 2
  
  *buffer = AllocateMemory(StringLen)
  If *buffer
    PokeS(*buffer, Value, StringLen, #PB_Unicode)
  EndIf
  
  ProcedureReturn *buffer
EndProcedure
Procedure.i StringToAscii(Value.s)
  Protected *buffer
  
  *buffer = AllocateMemory(Len(Value) + 1)
  If *buffer
    PokeS(*buffer, Value, -1, #PB_Ascii)
  EndIf
  
  ProcedureReturn *buffer
EndProcedure
Procedure.s GetSeamDir(*ErrorCode.LONG=#Null)
  Protected result.s, errorCode.l, hKey.l
  Protected cbData.l
  
  errorCode = RegOpenKeyEx_(#HKEY_LOCAL_MACHINE, "SOFTWARE\Wow6432Node\Valve\Steam", 0, #KEY_QUERY_VALUE, @hKey)
  
  If errorCode = #ERROR_SUCCESS
    errorCode = RegQueryValueEx_(hKey, "InstallPath", 0, 0, 0, @cbData)
    If errorCode = #ERROR_SUCCESS
      result = Space(cbData)
      
      errorCode = RegQueryValueEx_(hKey, "InstallPath", 0, 0, @result, @cbData)
    EndIf
    
    RegCloseKey_(hKey)
  EndIf
  
  If *ErrorCode
    *ErrorCode\l = errorCode
  EndIf
  
  ProcedureReturn result
EndProcedure
Procedure.i ISteamClient012_CreateSteamPipe(SteamClient.ISteamClient012)
  CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
    steam_thiscall_var(SteamClient)
    ProcedureReturn CallFunctionFast(@SteamClient\CreateSteamPipe())
  CompilerElse
    ProcedureReturn CallFunctionFast(@SteamClient\CreateSteamPipe(), SteamClient)
  CompilerEndIf
EndProcedure
Procedure.i ISteamClient012_ConnectToGlobalUser(SteamClient.ISteamClient012, hSteamPipe)
  CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
    steam_thiscall_var(SteamClient)
    ProcedureReturn CallFunctionFast(@SteamClient\ConnectToGlobalUser(), hSteamPipe)
  CompilerElse
    ProcedureReturn CallFunctionFast(@SteamClient\ConnectToGlobalUser(), SteamClient, hSteamPipe)
  CompilerEndIf
EndProcedure
Procedure.i ISteamClient012_GetISteamFriends(SteamClient.ISteamClient012, hSteamUser, hSteamPipe, pchVersion.s)
  Protected result.i
  Protected *ptr_pchVersion
  
  CompilerIf #PB_Compiler_Unicode
    *ptr_pchVersion = StringToAscii(pchVersion)
  CompilerElse
    *ptr_pchVersion = @pchVersion
  CompilerEndIf
  
  CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
    steam_thiscall_var(SteamClient)
    result = CallFunctionFast(@SteamClient\GetISteamFriends(), hSteamUser, hSteamPipe, *ptr_pchVersion)
  CompilerElse
    result = CallFunctionFast(@SteamClient\GetISteamFriends(), SteamClient, hSteamUser, hSteamPipe, *ptr_pchVersion)
  CompilerEndIf
  
  CompilerIf #PB_Compiler_Unicode
    If *ptr_pchVersion
      FreeMemory(*ptr_pchVersion)
    EndIf
  CompilerEndIf
  
  ProcedureReturn result
EndProcedure
Procedure.i ISteamClient012_ReleaseUser(SteamClient.ISteamClient012, hSteamPipe, hSteamUser)
  CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
    steam_thiscall_var(SteamClient)
    ProcedureReturn CallFunctionFast(@SteamClient\ReleaseUser(), hSteamPipe, hSteamUser)
  CompilerElse
    ProcedureReturn CallFunctionFast(@SteamClient\ReleaseUser(), SteamClient, hSteamPipe, hSteamUser)
  CompilerEndIf
EndProcedure
Procedure.i ISteamClient012_BReleaseSteamPipe(SteamClient.ISteamClient012, hSteamPipe)
  CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
    steam_thiscall_var(SteamClient)
    ProcedureReturn CallFunctionFast(@SteamClient\BReleaseSteamPipe(), hSteamPipe)
  CompilerElse
    ProcedureReturn CallFunctionFast(@SteamClient\BReleaseSteamPipe(), SteamClient, hSteamPipe)
  CompilerEndIf
EndProcedure
Procedure.i ISteamFriends013_GetPersonaName(SteamFriends.ISteamFriends013)
  CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
     steam_thiscall_var(SteamFriends)
    ProcedureReturn CallFunctionFast(@SteamFriends\GetPersonaName())
  CompilerElse
    ProcedureReturn CallFunctionFast(@SteamFriends\GetPersonaName(), SteamFriends)
  CompilerEndIf
EndProcedure
  
Procedure.s Steam_ISteamFriends013_GetPersonaName_PB(SteamClient.ISteamClient012, bPerformCleanup.b)
  Protected result.s
  Protected hSteamPipe.i,hSteamUser.i
  Protected SteamFriends.ISteamFriends013
  
  If SteamClient
    hSteamPipe = ISteamClient012_CreateSteamPipe(SteamClient)
    
    If hSteamPipe
      hSteamUser = ISteamClient012_ConnectToGlobalUser(SteamClient, hSteamPipe)
      
      If hSteamUser
        SteamFriends = ISteamClient012_GetISteamFriends(SteamClient, hSteamUser, hSteamPipe, "SteamFriends013")
        
        If SteamFriends
          Protected *pName = ISteamFriends013_GetPersonaName(SteamFriends)
          If *pName
            result = PeekS(*pName,-1,#PB_UTF8)
          EndIf
        EndIf
      EndIf
    EndIf
  EndIf
  
  ; Clean up
  If bPerformCleanup = #True
    
    If hSteamPipe And hSteamPipe <> -1
      If hSteamUser
        ISteamClient012_ReleaseUser(SteamClient, hSteamPipe, hSteamUser)
      EndIf
      
     ISteamClient012_BReleaseSteamPipe(SteamClient, hSteamPipe)
    EndIf
    
  EndIf
  
  ProcedureReturn result
EndProcedure
Procedure DisplayMySteamName()
  g_steamclient = steam_CreateInterface(#STEAMCLIENT_INTERFACE_VERSION_012, #Null)
  
  If g_steamclient
    PrintN("g_steamclient: "+Hex(g_steamclient))
    
    Protected mySteamName.s = Steam_ISteamFriends013_GetPersonaName_PB(g_steamclient, #True)
    
    PrintN("My Steam Name: "+mySteamName)
  EndIf
  
EndProcedure
;- ENTRY POINT
If OpenConsole()
  g_steamDir = GetSeamDir()
  
  If FileSize(g_steamDir) = -2
    SetCurrentDirectory(g_steamDir)
    
    CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
      g_steamClientFullPath = "steamclient.dll"
    CompilerElse
      g_steamClientFullPath = "steamclient64.dll"
    CompilerEndIf
    
    If OpenLibrary(0, g_steamClientFullPath)
      steam_CreateInterface = GetFunction(0, "CreateInterface")
      
      If steam_CreateInterface
        DisplayMySteamName()
      Else
        PrintN("Invalid CreateInterface")
      EndIf
    Else
      PrintN("Failed to load: "+g_steamClientFullPath)
    EndIf
  Else
    PrintN("Steam not found!")
  EndIf
  
  PrintN("")
  PrintN("Press enter to exit...")
  Input()
  
  CloseConsole()
EndIf