Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Api

  1. #1
    New Coder
    Join Date
    Jul 2003
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Api

    How do i use the API functions in VB. Where do I get them. How do i select them??

  • #2
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You have to declare them first:
    Code:
    ' the PlaySound API function declaration
    Public Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
    
    ' you might also need to declare some constants
    Public Const SND_ASYNC = &H1         '  play asynchronously
    Public Const SND_FILENAME = &H20000     '  name is a file name
    Public Const SND_NOWAIT = &H2000      '  don't wait if the driver is busy
    and then you can use them as a normal VB function:
    Code:
    ' now we can play sounds!
    PlaySound GetAppPath & "/sounds/somesound.wav", CLng(0), SND_ASYNC + SND_FILENAME + SND_NOWAIT
    The VB 6 API Viewer is a useful tool to find all the appropiate declarations (for the functions, the types, and the constants). You can reach it from the Add-In Manager (In the Add-Ins menu).

    shmoove

    PS: I'm talking VB 6 here, I don't know how it goes in VB.NET


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •