Leslie7
asked on
Error loading Midas.dll
Hi,
Does midas.dll need to be somehow introduced to windows?
I have a small app which is is sent to potential client companies to present some data . It was planned to be a "breafcase" app, which does not require any installation. It is based on TClientDataSet components which requires midas.dll. In most cases sending the dll with the program worked ok, but sometimes I got the "Error loading Midas.dll" message. How can I make sure that my app will work on any windows (win32)?
Regards, Leslie
Does midas.dll need to be somehow introduced to windows?
I have a small app which is is sent to potential client companies to present some data . It was planned to be a "breafcase" app, which does not require any installation. It is based on TClientDataSet components which requires midas.dll. In most cases sending the dll with the program worked ok, but sometimes I got the "Error loading Midas.dll" message. How can I make sure that my app will work on any windows (win32)?
Regards, Leslie
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It also needs to be registered (regsvr320 midas.dll) with windows.
Starting from Delphi 7, you can include MidasLib in your project's uses. That will link the MIDAS/DataSnap code directly into your executable, and you don't need to deploy midas.dll anymore.
ASKER
Hi Experts,
I apologize for the late reaction, but I wasn't in the office ...
DragonSlayer
Simply copying Midas.dll to the system folder is not enough on all machines, but the link helped me to compile it to the exe. (It was so easy ... I should have thought of it. :))
eholton
DragonSlayer provided me the answer, but I would like to learn how to register Midas.dll. If you could tell me, it would be worth for an other 200 points.
Thanks for your help!
Regards, Leslie
I apologize for the late reaction, but I wasn't in the office ...
DragonSlayer
Simply copying Midas.dll to the system folder is not enough on all machines, but the link helped me to compile it to the exe. (It was so easy ... I should have thought of it. :))
eholton
DragonSlayer provided me the answer, but I would like to learn how to register Midas.dll. If you could tell me, it would be worth for an other 200 points.
Thanks for your help!
Regards, Leslie
Hi Leslie,... you can try something like this:
uses ShellApi;
function ExecAndWait(const ExecuteFile, ParamString : string): boolean;
var
SEInfo: TShellExecuteInfo;
ExitCode: DWORD;
begin
FillChar(SEInfo, SizeOf(SEInfo), 0);
SEInfo.cbSize := SizeOf(TShellExecuteInfo);
with SEInfo do begin
fMask := SEE_MASK_NOCLOSEPROCESS;
Wnd := Application.Handle;
lpFile := PChar(ExecuteFile);
lpParameters := PChar(ParamString);
nShow := SW_HIDE;
end;
if ShellExecuteEx(@SEInfo) then
begin
repeat
Application.ProcessMessage s;
GetExitCodeProcess(SEInfo. hProcess, ExitCode);
until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
Result:=True;
end
else Result:=False;
end;
procedure RegisterOCX;
type
TRegFunc = function : HResult; stdcall;
var
ARegFunc : TRegFunc;
aHandle : THandle;
ocxPath : string;
begin
try
ocxPath := FullPathToMidasDLL; // e.g. C:\Windows\System32\Midas. dll, or C:\MyApp\Midas.dll
aHandle := LoadLibrary(PChar(ocxPath) );
if aHandle <> 0 then
begin
ARegFunc := GetProcAddress(aHandle,'Dl lRegisterS erver');
if Assigned(ARegFunc) then
begin
ExecAndWait('regsvr32','/s ' + ocxPath);
end;
FreeLibrary(aHandle);
end;
except
ShowMessage(Format('Unable to register %s', [ocxPath]));
end;
end;
so all you need to do now is to call RegisterOCX to register your midas.dll
uses ShellApi;
function ExecAndWait(const ExecuteFile, ParamString : string): boolean;
var
SEInfo: TShellExecuteInfo;
ExitCode: DWORD;
begin
FillChar(SEInfo, SizeOf(SEInfo), 0);
SEInfo.cbSize := SizeOf(TShellExecuteInfo);
with SEInfo do begin
fMask := SEE_MASK_NOCLOSEPROCESS;
Wnd := Application.Handle;
lpFile := PChar(ExecuteFile);
lpParameters := PChar(ParamString);
nShow := SW_HIDE;
end;
if ShellExecuteEx(@SEInfo) then
begin
repeat
Application.ProcessMessage
GetExitCodeProcess(SEInfo.
until (ExitCode <> STILL_ACTIVE) or Application.Terminated;
Result:=True;
end
else Result:=False;
end;
procedure RegisterOCX;
type
TRegFunc = function : HResult; stdcall;
var
ARegFunc : TRegFunc;
aHandle : THandle;
ocxPath : string;
begin
try
ocxPath := FullPathToMidasDLL; // e.g. C:\Windows\System32\Midas.
aHandle := LoadLibrary(PChar(ocxPath)
if aHandle <> 0 then
begin
ARegFunc := GetProcAddress(aHandle,'Dl
if Assigned(ARegFunc) then
begin
ExecAndWait('regsvr32','/s
end;
FreeLibrary(aHandle);
end;
except
ShowMessage(Format('Unable
end;
end;
so all you need to do now is to call RegisterOCX to register your midas.dll
Another way is to put the .dll in the same folder as your application file (.exe) but for that to work, you have to make sure that your shortcut's "Start In Directory" is the application directory and is not empty.