Link to home
Start Free TrialLog in
Avatar of d32coder
d32coder

asked on

dll.. XP vs. 98/Me

Any ideas?
look at this dll (the ShellExecute line), it doesn't open the exe in 98 or Me but will in XP.  

---------
library EZServe;

uses
  SysUtils, Classes, dialogs, ShellAPI, Windows, Messages;

{$R *.res}

function SendData(mWnd,aWnd: HWND; data, parms: PChar; show,nopause: LongBool): integer; Stdcall;
 var hWnd: THandle; cds: CopyDataStruct;
begin
    hWnd := FindWindow(nil,'EZServe v1.0');
    if hWnd <> 0 then
      begin
       cds.dwData := 3232;
       cds.cbData := StrLen(Data);
       cds.lpData := data;
       SendMessage(hWnd, WM_COPYDATA, 0, LongInt(@cds));
      end;
  Result := 1;
End;

function OpenEzServe(mWnd,aWnd: HWND; data, parms: PChar; show,nopause: LongBool): integer; Stdcall;
 var hWnd: THandle;
begin
    hWnd := FindWindow(nil,'mIRC');
    if not FileExists('EZServe.exe') then Showmessage('EZSere.exe not found.');
    ShellExecute(hWnd,'open','EZServe.exe',data,nil,SW_SHOWNORMAL);
    Result := 1;
End;

exports SendData,OpenEzServe;

END.

Avatar of Lee_Nover
Lee_Nover

where is this EZServe.exe ?
if it's in the environment path then it should work
the most common paths are:
c:\winnt\system32\ - windows nt system folder
c:\windows\system\ - win9x system fodler

the file search order is as folows:
 - folder of the callers process module
 - system folder
 - windows folder
 - other paths in the PATH list

if you use the full path it should work all the time

just a tip:
using ShowMessage in a dll is not good because it's VCL and thus not thread safe
rather use MessageBox which is a system function
your dll size will be reduced greatly and the memory consumption will be smaller also
don't forget to remove Dialogs from the uses clause :)
i ahve a windows xp and i don't have EZserve.exe file
Avatar of d32coder

ASKER

I wrote the EZServe.exe as well and it resides in the same folder as the dll.  

I'm going to get rid of the showmessage anyway.

Do I need to use the full path if they are in the same folder?
ASKER CERTIFIED SOLUTION
Avatar of mikepj
mikepj
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Turns out the problem was in the calling application, not the dll.

Points for mikepi as I used the iResult routine.

Thanks for everyone's comments.
Don