Results 1 to 3 of 3

Thread: Funny API

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 1999
    Posts
    100

    Talking

    Hi..

    I'm learning to use API and one silly simple on is this that makes random bip's on the pc-speaker:

    Code:
    Public Declare Function Beep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
    Code:
     Dim l As Long
     Dim i As Integer
     
     Randomize
     For i = 1 To 1000
        l = Beep(Int(10000 * Rnd), 50)
     Next
    Anyone that got something more stupid or fun???

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    I love changing the title bar caption of the Active Window
    Code:
    'didn't include declares
    Dim wnd
    wnd = GetForegroundWindow()
    
    
    ' Display the text displayed in the title bar of window Form1
    Dim textlen As Long  ' receives length of text of the window
    Dim wintext As String  ' receives the text of the window
    Dim slength As Long  ' receives the length of the returned string
    
    ' Find out how many characters are in the window's text.
    ' Add 1 to compensate for the terminating null.
    textlen = GetWindowTextLength(wnd) + 1
    ' Make sufficient room in the buffer.
    wintext = Space(textlen)
    ' Retrieve the text of window Form1.
    slength = GetWindowText(wnd, wintext, textlen)
    ' Remove the empty space from the string, if any.
    wintext = Left(wintext, slength)
    ' Display the result.
    
    
    retval = SetWindowText(wnd, "A Joke")
    
    ' Flash Form1 five times to get the user's attention
    Dim c As Integer  ' counter variable & return value
    
    For c = 1 To 10  ' flash on five times, off five times
      retval = FlashWindow(wnd, 1)  ' toggle the look of the window
      Sleep 500  ' halt execution for 500 milliseconds (1/2 minute)
    Next c
    retval = FlashWindow(wnd, 0)  ' make sure the window looks normal
    retval = SetWindowText(wnd, wintext) 'reset old text
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  3. #3
    Guest
    Here's a pretty good one.

    Code:
    Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal _
    lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength _
    As Long, ByVal hwndCallback As Long) As Long
    
    Private Sub Form_Load()
    Dim lngReturn As Long
    Dim strReturn As Long
    
    opencd = MsgBox("Are you in the mood for a free gift?", 4 + 32)
    If opencd = vbYes Then
    lngReturn = mciSendString("set CDAudio door open", strReturn, 127, 0)
    MsgBox "There you are.  A free cup holder :).", 64
    Else
    MsgBox "Okay, maybe next time.", 16
    End If
    End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width