Solved

Desktop Subclass Problem

Posted on 2001-09-05
3
398 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 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