View Single Post
  #4 (permalink)  
Old 22nd March 2003
s_bostjan s_bostjan is offline
Junior Member
BS.Player Newbie
 
Join Date: Mar 2003
Location: Slovenia
Posts: 2
Rep Power: 0
s_bostjan is an unknown quantity at this point
Default

Try it with the handle of the dll.

cds.dwData:=SendMessage(FindBsplayer,WM_COPYDATA,A pplication.Handle,lParam(@cds));

If you get an Error with 'Application' add the Forms and Windows units to the DLL unit. I don't remember if a dll project adds this two units for you. (the Application object is declared in the Forms unit, while the THandle data type is stored in the Windows unit)

Another way would be that you use the handle of the application that calls your dll:

Code:
procedure dllFunction(AHandle: THandle); 
var 
  OldHandle: THandle; 
begin 
  // Store the DLLs handle 
  OldHandle := Application.Handle; 
  // Assign the handle of the main application to the DLL's handle 
  Application.Handle := AHandle; 

  // now do what you want
  SendMessage(F.....

  // Restore the DLL's old handle, otherwise when freeing the DLL 
  // the application will close at the same time. 
  Application.Handle := OldHandle; 
end;
In the calling application would you call your function like this:

Code:
begin 
  ... 
  dllFunction(Application.Handle); 
  ... 
end;
I realy haven't been using Delphi for some time now so sorry if i told you just garbage.
Reply With Quote
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20