|
Given an HWND, GetDC(hWnd) will return the DC for the client window.
Steve S
Developer for hire
|
|
|
|
|
hi i m using setwindows hook functin with low level keyboard as paramter. in application it works fine and capture all global keystrokes but it is not working in service call back function is not called.i m calling setting hooks from servicemain function without the thread and hook is setted does not return null.
my service is interactive service it means it listen the windows events.
-- modified at 3:22 Tuesday 22nd August, 2006
Tasleem Arif
|
|
|
|
|
From MSDN on the SetWindowsHookEx API:
"These events are associated either with a specific thread or with all threads in the same desktop as the calling thread."
I have underlined the relevant part.
If you want a service to "interact with desktop" I would first investigate the "Allow service to interact with desktop" checkbox in the services properties.
Steve
|
|
|
|
|
thanks for reply here is the code for the creating service i think it is interactive mean can access user input and desktop.
schService = CreateService(schSCManager,
TEXT(SZSERVICENAME),TEXT(SZSERVICEDISPLAYNAME),SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS ,SERVICE_DEMAND_START, SERVICE_ERROR_NORMAL,szPath, NULL,
NULL,TEXT(SZDEPENDENCIES),NULL,NULL);
and for the hooks
hHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowerLevelKeyboardProc, hInstance,0);
if(hHook==NULL)
printf("SetHooks failed\n");
if i associate it with the specific thread will that thread will be called itslef regardless when created through createthread and once executed.
i will be very thankful to you if you provide me any further info.Thanks
If you want a service to "interact with desktop" I would first investigate the "Allow service to interact with desktop" checkbox in the services properties. services dont have such property i m using vc++.
-- modified at 4:32 Tuesday 22nd August, 2006
Tasleem Arif
|
|
|
|
|
I am assuming your hInstance is the instance of a DLL you loaded that contains the hook procedure as an exported function? Otherwise, this will not work.
The 'global' hook procedure can not be in your service EXE file, it must be in a DLL your service loads dynamically.
Try using LoadLibrary and GetProcAddress to make it work.
SetWindowsHookEx(WH_KEYBOARD_LL, LowerLevelKeyboardProc, hInstance,0);
It does not make sense to load a local keyboard hook in your service, since the service will never have 'focus' under 'normal' circumstances.
Any sufficiently gross incompetence is nearly indistinguishable from malice.
|
|
|
|
|
i m using the MFC extension dll and its callback function def like this and
works well from the desktop application.
LRESULT __declspec(dllexport)__stdcall CALLBACK KeyboardProc(int <br />
<br />
nCode,WPARAM wParam,LPARAM lParam) i m using this function to from
service to call th dll which also works for the desktop application.
typedef BOOL (CALLBACK *inshook)(); <br />
inshook instkbhook;<br />
hInstance= LoadLibrary((LPCTSTR) "hodll.dll"); <br />
instkbhook =GetProcAddress(hInstance, "installhook"); <br />
instkbhook();
i had googled a lot to find any example that uses callback or hook but was
not successful.dont know what to do or how to solve.My service is also
allowed to interact with desktop.
Tasleem Arif
|
|
|
|
|
See here[^] if its good for you
|
|
|
|
|
i had read those kind of pages nad found no solution that is why i posted question on that forum otherwise i cound do himself n tried to do so but result was 0%.
microsoft had not documented what to do inorder to make a service as desktop just link here n there but no to the poin answer.
Tell me what to do in order to make service runnig as desktop except specifying SERVICE_WIN32_OWN_PROCESS | SERVICE_INTERACTIVE_PROCESS parameter n creating service.
when i click on the service name and then properties and then logon through this code the checkbox "allow service to interact with desktop" was checked i think there it is present still cannot get the callback functions.
-- modified at 6:53 Tuesday 22nd August, 2006
-- modified at 7:37 Tuesday 22nd August, 2006
Tasleem Arif
|
|
|
|
|
Hi friends,
I am working on one Image processing application where I worked on the Histogram equalization, Histogram based Image segmentation and edge detection algorithms.
In my application I need to write one algorithm for object reorganization and object matching (the master Image is stored in to the DB) .
But the practical limitation is the object is of the shape of bullet and is coming in any position on the conveyor and I am grabbing the Image using CCD camera.
I have to compare the Master Image of the bullet I have in DB with the grabbed Image from the conveyor.
Please suggest any algorithm or library if anybody knows for this purpose
Regards,
Dinesh
"Failure is success if we learn from it"
-- modified at 2:41 Tuesday 22nd August, 2006
|
|
|
|
|
hello,
Iam using "CRecordset" class to access SQL database in another PC
through network(PEER to PEER).
Everything works fine when the network connection is active..
When the network connection is breaked and resumed for period of time,
the database cannot be accessed.
how to reconnect the database after the network is resumed???
give me a solution....
"Empty mind is devils workspace"
|
|
|
|
|
hi
how to convert CString to double format??
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
|
<br />
#include stdlib.h<br />
CString str = "123.0045";<br />
double a = atof(str);<br />
|
|
|
|
|
i am using two Command Buttons one for sending another for receiving data can be stored in a file
plese help me
advanced thanks
prasad raju
|
|
|
|
|
USB ports don't work like a standard COM port. Depending of the device you want are connected to, you should have received a driver with this device. Then, take a look at the documention (normaly, supplied with it). Everything should be described there.
Now, if the device connected is a USB-to-RS232 device, then it creates a virtual COM port and you should open this port and work with as a standard COM port.
|
|
|
|
|
Hi,
I have created a Device Independent Driver Code. It is working perfectly. All i need is a Application Launcher program. And that is where my problem starts. I am trying to create the file using the CreateFile Command. And it is always returning false. I have attached the code snippet below. Anyone who knows how to solve the problem please help me.
HANDLE OpenDeviceDriver(LPCTSTR szDriverName)
{
HANDLE hDevice;
TCHAR szFullName[200];
wsprintf(szFullName, "\\\\.\\%s", szDriverName);
hDevice = CreateFile (szFullName,
0,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);
if(hDevice == INVALID_HANDLE_VALUE)
{
hDevice = 0;
printf("%x Error %ld\n",hDevice,GetLastError());
}
return hDevice;
}
With Warm Regards
Kenny
|
|
|
|
|
What's the return value from GetLastError() ?
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
The result of the GetLastError() is 2
|
|
|
|
|
That's ERROR_FILE_NOT_FOUND
Could it be an ANSI/UNICODE problem?
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Might be. Is there any other way through which i can achieve the same? Or can we modify any settings to achieve the above.
-- modified at 4:48 Tuesday 22nd August, 2006
|
|
|
|
|
I'm a bit on thin ice here, but if your program is a Unicode build, you can try to use the wide version of CreateFile, CreateFileW().
Else, convert the string to ANSI and use CreateFile()
Or, do an ANSI build (by removing the UNICODE define(s)).
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
This is one problem. I tried your views and one problem is solved. But still it gives the same error in create file.
Regards
Kenny
|
|
|
|
|
Here is an article that might help you. Check out the information regarding "symbolic link name" especially. Maybe that's your problem?
http://www.ddj.com/dept/windows/184416453[^]
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
how start to a MFC code for delaunay triangulation using 10 points..?
-- modified at 0:34 Tuesday 22nd August, 2006
|
|
|
|
|
Hi, welcome to Code Project. I sure hope you become a member of our little community. If you want people to do your job for you, you would do well to show that you've taken a stab at it yourself. You've emphasised MFC, but what you're asking for is a mathematical operation. Why do you require MFC be used to do this ? What have you already done to try and solve this problem, besides asking us to do it ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|