Click here to Skip to main content
15,896,269 members
Home / Discussions / System Admin
   

System Admin

 
GeneralRe: Internet gets disconnected... :( Pin
Eytukan11-Jun-06 20:53
Eytukan11-Jun-06 20:53 
QuestionCannot Access shared folder in win service on Win 2003 server Pin
LoveMay25-May-06 10:19
LoveMay25-May-06 10:19 
AnswerRe: Cannot Access shared folder in win service on Win 2003 server Pin
Mekong River25-May-06 15:57
Mekong River25-May-06 15:57 
AnswerRe: Cannot Access shared folder in win service on Win 2003 server Pin
progload25-May-06 19:43
progload25-May-06 19:43 
GeneralRe: Cannot Access shared folder in win service on Win 2003 server Pin
LoveMay26-May-06 3:12
LoveMay26-May-06 3:12 
QuestionMarvell Yukon network controller - Crap? Pin
Ray Cassick25-May-06 6:30
Ray Cassick25-May-06 6:30 
AnswerRe: Marvell Yukon network controller - Crap? Pin
Mekong River25-May-06 15:44
Mekong River25-May-06 15:44 
QuestionInserting a button into another application's window Pin
tuckmeng25-May-06 5:47
tuckmeng25-May-06 5:47 
Hi,

I'm learning how to insert a button into another application's window using c programming. In short, I wrote an EXE file which modified a particular Window of another EXE file to insert a button in that window. Need some advice:

a. I was able to get to the other application's window by first hooking onto the other application's window handle. But the strange thing is that my callback function for WM_LBUTTONDOWN of my introduced button was not called when I click on the inserted button. Instead, I had to do a GetMessage in my main program to get the message for the button and check the message member in there. With this, I was able to insert an extra button into a messagebox in another EXE file while it's running.

b. What I don't quite understand is that when I try to use the same technique on different windows, I get different errors. For instance, if I were to insert a button this way into a .NET window, the button shows up as a white patch. It responds to the click though. For some other programs, my button crashed without inserting itself. Puzzled by the different behaviour. Is it due to the windows message queue and the different nature of windows that I'm getting this?

c. Strangely, although my callback WinProc function is not called when I click on the button, not defining the WinProc actually causes my program to die when attaching itself to any window that's not a messagebox. Not quite sure why.

If someone can guide me to any article on how to insert controls into another app's windows or to understand the windows message loop more, I would be grateful. I'm trying to do a little enhancement to a program whose source code is lost (ie, I only have the binary).

My code looks like this:

#include <windows.h>
#include <stdio.h>

LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);

int WinMain(HINSTANCE hInst,HINSTANCE,LPSTR,int)
{
HWND hWnd, hwndButton;
WNDCLASS wc;
MSG msg;
// Trace Windows Handle based on Name
hWnd = (HWND) 0x1D0458;
printf("Begin Program\n");

wc.style=CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc=WindowProc;
wc.cbClsExtra=0;
wc.cbWndExtra=0;
wc.hInstance=hInst;
wc.hIcon=NULL;
wc.hCursor=NULL;
wc.hbrBackground=(HBRUSH)COLOR_WINDOWFRAME;
wc.lpszMenuName=NULL;
wc.lpszClassName="BUTTON";

if (!RegisterClass(&wc)) return 0;
printf("Finished Creating Button");
hwndButton = CreateWindow(
"BUTTON", // predefined class
"H", // button text
WS_VISIBLE | WS_CHILD , // styles

// Size and position values are given explicitly, because
// the CW_USEDEFAULT constant gives zero values for buttons.
950, // starting x position
0, // starting y position
20, // button width
20, // button height
hWnd, // parent window
NULL, // No menu
(HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE),
NULL); // pointer not needed

if (!hwndButton) return 0;

ShowWindow(hwndButton,SW_SHOW);
UpdateWindow(hwndButton);
while (GetMessage(&msg,NULL,0,0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
printf("In Message Loop");
if (msg.message == WM_LBUTTONDOWN) {
MessageBox(0,"Button Worked in main loop","Button Worked",MB_OK);
printf("Works!");
ShowWindow(hwndButton,SW_SHOW);
} // end if
if (msg.message == WM_DESTROY) {
printf("Quitting\n");
// exit(0);
} // end if
} // end while

}// end all

LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
return DefWindowProc(hwnd, msg, wparam, lparam);
}
AnswerRe: Inserting a button into another application's window Pin
Eytukan25-May-06 6:06
Eytukan25-May-06 6:06 
QuestionProblem in running EXE File Pin
k.n.ruban24-May-06 22:56
k.n.ruban24-May-06 22:56 
AnswerRe: Problem in running EXE File Pin
Mekong River25-May-06 15:39
Mekong River25-May-06 15:39 
AnswerRe: Problem in running EXE File Pin
arunmahe25-May-06 22:38
arunmahe25-May-06 22:38 
GeneralRe: Problem in running EXE File Pin
k.n.ruban26-May-06 19:00
k.n.ruban26-May-06 19:00 
GeneralRe: Problem in running EXE File Pin
Mekong River28-May-06 14:53
Mekong River28-May-06 14:53 
Questionnetwork share "pretend" local device anyone?? Pin
GlenJDiamond24-May-06 21:48
GlenJDiamond24-May-06 21:48 
AnswerRe: network share "pretend" local device anyone?? Pin
Mekong River25-May-06 15:33
Mekong River25-May-06 15:33 
QuestionWindows Active Directory Error "LDAP_SIZELIMIT_EXCEEDED" Pin
jcemergin24-May-06 8:26
jcemergin24-May-06 8:26 
QuestionNeed an example of winnt32 for unattend installation Pin
Mekong River24-May-06 5:35
Mekong River24-May-06 5:35 
AnswerRe: Need an example of winnt32 for unattend installation Pin
Dan Neely24-May-06 6:56
Dan Neely24-May-06 6:56 
GeneralRe: Need an example of winnt32 for unattend installation Pin
Mekong River24-May-06 15:43
Mekong River24-May-06 15:43 
QuestionDVD Multi Recorder problem Pin
Sarath C23-May-06 21:00
Sarath C23-May-06 21:00 
AnswerRe: DVD Multi Recorder problem Pin
Mekong River23-May-06 21:26
Mekong River23-May-06 21:26 
QuestionHow to Stop an Exe File through Command Prompt By Executing a Batch File Pin
k.n.ruban23-May-06 18:53
k.n.ruban23-May-06 18:53 
AnswerRe: How to Stop an Exe File through Command Prompt By Executing a Batch File Pin
Mekong River23-May-06 21:24
Mekong River23-May-06 21:24 
GeneralRe: How to Stop an Exe File through Command Prompt By Executing a Batch File Pin
k.n.ruban23-May-06 23:37
k.n.ruban23-May-06 23:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.