Titus Information Systems, Inc.

Standard Library
Utility Functions

Many processes are tedious using the standard Windows API function calls.  Some of these have been encapsulated into MFC classes, but others have not.  The Standard Library provides functions that streamline these processes.  The following functions may be accessed from a C++ function utilizing the standard name-mangling call interface:

BOOL CreateShellLink(LPCSTR Source, LPCSTR Object, LPSTR Desc, LPSTR Link)
This routine creates a Windows shortcut icon.  Source is the path of the folder containing the Object.  Object is the file to which a shortcut should be created.  Desc is the name of the shortcut (the description of the icon).  Link is the path of the folder where the shortcut (.LNK file) should be placed.
ULONGLONG GetFileVersion(CString FileName)
This routine returns the version number of the specified Dynamic Link Library (DLL) file.  FileName should contain the full path of the file.
BOOL GetLoginInfo(CString&UserName, CString&ComputerName)
This routine returns the current login user name and computer name using standard Windows API function calls.  The value of the function is TRUE if the names are returned with no error and FALSE if either name can not be retrieved.
BOOL GetLoginInfo(CStringArray&GroupName)
This routine returns an array of Group Names to which the current login user is assigned using standard Windows API function calls.  The value of the function is TRUE if the names are returned with no error and FALSE if the names can not be retrieved.
BOOL GetLoginInfo(CString&UserName, CString&ComputerName, CStringArray&GroupName)
This routine returns the current login user name, the computer name, and an array of Group Names to which the current login user is assigned using standard Windows API function calls.  The value of the function is TRUE if the names are returned with no error and FALSE if the names can not be retrieved.
BOOL GetLoginInfo(CString&UserName, CString&ComputerName, CString&SerialNumber, BYTE*CpuType, BYTE*CpuSpeed)
This routine returns the current login user name, the computer name, the operating system serial number, the CPU type, and the CPU speed using standard Windows API function calls.  The value of the function is TRUE if the data are returned with no error and FALSE if any of the API functions fail.
BOOL ShutdownWindows(UINT Option)
This routine shuts down windows.  If the current login user does not have sufficient privileges to accomplish this, the privileges are adjusted to allow the ExitWindowsEx API function call to succeed.  Option is as follows:
EWX_LOGOFF Shuts down all processes running in the security context of the process that called the ExitWindowsEx() function.  Then it logs the user off.
EWX_POWEROFF Shuts down the system and turns off the power.  The system must support the power-off feature.
EWX_REBOOT Shuts down the system and then restarts the system.
EWX_SHUTDOWN Shuts down the system to a point at which it is safe to turn off the power.  All file buffers have been flushed to disk, and all running processes have stopped.
EWX_FORCE Forces processes to terminate.  When this flag is set, the system does not send the WM_QUERYENDSESSION and WM_ENDSESSION messages.  This can cause the applications to lose data.  Therefore, you should only use this flag in an emergency.
EWX_FORCEIFHUNG (Windows 2000 only) Forces processes to terminate if they do not respond to the WM_QUERYENDSESSION or WM_ENDSESSION message.  This flag is ignored if EWX_FORCE is used.
void SoundBeep(BOOL Error)
This routine sounds a tone for .05 seconds with a frequency of 1047 (the C on the third space of the treble clef).  If error is TRUE, that is followed by three more tones of .05 seconds each with frequencies of 784, 1047, and 784.  784 is the frequency of the G on the second line of the treble clef.  Therefore, when an error occurs, there will be four short tones alternating a perfect fourth.
BOOL UpdateStartFile(CString File, CString Key, CString Value)
This routine updates the contents of the startup file whose full pathname is in File.  Specify the key to be updated or created in Key and the value to be appended to the string of the that key in Value.  For example, to add a folder to the PATH environment variable in the AUTOEXEC.BAT file, specify "PATH" for Key, and the new folder in Value.  The existing file will be copied to a new file with the extension replaced with ".BAK".
void WriteHeapStatistics(CString&Status)
This diagnostic routine writes the current heap statistics into Status.  These statistics are useful for determining the existence and location of processes that gradually consume system resources, such as memory leaks.  The returned string will contain end-of-line characters and may be written to a file, displayed in a Message Box, or sent to the Application Log.


[ Stand-alone Programs | Standard Library | Conversion Functions | COBOL Functions ]
[ Windows NT Library | COBOL Library | COBOL Interface | Command Prompt Abbreviations | Purchase Instructions ]

[ Home | Areas of Expertise | "We Do Windows" | Clients and Projects | Software Samples | Package Software Available ]
[ Contact Information | Business Software Philosophy | Church Software Philosophy ]
All contents of this web site are Copyright © Titus Information Systems, Inc., Phoenix, Arizona, U.S.A.