dcsimg
Results 1 to 1 of 1

Thread: Unicode aware VB6 functions replacement

  1. #1

    Thread Starter
    Member Dragokas's Avatar
    Join Date
    Aug 2015
    Location
    Ukraine
    Posts
    571

    Unicode aware VB6 functions replacement

    Hi,

    here is W replacement for several native VB6 functions / properties:

    - Dir -> DirW()
    - MkDir -> MkDirW()
    - Environ -> EnvironW()
    - App.Path -> AppPathW()
    - App.ExeName -> AppExeNameW()
    - App.Major, Minor, Revision -> AppVersionW()

    All functions packed on archive as separate projects, available under the post below.

    1) DirW

    Prototype is: Dir$(Path with mask or backslash at the end, opt_mask of allowed attributes, opt_return folders? )

    Difference to original VB6 Dir$():

    Fixed bug, when Dir cannot handle attribute: read only (vbReadOnly)
    Added attributes:
    - reparse points (symlinks / junctions) (vbReparse)
    - all file objects (vbAll)
    - vbFile (files only, without folders)

    Enum VbFileAttribute "overloaded" by own: I removed all superfluous attributes, which original VB6 dir() are still not used in any way; I leave meaningful attributes only.

    + 3-rd optional argument (FoldersOnly); if true, it will filter files and leave folders only in output.
    Function also automatically filter folders-aliases "." и ".."

    Code based on earlier VB6() Dir$ reversing by @The Trick.

    2) MkDirW()

    Prototype is: MkDirW(Path to folder to create, opt_LastComponentIsFile as boolean) as boolean

    LastComponentIsFile - true, if you plan to specify filename as a last part of path component
    Return value: true, if successfully created or if folder is already exist

    3) EnvironW()

    Prototype: EnvironW$( "%Environment variable(s)%" )

    Difference to original VB6 Environ():

    - support several env. var-s on one line, like EnvironW("%UserName% - %UserDomain%")
    - require %var%, i.e. each environment variable should be surrounded by % signs.
    - automatically correct and "right" (in the sense, like if we wanted to do so from a 64-bit application) to expand under WOW64 such env. variables as:
    - %PROGRAMFILES%
    - %COMMONPROGRAMFILES%
    and get on 64-bit OS, respectively:
    - C:\Program Files, but not C:\Program Files (x86)
    - C:\Program Files\Common Files, but not C:\Program Files (x86)\Common Files

    4,5) AppPathW(), AppExeNameW()

    Prototypes are:
    - AppPathW$(opt_bGetFullPath as boolean)
    - AppExeNameW$(opt_WithExtension As Boolean)

    Self-explained:
    Code:
        Debug.Print AppPathW()                          'Folder
        Debug.Print AppPathW(bGetFullPath:=True)        'Folder\FileName.extension
        Debug.Print AppExeNameW()                       'FileName
        Debug.Print AppExeNameW(WithExtension:=True)    'FileName.extension
    6) AppVersionW()

    Prototype is: AppVersionW$()

    # require AppPathW(), AppExeNameW()

    Just append unicode-char to your exe-name /and-or path (e.g. ALT + 3333) and you'll understand why you may need this function replacement.

    Returns: String, version of your program in format: Major.Minor.Build.Revision
    ___________________

    Best wishes,
    Alex.
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width