Получение цели ярлыка Microsoft Installer (юникод) - VB

Формулировка задачи:

Здравствуйте ! Помогите, пожалуйста, перевести эту функцию в юникодную версию.
Private Declare Function MsiGetShortcutTarget Lib "Msi.dll" Alias "MsiGetShortcutTargetA" (ByVal szShortcutTarget As String, ByVal szProductCode As String, ByVal szFeatureId As String, ByVal szComponentCode As String) As Long
Private Declare Function MsiGetComponentPath Lib "Msi.dll" Alias "MsiGetComponentPathA" (ByVal szProduct As String, ByVal szComponent As String, ByVal lpPathBuf As String, pcchBuf As Long) As Long
 
 
Public Function GetMSILinkTarget(Link As String) As String
    On Error Resume Next
    Const MaxFeatureLength      As Long = 38&
    Const MaxGuidLength         As Long = 38&
    Const MaxPathLength         As Long = 1024&
    Const INSTALLSTATE_LOCAL    As Long = 3&
 
    Dim lr              As Long
    Dim TargetSize      As Long
    Dim ProductCode     As String
    Dim FeatureID       As String
    Dim ComponentCode   As String
    Dim Target          As String
    
    ProductCode = Space(MaxGuidLength + 1)
    FeatureID = Space(MaxFeatureLength + 1)
    ComponentCode = Space(MaxGuidLength + 1)
    
    lr = MsiGetShortcutTarget(Link, ProductCode, FeatureID, ComponentCode)
    
    TargetSize = MaxPathLength
    Target = Space(TargetSize)
    
    lr = MsiGetComponentPath(ProductCode, ComponentCode, Target, TargetSize)
    
    If lr = INSTALLSTATE_LOCAL Then
        GetMSILinkTarget = Trim(Left$(Target, TargetSize))
    End If
End Function
Спасибо.

Код к задаче: «Получение цели ярлыка Microsoft Installer (юникод) - VB»

textual
Private Declare Function MsiGetShortcutTarget Lib "Msi.dll" Alias "MsiGetShortcutTargetW" (ByVal szShortcutTarget As Long, ByVal szProductCode As Long, ByVal szFeatureId As Long, ByVal szComponentCode As Long) As Long
Private Declare Function MsiGetComponentPath Lib "Msi.dll" Alias "MsiGetComponentPathW" (ByVal szProduct As Long, ByVal szComponent As Long, ByVal lpPathBuf As Long, pcchBuf As Long) As Long
 
 
Public Function GetMSILinkTarget(Link As String) As String
    On Error Resume Next
    Const MaxFeatureLength      As Long = 38&
    Const MaxGuidLength         As Long = 38&
    Const MaxPathLength         As Long = 1024&
    Const INSTALLSTATE_LOCAL    As Long = 3&
 
    Dim lr              As Long
    Dim TargetSize      As Long
    Dim ProductCode     As String
    Dim FeatureID       As String
    Dim ComponentCode   As String
    Dim Target          As String
    
    ProductCode = Space(MaxGuidLength)
    FeatureID = Space(MaxFeatureLength)
    ComponentCode = Space(MaxGuidLength)
    
    lr = MsiGetShortcutTarget(StrPtr(Link), StrPtr(ProductCode), StrPtr(FeatureID), StrPtr(ComponentCode))
    
    TargetSize = MaxPathLength
    Target = Space(TargetSize)
    
    lr = MsiGetComponentPath(StrPtr(ProductCode), StrPtr(ComponentCode), StrPtr(Target), TargetSize)
    
    If lr = INSTALLSTATE_LOCAL Then
        GetMSILinkTarget = Trim(Left$(Target, TargetSize))
    End If
End Function

15   голосов, оценка 4.267 из 5


СОХРАНИТЬ ССЫЛКУ