Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1529

Tiny, confortable and effortless little helper

$
0
0
Sometimes there are events in life then a invalid filename or foldername has sneaked in due to human misspelling or a crash and causing you headache because you just doesn't find the tiny little error.
I'm notorius in about the shell so this effortless example is no excption and very handy :D

Code:

Public Declare Function SHCreateStreamOnFileEx Lib "shlwapi" (ByVal pszFile As Long, ByVal grfMode As STGM, ByVal dwAttributes As FILE_ATTRIBUTES, ByVal fCreate As Long, ByVal pstmTemplate As Long, ppSTM As IStream) As Long

Dim hr As Long: hr = SHCreateStreamOnFileEx(StrPtr(CStr(sFileOrPath)), STGM_READ, 0, 0, 0, Nothing): If hr = &H80070002 Then MsgBox "File does not exist! Must quit!", vbCritical: Exit Function

Yes, I know PathFileExistsW exists but mine is funnier (I do think that one uses same princip) :p
Yes, you need Fafalone's TypeLib or Similar.

Viewing all articles
Browse latest Browse all 1529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>