Solved

Desktop Subclass Problem

Posted on 2001-09-05
3
397 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
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…

856 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