Re: Passing info between a DLL and an app



I am not sure if this will cure the problem. I have had bunches of
problems executing dlls in Delphi. Try executing your dll in a
procedure by itself like the one below. This seems to have cured my
dll execution problems.

procedure TForm1.LoadAndRunDLLProcedure(sDLL, sFunc : string);
type
TFunc_Start = function(pRiseSetLat, pRiseSetLong : string;
RiseSetOffset : real;
RiseOrSetSw, passmmddyyyy: string) : string;
var
Func_Start : TFunc_Start;
hDll : THandle;
FuncPtr : TFarProc;
sMsg : string;
begin
hDll := LoadLibrary( PChar( sDLL ) );

if (hDll > 32) then begin
FuncPtr := GetProcAddress( hDll, PChar( sFunc ) );
@Func_Start := FuncPtr;

if (@Func_Start <> nil) then begin
LabelRise.Caption := Func_Start(CurrencyEditN1.Text,
CurrencyEditW2.Text, -6, 'r',
FormatDateTime('mmddyyyy',
Now));
LabelSet.Caption := Func_Start(CurrencyEditN1.Text,
CurrencyEditW2.Text, -6, 's',
FormatDateTime('mmddyyyy',
Now));
end
else begin
sMsg := 'DLL entry point ' + sFunc + ' not found';
//procedure not found
MessageBox( 0, PChar( sMsg ), 'Error', MB_OK );
end;

FreeLibrary( hDll );
FuncPtr := NIL;

end
else begin
sMsg := 'File ' + sDLL +' not found';
//dll not found
MessageBox( 0, PChar( sMsg ), 'Error', MB_OK );
end;
end;

.



Relevant Pages

  • Re: Passing info between a DLL and an app
    ... problems executing dlls in Delphi. ... dll execution problems. ... RiseOrSetSw, passmmddyyyy: string): string; ... hDll: THandle; ...
    (alt.comp.lang.borland-delphi)
  • Re: Passing info between a DLL and an app
    ... I can pass an Object as a param to my DLL ... RiseOrSetSw, passmmddyyyy: string): string; ... hDll: THandle; ... FuncPtr: TFarProc; ...
    (alt.comp.lang.borland-delphi)
  • Help DLL calling in Excel 2007 crashes
    ... functions calls a function in a DLL and when that DLL function returns, ... VBA continues executing by starting the same VBA function over. ... ByRef szCompany As String, ByRef szCode As String) As Long ...
    (microsoft.public.excel.programming)
  • Calling Methods in Sibling Class Module
    ... both in the same DLL. ... When executing a "write" method, ... string generated by "read" method. ... Somehow I figured out that if I add a .bas module with the line "Public ...
    (microsoft.public.vb.com)
  • Re: Accessing global variables in EXE from DLL
    ... > file from a DLL? ... void __declspecdllfunc; ... int __declspecjunk; ... less ignore) some error messages while executing the following steps: ...
    (microsoft.public.vc.mfc)