AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) DLL Side-by-side registration & redirection
Thema durchsuchen
Ansicht
Themen-Optionen

DLL Side-by-side registration & redirection

Ein Thema von Der schöne Günther · begonnen am 21. Jun 2018 · letzter Beitrag vom 22. Jun 2018
Antwort Antwort
EWeiss
(Gast)

n/a Beiträge
 
#1

AW: DLL Side-by-side registration & redirection

  Alt 22. Jun 2018, 01:21
Emil, er benutzt nicht LoadLibrary() wie Du mit Bass.dll. Was er beschreibt ordne ich eher .OCX (ActiveX) zu.
Ich verwende kein LoadLibrary wer sagt dir das?

Das einzige Problem das er haben könnte wenn er die Umgebung setzt das der seltsame Compiler von Delphi die DLL selber lädt bevor er die Umgebung setzen kann.
Wenn also die DLL dann nicht gefunden wird startet das Programm erst gar nicht.
VB zum Beispiel tut das nicht.

Beispiel:
Delphi-Quellcode:
var
  MeinDLLPath: string;

begin

  MeinDLLPath := ExtractFilePath(ParamStr(0)) + 'Meine_Lib';
  SetEnvironmentVariable(PWideChar('Path'), PWideChar(MeinDLLPath));
  if not FileExists(ExtractFilePath(ParamStr(0)) + 'Meine_Lib\Meinelib.dll') then
    Halt;
end;
Ich befürchte aber das es trotz meiner Aussage bedingt durch den Compiler von Delphi nicht funktionieren wird wenn es keinen Schalter gibt
der verhindert das die Anwendung sich beendet wenn die DLL nicht gefunden wird bevor man die Umgebung setzen kann.

Zumindest unter VB gibt es diesbezüglich keine Probleme ohne LoadLibrary.
Vielleicht kann man das umgehen wenn man vorher eine Batchdatei erstellt. (nicht getestet)

gruss

Geändert von EWeiss (22. Jun 2018 um 01:53 Uhr)
  Mit Zitat antworten Zitat
EWeiss
(Gast)

n/a Beiträge
 
#2

AW: DLL Side-by-side registration & redirection

  Alt 22. Jun 2018, 01:46
Hier ein Beispiel in Sharp..
Von meinem BassVis Example in C# (Sharp)

Code:
private void BassInit()
{
  string BassPath;
  string BassVisPath;
  BASS_DEVICEINFO info;

  BassPath = Path.Combine(Application.StartupPath, "BassLib");
  Win32Api.SetEnvironmentVariable("Path", BassPath);

  // check the correct BASS was loaded
  if (Win32Api.HiWord(Bass.BASS_GetVersion()) != Bass.BASSVERSION)
  {
    MessageBox.Show("BASS_Vis.DLL existiert nicht!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
    Application.Exit();
  }

  //Set Path to AddOns
  BassVisPath = Path.Combine(Application.StartupPath, "BassADDOn");

  Win32Api.SetEnvironmentVariable("Path", BassVisPath);

  //Check "bass_Vis.dll" exist

  string visDll = Path.Combine(Application.StartupPath, @"BassADDOn\bass_Vis.dll");

  if (!File.Exists(visDll))
  {
    MessageBox.Show("BASS_Vis.DLL failed to load!", "BASS_Vis.DLL", MessageBoxButtons.OK, MessageBoxIcon.Error);
    Application.Exit();
  }

  // setup recording and output devices (using default devices)
  if ((Bass.BASS_RecordInit(-1) == false) || (Bass.BASS_Init(-1, 44100, 0, Handle, Guid.Empty) == false))
  {
    MessageBox.Show("Can\'t initialize device", "BASS.DLL", MessageBoxButtons.OK, MessageBoxIcon.Error);
    Application.Exit();
  }
  else
  {
    input_ = 0;
    info = new BASS_DEVICEINFO();
    while (Bass.BASS_RecordGetDeviceInfo(input_, info))
    {
      Bass.BASS_RecordGetDeviceInfo(input_, info);
      cmbInputs.Items.Add(info.name);
      input_++;
    }
    cmbInputs.SelectedIndex = 0;
  }

  Text = "Bass_Vis Example for C# VS2012: BassVis Version: " + BassVis.BASSVIS_GetVersion();
  Width = 498;
}

#endregion BassInit()
Ich setze die Umgebung nur für diese Anwendung nicht global von außen kann das also niemand sehen.
Die Anwendung startet ohne zu murren und die DLL's werden gefunden.

Und nein die DLL's werden nicht dynamisch geladen.
Ich glaube aber das Problem ist Delphi in dem Fall.
Zitat:
das tun wohl irgendwelche Delphi-Automatismen im Hintergrund.
gruss

Geändert von EWeiss (22. Jun 2018 um 02:20 Uhr)
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:45 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz