Solved

Desktop Subclass Problem

Posted on 2001-09-05
3
394 Views
Last Modified: 2010-08-05
I wrote this dll, and it isn't working. Can anybody help?

--------------------------------------------------------
library Desktop;

uses
  SysUtils, Classes,windows, Messages, Dialogs;

const
    WM_PAINTPRIVATE_MESSAGE = WM_USER + 322;

var oldWndProc: Integer;

function myDesktopWndProc(WindowHandle:hWnd; TheMessage:Longint; ParamW:Longint;ParamL:Longint):LongInt; stdcall;
begin
  case TheMessage of
  xxx : ShowMessage('Testing...');
  end;

   myDesktopWndProc := CallWindowProc(Pointer(OldWndProc),WindowHandle, TheMessage, ParamW, ParamL);
end;


procedure SetProc; stdcall;
var FhDesktopWnd : HWND;
    FDesktopWndInstance : TFarProc;
    Errol : Cardinal;
    DProc : LongInt;
begin

 oldWndProc:=GetWindowLong(GetDesktopWindow, GWL_WNDPROC);
 if SetWindowLong( GetDesktopWindow, GWL_WNDPROC, Longint(@myDesktopWndProc))=0 then
  begin
  Errol:= GetLastError;
  showmessage(inttostr(Errol));

  end
  else
   showmessage('Set')
end;

procedure KillProc; stdcall;
begin
  SetWindowLong( GetDesktopWindow, GWL_WNDPROC, LongInt(oldWndProc));
  showmessage('Kill')
end;


exports SetProc index 1,
        KillProc index 2;
begin

end.




--------------------------------------------------------

I get the ERROR_CALL_NOT_IMPLEMENTED error when I call then SetWindowLong function.


Regards,
guitfatio
0
Comment
Question by:guitfatio
3 Comments
 
LVL 14

Accepted Solution

by:
DragonSlayer earned 25 total points
ID: 6459374
Check out Madshi's comment (it's at the bottom of the page):

http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20178822
0
 
LVL 20

Assisted Solution

by:Madshi
Madshi earned 25 total points
ID: 6460063
:-)

The problem is that SetWindowLong is only supported for windows that belong to the current process. So your dll can call SetWindowLong only, if your dll is loaded in the context of the explorer process. See DragonSlayer's link for more information...

Regards, Madshi.
0
 
LVL 17

Expert Comment

by:geobul
ID: 9295457
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

split points between DragonSlayer and Madshi

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Thanks,

geobul
EE Cleanup Volunteer
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now