August 7, 2000

Check whether RAS is installed

When you work with RAS APIs, you should have to make sure if RAS library is installed on the system. A simple way is to verify the existence of the Rasapi32.dll file in the windows system directory; the same thing can be obtained with a call to the InternetGetConnectedState API,

AlwaysOnTheTop – Move a form on top of all other windows

Private Declare Function SetWindowPos Lib “user32” (ByVal hWnd As Long, _ ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, _ ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongConst SWP_NOSIZE = &H1Const SWP_NOMOVE = &H2Const SWP_SHOWWINDOW = &H40Const HWND_NOTOPMOST = -2Const

EnumRASEntries – Enumerate all available RAS phone-book entries

Const ERROR_SUCCESS = 0&Const ERROR_BUFFER_TOO_SMALL = 603&Const RAS_MaxEntryName = 256Private Type RASENTRYNAME dwSize As Long szEntryName(RAS_MaxEntryName) As ByteEnd TypePrivate Declare Function RasEnumEntries Lib “RasApi32.DLL” Alias _ “RasEnumEntriesA” (ByVal reserved As String, ByVal lpszPhonebook As String, _ lpRasEntryName As Any, lpcb As Long, lpcEntries As Long) As Long’ Enumerate available RAS

Delete a User in NT

Question: How do I delete a user in NT with the API’s? Answer: The code below shows how to delete a user (if the server name is blank, it attempts to delete a user on the local computer): Option ExplicitPrivate Const NERR_Success As Long = 0&Private Declare Function NetUserDel _

Setting the off-line mode

You can programmatically set the Internet Explorer off-line mode with the InternetSetOption API, as this code snippet demonstrates: Const INTERNET_OPTION_CONNECTED_STATE = 50Const INTERNET_STATE_CONNECTED = 1Const INTERNET_STATE_DISCONNECTED = 2Const INTERNET_STATE_DISCONNECTED_BY_USER = &H10Const INTERNET_STATE_IDLE = &H100Const INTERNET_STATE_BUSY = &H200Const ISO_FORCE_DISCONNECTED = 1Private Declare Function InternetSetOption Lib “wininet.dll” Alias _ “InternetSetOptionA” (ByVal hInternet

Check whether the user is working off-line

Internet Explorer offers the possibility to simulate an Internet connection with the off-line mode. If you want to know if off-line mode is on or off you can use InternetQueryOption API. Const INTERNET_OPTION_CONNECTED_STATE = 50Const INTERNET_STATE_DISCONNECTED_BY_USER = &H10Private Type INTERNET_CONNECTED_INFO dwConnectedState As Long dwFlags As LongEnd TypePrivate Declare Function InternetQueryOption

An enhanced VB DatePart function

Here is an enhanced version of VB DatePart function: the first parameter is now an enumerated type, so easier to use. DatePartEx is 4-5 times faster than DatePart and supports also two new intervals: MonthName and WeekdayName. Enum DateTimePart dtYear dtQuarter dtMonth dtMonthName dtShortMonthName dtDay dtDayOfTheYear dtWeekday dtWeekdayName dtShortWeekdayName dtWeekOfTheYear

Intercepting MouseEnter and MouseExit events without subclassing

Visual Basic raises the MouseMove event when the mouse cursor is within a control, so it’s easy to know when the cursor “enters” a control. However, determining when the mouse leaves the control is more difficult.You can solve this problem by monitoring the first time the control raises the MouseMove