The App object is a global COM object accessed with the App keyword. It determines or specifies information about the application's title, version information, the path and name of its executable file and Help files, and whether or not a previous instance of the application is running.

 

Dim f$, h%, s$, v#

' Object App

s$ = App.Arguments                      ' Commandline arguments

s$ = App.AboutBox                       ' Show mandatory OCX message box

f$ = App.Name : App.Name = f$           ' Get or set (current) application name

f$ = App.Path : App.Path = f$           ' Get or set (current) path

f$ = App.FileName : App.FileName = f$   ' Get or set (current) complete filename

h% = App.hInstance                      ' Get current instance handle

 

' Forms collection at runtime

Dim frm As Form

For Each frm In App.Forms

s$ = frm.Caption

' ...

Next

 

' Global memory

h% = App.AvailPhys

h% = App.TotalPhys

h% = App.AvailPageFile

h% = App.TotalPageFile

h% = App.AvailVirtual

h% = App.TotalVirtual

h% = App.MemoryLoad

 

' User and Company of this Windows version.

s$ = App.WinUser

s$ = App.WinCompany

 

' Version info of GFA-BASIC executable

h% = App.Major

h% = App.Minor

h% = App.MajorRevision

h% = App.Revision

h% = App.ProdMajor

h% = App.ProdMinor

h% = App.ProdMajorRevision

h% = App.ProdRevision

s$ = App.Comments

s$ = App.CompanyName

s$ = App.FileDescription

s$ = App.FileVersion

s$ = App.InternalName

s$ = App.LegalCopyright

s$ = App.LegalTrademarks

s$ = App.OriginalFilename

s$ = App.PrivateBuild

s$ = App.ProductName

s$ = App.ProductVersion

s$ = App.SpecialBuild

 

' Functions to create shortcut files (.lnk).

App.scClear                                     ' Clear scXXXsettings

App.scRead f$                                   ' Get the settings from an external .lnk file

 

' scXXX settings

f$ = App.scPath : App.scPath = f$               ' Full filename for the shortcut

s$ = App.scDescription : App.scDescription = s$ ' Description to put in .lnk file

h% = App.scShowCmd : App.scShowCmd = h%         ' Show type (SW_xxx constant)

s$ = App.scDirectory : App.scDirectory = s$     ' Directory to start in

s$ = App.scArguments : App.scArguments = s$     ' Arguments to pass to File

h% = App.scHotkey : App.scHotkey = h%           ' Global windows key to run shortcut

f$ = App.scIconPath : App.scIconPath = f$       ' Icon file to use for shortcut

h% = App.scIconIndex : App.scIconIndex = h%     ' Index to icon in icon file

 

' Create a shortcut file

App.scWrite f$

 

' Special common Windows folders

s$ = App.scCommonStartMenu      ' \Documents and Settings\All Users\Menu Start

s$ = App.scCommonPrograms       ' \Documents and Settings\All Users\Menu Start\Programma's

' Specific folders for current user

s$ = App.scStartMenu            ' \Documents and Settings\User\Menu Start

s$ = App.scPrograms             ' \Documents and Settings\User\Menu Start\Programs

 

' Obtain the special folders for current user.

s$ = App.scSpecialDir(0)        ' \Documents and Settings\User\Dsktop

s$ = App.scSpecialDir(2)        ' \Documents and Settings\User\Menu Start\Programs

s$ = App.scSpecialDir(5)        ' \Documents and Settings\User\My Documents

s$ = App.scSpecialDir(6)        ' \Documents and Settings\User\Favourites

s$ = App.scSpecialDir(7)        ' \Documents and Settings\User\Menu Start\Programs\Start Up

s$ = App.scSpecialDir(8)        ' \Documents and Settings\User\Recently Opened

s$ = App.scSpecialDir(9)        ' \Documents and Settings\User\SendTo

s$ = App.scSpecialDir(11)       ' \Documents and Settings\User\Menu Start

 

There can be one App object only: App. You cannot create another App object like:


Dim
MyApp As New App

 

You can however assign the App object to a variable of type App

  Dim MyApp As App
Set MyApp = App

There would be little use for this, though.

The App.scSpecialDir() functions

