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
- 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)
If hFind = INVALID_HANDLE_VALUE Then
If (Err.LastDllError) > 12& Then hFind = 0&: Err.Raise 52&
Exit Function
End If
it should be
Code:
If hFind = INVALID_HANDLE_VALUE Then
hFind = 0&
If (Err.LastDllError) > 12& Then Err.Raise 52&
Exit Function
End If
Reason:
You check always for "hFind <> 0&" and hFind of INVALID_HANDLE_VALUE would be also <> 0&. So the hFind must be reset to 0& regardless if an error shall be thrown out or not. (Err.LastDllError > 12&)
It looks like the API functions used for your "AppVersionW" could also be used to return values for App.Comments, App.CompanyName, App.FileDescription, App.LegalCopyright, App.LegalTrademarks and App.ProductName. All these properties fail when the executable lies on a path containing Unicode characters. Maybe you could make an updated version including these? It doesn't seem to be as trivial as retrieving the version numbers though...
Well, I must give outdated thank to @Krool, that's correct remark. Sorry, for not answering. Were bad times.
@xiaoyao, it's short but not reliable compared to mine. Always need to normalize, especially if you support various versions of Windows.
@VanGoghGaming, I'll keep your proposal in mind until I'll have more time.
Lot of things changed since. It's better to move source code on github, I think.
For those properties, I already wrote 2 roots in the past: for exe & for ide (parsed from vbp). Just need to beautify it a bit.
It's always a pain how to separate single samples from a large project.
One time I thought about writing mini-framework with all functions embedded including -W, file/registry/window basic tasks. But I'm not the one who can write clear API (ahh, then I have to to write docs...)
Actually I already have one in form of several mod/cls, ready to use. But I'd prefer to have it like OCX (or even both variants). So, you connect it once, and you have a full power much like mini .NET, aimed to interact with OS with most common actions developer may want.
PutStringUnicode(hFile As Long, Optional pos As Long, Optional sStr As String) As Boolean PutString(hFile As Long, Optional pos As Long, Optional sStr As String, Optional bUnicode As Boolean = True) As Boolean PutW(hFile As Long, ByVal pos As Long, vInPtr As Long, cbToWrite As Long, Optional doAppend As Boolean) As Boolean PrintLineW(hFile As Long, sStr As String, Optional bUnicode As Boolean) As Boolean PrintBOM(hFile As Long) As Boolean
PutStringUnicode(hFile As Long, Optional pos As Long, Optional sStr As String) As Boolean PutString(hFile As Long, Optional pos As Long, Optional sStr As String, Optional bUnicode As Boolean = True) As Boolean PutW(hFile As Long, ByVal pos As Long, vInPtr As Long, cbToWrite As Long, Optional doAppend As Boolean) As Boolean PrintLineW(hFile As Long, sStr As String, Optional bUnicode As Boolean) As Boolean PrintBOM(hFile As Long) As Boolean
Thank you! I (should) have resolved extracting from here