Forum > General
GetProcAdress returns valid pointer but execution returns: "External exception:"
Shpend:
Title.
this is the function and i just cant see why :(
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function LoadCOMLib: string; var funcPtr: InputToStrFunc; //the definition of this is: function():integer; //sometimes even added with stdcall or cdecl still no work.. path: string; handleToLib: HWND; funcReturn: integer; begin GetDir(0, path); path := Concat(path, '\', 'UnmanagedExport__TEST.dll'); handleToLib := LoadLibrary(PChar(path)); if handleToLib <> NilHandle then begin try funcPtr := InputToStrFunc(GetProcAddress(handleToLib, 'AllocRecord')); //funcPtr('TEST', funcReturn); funcReturn := funcPtr(); Result := IntToStr(funcReturn); RaiseLastWin32Error; //result = Concat(result, 'A'); //result := 'YEEAAA it works' + IntToStr(funcReturn); except on e: Exception do begin FreeLibrary(handleToLib); Result := e.Message; end; end; end else Result := 'Er hat die Library nicht gefunden irgendwie'; end;
Much appreciation if any1 has a glimpse why.
BTW: i try to import a .NET 6 assembly (with .net 6 features) but there is a project on github allowing do use [DllExport] and i followed everys tep carefully like he does in this video: https://www.youtube.com/watch?v=QXMj9-8XJnY
https://github.com/3F/Conari
Idk ..
Shpend:
Small Addition:
OS: windows 10 x64 latest version (21h2)
FPC: 3.3.1 (trunk) ; x64 setting, O0 optimization
Lazarus 2.3.0 (trunk)
440bx:
You're not testing the value returned by GetProcAddress. That would be the first thing to do, otherwise FuncPtr may be nil.
HTH.
engkin:
AllocRecord signature?
InputToStrFunc definition?
Shpend:
it is not nil @440bx
it has an arbitrary adress. i see it via the debugger.
Navigation
[0] Message Index
[#] Next page