Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#14

AW: DLL Side-by-side registration & redirection

  Alt 22. Jun 2018, 15:07
Kenne die DLL nicht.
Zitat:
Heißt: Es muss entweder registriert werden oder man nutzt "side-by-side".
Oder LoadLibrary.

Ich mache es so.. mit LoadLibrary von meinem Plugin System.

Code:
Private Sub CheckVisPlugin()

    VisPlugin = GetSetting(App.EXEName, "Option", "PluginVisual", vbNullString)
    If Right$(VisPlugin, 4) = ".dll" Then
        RegServe VisPlugin, True
        VisPlugin = GetFileName(VisPlugin)
        PluginName = Left$(VisPlugin, Len(VisPlugin) - 4)
        Set PluginVis = CreateObject(PluginName & ".clsMain")
        msgPlg.Visual = True
        PluginVis.ToolBarVisible = frmToolbar.Visible = True
        PluginVis.EQVisible = frmEqualizer.Visible = True
        PluginVis.SkinChange sOldSkinName

        If Me.WindowState = vbMinimized Then
            PluginVis.PlayerVisible = False
        Else
            PluginVis.PlayerVisible = Me.Visible
        End If

        If stndPlayList = 1 Then
            PluginVis.PlaylistVisible = True
            PluginVis.PlaylistPos frmPlayList.Left, frmPlayList.Top, frmPlayList.Width, frmPlayList.Height
        Else
            PluginVis.PlaylistVisible = False
        End If
        PluginVis.Execute FrmMain_Hwnd
    End If

End Sub
Code:
Public Function RegServe(ByVal Path As String, _
                         ByVal mode As Boolean) As Boolean

Dim insthLib As Long
Dim lpLibAdr As Long
Dim hThd    As Long
Dim lpExCode As Long
Dim procName As String
Dim Result  As Long
Dim okFlag  As Boolean
'### DLL in den Speicher laden

    insthLib = LoadLibrary(Path)
    '### Aktion wählen
    If insthLib Then
        If mode Then
            procName = "DllRegisterServer"
        Else
            procName = "DllUnregisterServer"
        End If
        '### Adresse der DLL im Speicher
        lpLibAdr = GetProcAddress(insthLib, procName)
        If lpLibAdr <> 0 Then
            '### Aktion starten
            hThd = CreateThread(ByVal 0, 0, ByVal lpLibAdr, ByVal 0&, 0&, 0&)
            If hThd Then
                '### Maximal 5 sec warten
                Result = WaitForSingleObject(hThd, 5000)
                If Result = STATUS_WAIT_0 Then
                    '### Vorgang erfolgreich in 5 sec beendet
                    Call CloseHandle(hThd)
                    okFlag = True
                Else
                    '### 5 sek. überschritten -> Thread schließen
                    Call GetExitCodeThread(hThd, lpExCode)
                    Call ExitThread(lpExCode)
                    Call CloseHandle(hThd)
                End If
            End If
        End If
        '### Speicher wieder freigeben
        Call FreeLibrary(insthLib)
    End If
   
    If Not okFlag Then
        MsgBox ("Fehler! Der Vorgang wurde abgebrochen.")
    Else
        'MsgBox ("Der Vorgang war erfolgreich!")
    End If
   
    RegServe = okFlag
   
End Function
Nur damit du siehst das ich dir nicht nur was erzähle sondern weis wie es geht.

gruss

Geändert von EWeiss (22. Jun 2018 um 15:14 Uhr)
  Mit Zitat antworten Zitat