The App.scSpecialDir(CSIDL as Int) function retrieves the path of a special folder, identified by its CSIDL. The scSpecialDir function conforms to the Windows Shell API ShGetSpecialFolderPath(). A number of folders are used frequently by applications, but may not have the same name or location on any given system. CSIDL values provide a unique system-independent way to identify these special folders. The values supersede the use of environment variables for this purpose. For example, the system folder may be "C:\Windows" on one system and "C:\Winnt" on another. The CSIDL constants are defined in shlapi.inc.g32 (Shlobj.h) and shfolder.inc.g32 (Shfolder.h).

 

Constants

CSIDL_FLAG_CREATE (0x8000)

Version 5.0. Combine this CSIDL with any of the following CSIDLs to force the creation of the associated folder.

CSIDL_ADMINTOOLS (0x0030)

Version 5.0. The file system directory that is used to store administrative tools for an individual user. The Microsoft Management Console (MMC) will save customized consoles to this directory, and it will roam with the user.

CSIDL_ALTSTARTUP (0x001d)

The file system directory that corresponds to the user's nonlocalized Startup program group.

CSIDL_APPDATA (0x001a)

Version 4.71. The file system directory that serves as a common repository for application-specific data. A typical path is C:\Documents and Settings\username\Application Data. This CSIDL is supported by the redistributable Shfolder.dll for systems that do not have the Microsoft Internet Explorer 4.0 integrated Shell installed.

CSIDL_BITBUCKET (0x000a)

The virtual folder containing the objects in the user's Recycle Bin.

CSIDL_CDBURN_AREA (0x003b)

Version 6.0. The file system directory acting as a staging area for files waiting to be written to CD. A typical path is C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\CD Burning.

CSIDL_COMMON_ADMINTOOLS (0x002f)

Version 5.0. The file system directory containing administrative tools for all users of the computer.

CSIDL_COMMON_ALTSTARTUP (0x001e)

The file system directory that corresponds to the nonlocalized Startup program group for all users. Valid only for Microsoft Windows NT systems.

CSIDL_COMMON_APPDATA (0x0023)

Version 5.0. The file system directory containing application data for all users. A typical path is C:\Documents and Settings\All Users\Application Data.

CSIDL_COMMON_DESKTOPDIRECTORY (0x0019)

The file system directory that contains files and folders that appear on the desktop for all users. A typical path is C:\Documents and Settings\All Users\Desktop. Valid only for Windows NT systems.

CSIDL_COMMON_DOCUMENTS (0x002e)

The file system directory that contains documents that are common to all users. A typical paths is C:\Documents and Settings\All Users\Documents. Valid for Windows NT systems and Microsoft Windows 95 and Windows 98 systems with Shfolder.dll installed.

CSIDL_COMMON_FAVORITES (0x001f)

The file system directory that serves as a common repository for favourite items common to all users. Valid only for Windows NT systems.

CSIDL_COMMON_MUSIC (0x0035)

Version 6.0. The file system directory that serves as a repository for music files common to all users. A typical path is C:\Documents and Settings\All Users\Documents\My Music.

CSIDL_COMMON_PICTURES (0x0036)

Version 6.0. The file system directory that serves as a repository for image files common to all users. A typical path is C:\Documents and Settings\All Users\Documents\My Pictures.

CSIDL_COMMON_PROGRAMS (0x0017)

The file system directory that contains the directories for the common program groups that appear on the Start menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs. Valid only for Windows NT systems.

CSIDL_COMMON_STARTMENU (0x0016)

The file system directory that contains the programs and folders that appear on the Start menu for all users. A typical path is C:\Documents and Settings\All Users\Start Menu. Valid only for Windows NT systems.

CSIDL_COMMON_STARTUP (0x0018)

The file system directory that contains the programs that appear in the Startup folder for all users. A typical path is C:\Documents and Settings\All Users\Start Menu\Programs\Startup. Valid only for Windows NT systems.

CSIDL_COMMON_TEMPLATES (0x002d)

The file system directory that contains the templates that are available to all users. A typical path is C:\Documents and Settings\All Users\Templates. Valid only for Windows NT systems.

CSIDL_COMMON_VIDEO (0x0037)

Version 6.0. The file system directory that serves as a repository for video files common to all users. A typical path is C:\Documents and Settings\All Users\Documents\My Videos.