Стенография, для бинарных файлов.
Для многих графических (JPG, TIFF и некоторые другие) - Exif.
В общем случае - descript.ion.
alibek писал(а):Стенография, для бинарных файлов.
Для многих графических (JPG, TIFF и некоторые другие) - Exif.
В общем случае - descript.ion.
Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
Public Function CheckFile(Name As String) As Integer
Dim S As Long
S = GetFileAttributes(Name)
If S = -1 Then CheckFile = 0: Exit Function
If S And &H10 Then CheckFile = 2: Exit Function
CheckFile = 1
End Function
Public Function LoadFile(FileName As String) As String
Dim F As Long, B() As Byte, IC As Long
F = FreeFile
If CheckFile(FileName) <> 1 Then Exit Function
Open FileName For Binary As F
IC = LOF(F)
If Not IC = 0 Then
ReDim B(1 To IC) As Byte
Get #F, 1, B()
LoadFile = String(IC, " ")
CopyMemory ByVal LoadFile, B(1), IC
End If
Close F
End Function
Public Function GetFileNameIN(FilePath As String)
Dim CN, A, B
CN = 1
Ret:
A = InStr(CN, FilePath, "\")
If A = 0 Then
GetFileNameIN = Mid(FilePath, B - -1): Exit Function
Else
CN = A - -1: B = InStr(CN, FilePath, "\")
If B = 0 Then
GetFileNameIN = Mid(FilePath, A - -1): Exit Function
Else
CN = B - -1: GoTo Ret
End If
End If
End Function
Public Function GetPathOnlyIN(FilePath As String)
Dim A As Long
A = InStrRev(FilePath, "\")
If A > 1 Then GetPathOnlyIN = Mid$(FilePath, 1, A)
End Function
Public Function MySplit(ToArray() As String, Expression As String, Optional Delimiter As String = vbCrLf, Optional Limit As Long, Optional Compare As VbCompareMethod = vbBinaryCompare) As Long
Dim TAC As Long, i As Long, L As Long
Erase ToArray()
If Len(Expression) = 0 Then ReDim ToArray(1 To 1) As String: TAC = 1
L = 1
Do
i = InStr(L, Expression, Delimiter, Compare)
If i = 0 Then Exit Do
TAC = TAC + 1
ReDim Preserve ToArray(1 To TAC) As String
ToArray(TAC) = Mid$(Expression, L, (i - L))
If TAC >= Limit And Limit > 0 Then ToArray(TAC) = ToArray(TAC) & Mid$(Expression, i): GoTo NEX
L = i + Len(Delimiter)
Loop
If Len(Expression) >= L Then
TAC = TAC + 1
ReDim Preserve ToArray(1 To TAC) As String
ToArray(TAC) = Mid$(Expression, L)
End If
NEX:
MySplit = TAC
End Function
Public Function GetComment(FN As String) As String
On Error Resume Next
Dim S As String, IC As Long, Arr() As String, i As Long, S2 As String
Dim sFN As String, L As Long
sFN = GetFileNameIN(FN)
S = LoadFile(GetPathOnlyIN(FN) & "descript.ion")
IC = MySplit(Arr(), S)
For i = 1 To IC
If Len(Trim$(Arr(i))) > 0 Then
If Mid$(Arr(i), 1, 1) = Chr$(34) Then
L = InStr(2, Arr(i), Chr$(34))
S = "": S2 = ""
If L > 2 Then
S = Mid$(Arr(i), 2, L - 2)
S2 = Mid$(Arr(i), L + 2)
End If
Else
Split2 Arr(i), " ", S, S2
End If
If StrComp(sFN, S, vbTextCompare) = 0 Then GetComment = S2: Exit Function
End If
Next
End Function
Public Function Split2(ByVal Text As String, Delimiter As String, Optional S1 As String, Optional S2 As String, Optional Compare As VbCompareMethod = vbBinaryCompare) As Long
Dim i As Long
S1 = "": S2 = ""
i = InStr(1, Text, Delimiter, Compare)
If i = 0 Then S1 = Text: Exit Function
If i = 1 And Len(Delimiter) = Len(Text) Then Exit Function
If i = 1 Then S2 = Mid$(Text, Len(Delimiter) + 1): Exit Function
If i + Len(Delimiter) = Len(Text) + 1 Then S1 = Mid$(Text, 1, i - 1): Exit Function
S1 = Mid$(Text, 1, i - 1): S2 = Mid$(Text, i + Len(Delimiter))
End Function
Public Function SetComment(FN As String, Comment As String) As Long
On Error Resume Next
Dim S As String, IC As Long, Arr() As String, i As Long, S2 As String
Dim sFN As String, L As Long, F As String, AD As Boolean
sFN = GetFileNameIN(FN)
S = LoadFile(GetPathOnlyIN(FN) & "descript.ion")
F = FreeFile
Open GetPathOnlyIN(FN) & "descript.ion" For Output As #F
IC = MySplit(Arr(), S)
For i = 1 To IC
If Len(Trim$(Arr(i))) > 0 Then
If Mid$(Arr(i), 1, 1) = Chr$(34) Then
L = InStr(2, Arr(i), Chr$(34))
S = "": S2 = ""
If L > 2 Then
S = Mid$(Arr(i), 2, L - 2)
S2 = Mid$(Arr(i), L + 2)
End If
Else
Split2 Arr(i), " ", S, S2
End If
If StrComp(sFN, S, vbTextCompare) = 0 Then
Arr(i) = Chr$(34) & S & Chr$(34) & " " & Comment
AD = True
End If
Print #F, Arr(i)
End If
Next
If Not AD Then
Print #F, Chr$(34) & GetFileNameIN(FN) & Chr$(34) & " " & Comment
End If
Close #F
End Function
Сейчас этот форум просматривают: AhrefsBot, Majestic-12 [Bot], Yandex-бот и гости: 4