|
Hi !
When my app is installed on a user's computer, the install is made in Admin mode. Some settings are stored in the registry in the LOCAL_MACHINE keys.
Users then use it, the app stores their settings in the registry (in the CURRENT_USER keys).
Later on, the admin wants to uninstall my app. I need to clear each users's registry to get rid of their settings. I didn't find a way, when logged as an admin, how to reach each local user of the machine and get rid of keys.
Could anyone help me regarding this issue ?
Thanks !
Jerome
|
|
|
|
|
Iterate nodes of HKEY_USERS and access your specific application keys.
This will get you to each user's "current user" keys.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
Have any poker playing developers got anywhere with online screen scraping methods to read card / bot / player position from poker rooms? I want to write a semi auto super system - which gives me playing tips while i play - based on my own rules and poker thinking. but screen scraping, I got no idea where to start, it sounds extremely ugly and unreliable. Anyone that has got somewhere in this area I love to hear from
"Life begins at 140"
|
|
|
|
|
Sure! I did this with an online version of the Diamond Mine game to automatically solve the mine puzzles. It could scrape a bitmap and decode object positions and build an internal table and then calculate the best move to make.
You can download the source code at:
http:
<code>NO CARRIER</code>
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Thanks for response but your link is incorrect.
I tried searching on filetransit.com but could not find it.
"Life begins at 140"
|
|
|
|
|
georgekjolly wrote: How can I get it .
Try looking in the C++/MFC articles here on Code Project. I know there are some there, also msdn.microsoft.com has them.
led mike
|
|
|
|
|
I have a button on a dialog and i would like to place an image on that button.
How is that done?
|
|
|
|
|
LCI wrote: How is that done?
By reading this.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
You can also use BS_BITMAP style for the button and set bitmap by sending BM_SETIMAGE message.
example:
result = SendMessage(hWnd, BM_SETIMAGE, IMAGE_BITMAP, (LPARAM)(HBITMAP)hBitmap);
Hope that helps...
Regards
|
|
|
|
|
|
When an application's form is minmum to the taskbar or hide,how to hook the messages of the form?I have developed an application that can hook a form's messages when the form on the desktop.But when the form is minmum to the taskbar or the form is hidden,the hook message application could not hook nothing of the form.In fact ,the messages of the form happen,such as a message that a disable button is changed to an enable button.Please help me!
Thanks alot!
|
|
|
|
|
Are you using SetWindowsHookEx API? Once you install the hook with the thread ID of the application, the hook remains even though it is hidden.
How did you determine it's not working?
|
|
|
|
|
I use SetWindowsHookEx API,but I use SubClass to hook the other application's message.When the hooked form is on the desktop,the hook application can hook all messages of the destination application.But when the form is minmum,the hook can't hook any messages of the destination application.
|
|
|
|
|
I've been battling the hooking and subclassing for the last 3 or 4 weeks. I finally get it to work. You haven't answered the question.
How did you determine it's not working when the form is minimized?
If the destination application is running in another process, you won't be able to step your code in the debugger. Instead, you should open up a new visual studio instance, attach to the process of the destination application, open the file you want to debug, add breakpoints.
Or, use the OutputDebugString API to print out all the window messages and Sysinternals DebugView to see the debug messages.
Are you hooking to WH_CBT or WH_CALLWNDPROC? Perhaps you should paste portion of your code here (especially the part where you call SetWindowsHookEx and SetWindowLong) if you really need help.
|
|
|
|
|
Thanks your reply.I use Delphi7 not VC.My source code is as following.
library MyHook;
uses
SysUtils,
windows,
Messages;
const
WM_UNSUBCLASS = WM_USER + 1001;
WM_NEWMESSAGE = WM_USER + 1002;
HOOK_EVENT_NAME = 'MyHook';
type
PMyDLLVar = ^TMyDLLVar;
TMyDLLVar = record
SubClass: Boolean;
HookWindow, SpyWindow: LongWORD;
hHook: LongWORD;
OldWndProc: pointer;
MsgHwnd: LongWORD;
Msg: TMessage;
end;
var
DLLData: PMyDLLVar;
function NewWndProc(hHwnd, Msg, wParam, lParam: LongWORD): Longint; stdcall;
begin
Result := 0;
if Msg = WM_UNSUBCLASS then
begin
SetWindowLong(DLLData^.HookWindow, GWL_WNDPROC, longint(DLLData^.OldWndProc));
exit;
end;
DLLData^.Msg.Msg := Msg;
DLLData^.Msg.WParam := wParam;
DLLData^.Msg.LParam := lParam;
DLLData^.MsgHwnd := hHwnd;
SendMessage(DLLData^.SpyWindow, WM_NEWMESSAGE,Msg,lParam);
Result := CallWindowProc(DLLData^.OldWndProc, hHwnd, Msg, wParam, lParam);
end;
Function HookProc(nCode:integer; wParam:WPARAM; lParam: LPARAM):LRESULT;stdcall;
var
hEvent: THandle;
begin
if not DllData^.SubClass then
begin
hEvent := OpenEvent(Synchronize, False, HOOK_EVENT_NAME);
if hEvent <> 0 then
begin
WaitForSingleObject(hEvent, INFINITE);
CloseHandle(hEvent);
end;
DLLData^.OldWndProc := pointer(GetWindowLong(DLLData^.HookWindow, GWL_WNDPROC));
SetWindowLong(DLLData^.HookWindow, GWL_WNDPROC, integer(@NewWndProc));
DLLData^.SubClass := True;
end;
Result := CallNextHookEx(DLLData^.hHook, nCode, wParam, lParam);
end;
function InstallHook(HWindow, SWindow: LongWORD):Boolean;stdcall;
var
ThreadID: LongWORD;
hEvent: THandle;
begin
Result := False;
DLLData^.hHook := 0;
DLLData^.HookWindow := HWindow;
DLLData^.SpyWindow := SWindow;
ThreadID := GetWindowThreadProcessId(HWindow, nil);
hEvent := CreateEvent(nil, True, False, HOOK_EVENT_NAME);
DLLData^.hHook := SetWindowsHookEx(WH_GETMESSAGE, @HookProc, Hinstance, ThreadID);
SetEvent(hEvent);
CloseHandle(hEvent);
if DLLData^.hHook > 0 then Result := True; {是否成功HOOK}
end;
procedure UnHook;stdcall;
begin
SendMessage(DLLData^.HookWindow, WM_UNSUBCLASS, 0, 0);
DLLData^.SubClass := False;
{卸载Hook}
UnhookWindowsHookEx(DLLData^.hHook);
end;
procedure MyDLLHandler(Reason: Integer);
var
FHandle: LongWORD;
begin
case Reason of
DLL_PROCESS_ATTACH:
begin
FHandle := CreateFileMapping($FFFFFFFF, nil, PAGE_READWRITE, 0, $ff, 'MYDLLDATA');
if FHandle = 0 then
if GetLastError = ERROR_ALREADY_EXISTS then
begin
FHandle := OpenFileMapping(FILE_MAP_ALL_ACCESS, False, 'MYDLLDATA');
if FHandle = 0 then Exit;
end else Exit;
DLLData := MapViewOfFile(FHandle, FILE_MAP_ALL_ACCESS, 0, 0, 0);
if DLLData = nil then
CloseHandle(FHandle);
end;
DLL_PROCESS_DETACH:
if Assigned(DLLData) then
begin
UnmapViewOfFile(DLLData);
DLLData := nil;
end;
DLL_THREAD_ATTACH:;
DLL_THREAD_DETACH:;
end;
end;
{$R *.res}
exports
InstallHook, UnHook, HookProc;
begin
DLLProc := @MyDLLHandler;
MyDLLhandler(DLL_PROCESS_ATTACH);
end.
|
|
|
|
|
Sorry I don't know Delphi and it's hard to read the code without the indention. You can first try the equivalent methods of attaching to a process and printing debug messaegs.
You still haven't answered the question I asked in the first place. You might want to read it again carefully.
Perhaps by definition WH_GETMESSAGE hook is not meant to be called when the window is minimized? Or the minimized application indeed has no messages in the queue? Or did you unhook or "unsubclass" prematurely? I don't know, you will have to research these.
|
|
|
|
|
yeah,The Delphi code is not same as VC.But Could you show me some code ,I can read the VC or C++ code.Thanks!
|
|
|
|
|
Because I use a timer in the form,I write some code to set a button's enable property at interval.When the form is on desktop, my hook application can hook the message,but when the form minmum my hook application can't.
|
|
|
|
|
The key here is WH_GETMESSAGE. Are you sure the minimized application should be getting messages? I could be wrong. I thought the minimized application would be in the idle loop. I used Spy++ to monitor all standard window messages of a minimized application and I don't see any. Do you expect custom control messages? If not, I think what you are seeing is the correct behavior. I don't think Spy++ will miss out any.
I used WH_CALLWNDPROC and WH_CBT and they behave differently from WH_GETMESSAGE. I have the similar code to hook and subclass, I don't think that part of your code is wrong.
|
|
|
|
|
At first,Thanks your reply!As you said,When the application is minimized the Spy++ could not hook the messages!But the application is runing.Of course,the application must produce some messages to notify it's child-component such as button,listbox,prograss bar and so on.If the application is in the idle loop,how does it's child-component get the notify_message?Please help me!Thanks!
|
|
|
|
|
I don't think you understand what I was saying. You can use Spy++ to log ALL messages of the window and ALL its child windows before you minimize the application, then only you minimize it.
I'm outta ideas to suggest to you (that you actually try). Good luck!
|
|
|
|
|
Sorry I didn't see your post about the timer. Why don't you use Spy++ to monitor it and see if it gets any timer messages? If it doesn't, then your code behaves correctly. If it does, I suggest you to add a bunch of debug messages where the timer starts, ends, etc and analyze them in DebugView.
|
|
|
|
|
When an application's form is minmum to the taskbar or hide,how to hook the messages of the form?I have developed an application that can hook a form's messages when the form on the desktop.But when the form is minmum to the taskbar or the form is hidden,the hook message application could not hook nothing of the form.In fact ,the messages of the form happen,such as a message that a disable button is changed to an enable button.Please help me!
Thanks alot!
|
|
|
|
|
please help me.I have searched on google and msdn,but all ways can only hook the application with forms.But when the form is hidden,how to hook the messages when the states of the components on the form is changing?Please help me!
|
|
|
|
|
Hello, I am new to programming C++. Can anyone help me with this problem:
C2248: cannot access protected struct declared in class.
It occurs when I want to fill a struct in another class, which is declared private (and should stay private).
Do I have to develop a public function in this class which acceses my struct ?
I do not know how to proceed...
Thanks for your help
|
|
|
|
|