Einzelnen Beitrag anzeigen

Benutzerbild von lbccaleb
lbccaleb

Registriert seit: 25. Mai 2006
Ort: Rostock / Bremen
2.037 Beiträge
 
Delphi 7 Enterprise
 
#3

AW: load a dll at run-time

  Alt 27. Nov 2013, 18:46
Do you really still use jump marks?

A example how you can dynamically load a Libary can you find here:
http://www.delphipraxis.net/175591-d...ml#post1220503

Edit1:
Btw, you have to link external Posts:
http://forum.delphi-treff.de/index.p...threadID=59293


Edit2:
Delphi-Quellcode:
program GurobiTest;
{$APPTYPE CONSOLE}
uses System.SysUtils, Windows;

//label QUIT;
type
  pAChar = pAnsiChar;
  GRBenv = pointer;
  GRBmodel = pointer;

var
  h: HMODULE;
  err: integer;
  grEnv: GRBenv;
  grLp: GRBmodel;

   GRBloadenv: function(var envP:GRBenv; logfilename:pAChar):integer; stdcall;
   GRBreadmodel: function(env:GRBenv; filename:pAChar; var mp:GRBmodel):integer; stdcall;
   GRBoptimize: function(model:GRBmodel):integer; stdcall;

begin;
  
  h := LoadLibrary('C:/gurobi550/win64/bin/gurobi55.dll');
  if h = 0 then begin;
    ShowMessage('Cannot load dll');
    Exit;
  end;

  GRBloadenv := GetProcAddress(h,'GRBloadenv');
  GRBreadmodel := GetProcAddress(h,'GRBreadmodel');
  GRBoptimize := GetProcAddress(h,'GRBoptimize');

  if Assigned(GRBloadenv) then begin;
    err := GRBloadenv(grEnv, 'gurobi.log');
    if err <> 0 then
      //MessageBox?
  end;

  if Assigned(GRBreadmodel) then begin;
    err := GRBreadmodel(grEnv, 'ALUAM.mps', grLp);
    if err <> 0 then
      //MessageBox?
  end;

  if Assigned(GRBoptimize) then begin;
    err := GRBoptimize(grLp);
    if err <> 0 then
      //MessageBox?
  end;

  FreeLibrary(h);
end.
-->not testet
Martin
MFG Caleb
TheSmallOne (MediaPlayer)
Die Dinge werden berechenbar, wenn man die Natur einer Sache durchschaut hat (Blade)

Geändert von lbccaleb (27. Nov 2013 um 19:19 Uhr)
  Mit Zitat antworten Zitat