Click here to Skip to main content
15,906,106 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Generalwat is the code for matrix function(math) Pin
vnistelrooy6-Jan-04 22:30
vnistelrooy6-Jan-04 22:30 
GeneralListView repainting problem Pin
Niels Penneman6-Jan-04 11:03
Niels Penneman6-Jan-04 11:03 
QuestionHow to install kbd hook in VB Pin
Vivek Jain6-Jan-04 7:41
Vivek Jain6-Jan-04 7:41 
GeneralMulti level binding with Datagrid Pin
DC@Home6-Jan-04 6:05
DC@Home6-Jan-04 6:05 
QuestionIs the Screensaver running? Pin
Roidzo6-Jan-04 4:20
Roidzo6-Jan-04 4:20 
AnswerRe: Is the Screensaver running? Pin
Dave Kreskowiak6-Jan-04 9:40
mveDave Kreskowiak6-Jan-04 9:40 
GeneralRe: Is the Screensaver running? Pin
Roidzo6-Jan-04 17:47
Roidzo6-Jan-04 17:47 
GeneralRe: Is the Screensaver running? Pin
Dave Kreskowiak7-Jan-04 5:03
mveDave Kreskowiak7-Jan-04 5:03 
OK. All of your code is good except for one thing. Change all of your 'Long's to Integers. Long's in VB.NET are 64-bit integers and 32-bit in VB6. This is one of your problems. The other is that your VariantType just needs to be an integer. All the pvParam is returning is a boolean value saying True or False. When you call a function that has an ANy type in it, you have to think ahead and replace the Any with the type that you EXPECT to get back. In this case, a 32-bit Integer would work. The corrected code look like this:
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" _
        (ByVal uiAction As Integer, _
        ByVal uiParam As Integer, _
        ByRef pvParam As Integer, _
        ByVal fWInIni As Integer) As Boolean
Private Const SPI_GETSCREENSAVEACTIVE As Integer = &H10
Private Const SPI_GETSCREENSAVERRUNNING As Integer = &H72

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Dim p_lngRtn As Integer
    Dim bRunning As Boolean

    p_lngRtn = SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, 0, bRunning, False)
    If p_lngRtn = 0 Then
        Debug.WriteLine(Err.Description)
    End If

    If bRunning Then
        Beep()
    End If
End Sub

Also, when calling into the API, exceptions will not be thrown, and the Err object will not be set at all. You would have to use the return value, 'p_lngRtn' is your code, to determine that an error HAS occured, then you would have to call the API function GetLastError to get the actual error that occured. Your's was probably something like '87 - The parameter is incorrect'.



RageInTheMachine9532
GeneralRe: Is the Screensaver running? Pin
Roidzo7-Jan-04 7:53
Roidzo7-Jan-04 7:53 
GeneralRe: Is the Screensaver running? Pin
Dave Kreskowiak8-Jan-04 4:09
mveDave Kreskowiak8-Jan-04 4:09 
GeneralNew Project Pin
SLoughins6-Jan-04 0:38
SLoughins6-Jan-04 0:38 
GeneralRe: New Project Pin
cnurse6-Jan-04 1:59
cnurse6-Jan-04 1:59 
GeneralRe: New Project Pin
Niels Penneman6-Jan-04 11:10
Niels Penneman6-Jan-04 11:10 
Generalfreezing issue with simple client/server Pin
acecase6-Jan-04 0:04
acecase6-Jan-04 0:04 
GeneralRe: freezing issue with simple client/server Pin
cnurse6-Jan-04 2:09
cnurse6-Jan-04 2:09 
GeneralRe: freezing issue with simple client/server Pin
acecase6-Jan-04 10:03
acecase6-Jan-04 10:03 
GeneralAll Controls in Form Pin
Het21095-Jan-04 21:59
Het21095-Jan-04 21:59 
GeneralRe: All Controls in Form Pin
cnurse6-Jan-04 1:55
cnurse6-Jan-04 1:55 
Generallinking vb.net user interface with c++ dll function Pin
Member 7803585-Jan-04 20:07
Member 7803585-Jan-04 20:07 
GeneralRe: linking vb.net user interface with c++ dll function Pin
Colin Angus Mackay6-Jan-04 4:28
Colin Angus Mackay6-Jan-04 4:28 
GeneralRe: linking vb.net user interface with c++ dll function Pin
Dave Kreskowiak6-Jan-04 9:34
mveDave Kreskowiak6-Jan-04 9:34 
Generalattachments in Word Document Pin
Anonymous5-Jan-04 7:31
Anonymous5-Jan-04 7:31 
GeneralI Don't wanna go to Add/Remove Program to Uninstall my application Pin
jlizardo5-Jan-04 7:29
jlizardo5-Jan-04 7:29 
GeneralRe: I Don't wanna go to Add/Remove Program to Uninstall my application Pin
Niels Penneman6-Jan-04 11:15
Niels Penneman6-Jan-04 11:15 
GeneralRe: I Don't wanna go to Add/Remove Program to Uninstall my application Pin
jlizardo6-Jan-04 16:33
jlizardo6-Jan-04 16:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.