VB2005 Express b2: Where are the libraries?

I'm doing some dabbling with VB, and I want to write a tiny windowless app that can intercept APM suspend events and deny them. This sounds like a very simple 50-line program, so I'm not too keen on dropping $800 for the full VB Studio to do it. :)

I've download the VB 2005 Express b2 to see what can be done, and I'm not finding much of anything for libraries included with it (*.h or *.lib).

My experience has so far been with the MSDOS 6.2 QuickBASIC 1.0, and with QB 4.5 which used libraries (*.lib), so it's unclear to me if the Express edition can even do Win32-APM control:

Win32/COM: Power Management: PBT_APMQUERYSUSPEND
http://msdn.microsoft.com/library/default.asp url=/library/en-us/power/base/pbt_apmquerysuspend.asp

Prevent Windows Suspend Mode
http://www.freevbcode.com/ShowCode.asp ID=2596

Can VB Studio 2005 do APM, with a route that doesn't use libraries
Or do I need the full "standard" version of VB studio to do code like this


Answer this question

VB2005 Express b2: Where are the libraries?

  • Luchoborbo

    Hi,

    The good news is that Express contains all of the libraries and runtime components to handle these events.  There are two ways (that I know of off hand) to intercept the Power management events--one easy and one much harder. 

    If you just want to ensure that the user never shuts down the computer, then the Microsoft.Win32.SystemEvents.SessionEnding event will do the trick.  All you need to do is create a console application and add the following:


    Sub Main()
       
    AddHandler Microsoft.Win32.SystemEvents.SessionEnding, AddressOf HandleShutdownEvent
    End Sub

    Sub HandleShutdownEvent(ByVal sender As Object, ByVal e As Microsoft.Win32.SessionEndingEventArgs)
       
    If e.Reason = Microsoft.Win32.SessionEndReasons.SystemShutdown Then
          
    MsgBox("I'm not going to let you shut down!")
          e.Cancel =
    True
       End If
    End Sub

     


    Now.. if you really need to ensure that the user does not suspend the computer, then you'll unfortunately have to handle the native windows event you've listed above (PBT_APMQUERYSUSPEND).  Although this is still possible to do in VB Express, it's a bit trickier.  If you're specifically looking to trap suspend, let me know and I can help you out.

    Joe
    The VB Team

  • Clemmie

    You can use old-style dll calling in vb.net still...



    <DllImport("dll-name.dll", CallingConvention:=CallingConvention.StdCall)> _
       Shared Function proc-name (arg-list) as return-type
       End Function

     



  • Intercessor

    To be clear, applications can utilize .NET Framework and Win32 libraries--they are not mutually exclusive.  So if you'd like to write a VB.NET app that wraps the Win32 event, that's entirely possible.

    However, your assertion that applications built with VB Express require the .NET Framework to execute is correct.  The same is true for any version of VB from version 7 forward.  If you'd like to write a native VB app that does not require the .NET Framework to run, VB 6 is most recent version that will work for you.

    I hope this helps!

    Joe
    The VB Team

  • vvkmlhtr

    Well, in my further explorations, I'm just not seeing how VB Express can utilize the native Win32 libraries if they aren't even installed on the system with VB Express. 

    I do see that the full VStudio 2003 does include all the *.lib files, from searching the hard drive of that remote-access 3hr demo system:
    http://msdn.microsoft.com/vstudio/tryit/hosted/

    Could you give an example how to you'd access the native Win32 libraries, such as that APM event handler, in VB Express It looks like doing so will be rather obfuscated. :)

    Perhaps I'd just be better off to wait and get the full version of VB6 and/or Studio 2003 with the actual libraries.


  • ecentinela

    It sort of seems off-topic to discuss what I'm trying to do, but:

    - the district administrator wants the computers to turn off when not in use
    - we can't afford the latest hardware or WinXP, so machines are slow booting

    I've found that hibernation works at the network login prompt, and it will come out of hibernation at the login prompt very quickly. So, I just set the system power options to enable hibernation, and hibernate after 15 minutes, so the idle PCs auto-hibernate at the login screen. This works, I don't need to do anything more.

    However, sinces these are lab computers I do not want the system to hibernate with people actually logged in. But there is no such thing as a Windows group policy to restrict/control how hibernation operates in a lab environment, and apparantly nobody has ever written a tool to do what I'm trying to achieve here.


    My hope is to write a windowless app that loads when users login, and lurks in the background intercepting and denying both idle-event and user-triggered requests to hibernate/suspend, but it will not block a shutdown/restart/logoff event.

    I don't yet know if there's a way to tell the difference between an idle-triggered hibernate event and a user-activated hibernate event (via the Shut Down options list), but if there is a way, the idle-triggered would be silent-blocked while the user-activated event would pop up a messagebox saying that hibernation is not available.

    This can be done as a windowless console app that simply exits at logout, but making it as a service that listens for logon/logoff events might be better, to protect it from being force-quit by the user.

    This would also monitor the general idle timer for user inactivity and force the user to logoff if the system has been sitting idle for 45 minutes or so. (Forced-logoff sounds a little too deep for me to take on, but I already know of several utilities that can do that which I could just call.)

    For example:
    http://www.beyondlogic.org/solutions/shutdown/shutdown.htm

  • mocox

    Ah, I see, this is Win32 libraries reimplmeneted as a subset of .NET:
    http://msdn.microsoft.com/library/en-us/cpref/html/cpref_start.asp frame=true

    But it doesn't appear to offer the same level of access to the OS as compared to the traditional Win32 libraries, though. And since it's a subset of .NET then likely the .NET framework must be installed for any of these apps to work.

    I think I'd rather go for a more traditional route of programming that more directly corresponds to the "old-fashioned" Win32 libraries, and doesn't involve .NET at all. (For the Win2000 K-12 computers I manage, I really can't think of any that even have or need .NET installed yet.)

    Fortunately, I've found I have access to Academic Select pricing through a state contract of Visual Studio .NET 2003 Professional. Is it possible to write non-.NET programs with it, or would I need to try to find an older non-.NET version of VStudio

  • VB2005 Express b2: Where are the libraries?