|
Does it mean handle is just another way of declaring a pointer? Is that right?
Asura
|
|
|
|
|
In totally handles are different of pointers.I think I know a good site for you about C++/CLI and you will be find your answer and other answers that maybe you have a question for them.see here[^];)
|
|
|
|
|
im trying to get the WM_CHAR message and this set up is not doing it.
i have an edit text box in my window and all im getting is the keydown message when i type to it.
LRESULT CALLBACK GetMsgProc(int code, WPARAM wParam, LPARAM lParam){<br />
if(code == HC_ACTION){<br />
MSG* pMsg = (MSG*)lParam;<br />
if(pMsg->message == WM_CHAR){<br />
int i=0;<br />
i = i +10;
}<br />
}<br />
<br />
return CallNextHookEx(g_KeybdHook, code, wParam, lParam);<br />
}<br />
hook in main:
g_KeybdHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, 0,GetCurrentThreadId());
thanks
|
|
|
|
|
lParam is not a MSG pointer in a keyboard hook proc. See KeyboardProc Function[^].
It seems to me it would be simpler to subclass the edit control than to use a keyboard hook.
Safe Subclassing in Win32[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
hi mark, im using "WH_GETMESSAGE" one of the options here and i should be dealing with this GetMsgProc Function right?
obviously not since is not working
what tells you that im dealing with "keyboard hook proc", more importantly how do i fix it.
im practicing to write a dll so i want to get my head around this hooking business.
Thank You
|
|
|
|
|
Lamefif wrote: im using "WH_GETMESSAGE"
Got it. I apparently can't read
Your code works for me. What's going wrong on your end?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
i cleaned it up alot due to experimenting lol but this is it.
CODE
|
|
|
|
|
Try this message loop:
g_KeybdHook = SetWindowsHookEx(WH_GETMESSAGE, GetMsgProc, 0,GetCurrentThreadId());
while (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
UnhookWindowsHookEx(g_KeybdHook);
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
|
Lamefif wrote: ps have you any idea how to load and use .klc files
No, sorry. Maybe the section "Languages, Locales, and Keyboard Layouts" here[^] will help?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
This episode brought to you by the letter Z
|
|
|
|
|
Hi all,
I am facing the problem.I want to put some IP address in IP address control box,store it in a string value and pass it as parameter to some function,how i will be able to that.
Regards,
Mayank
|
|
|
|
|
Maynka wrote: I want to put some IP address in IP address control box...
Send the control a IPM_SETADDRESS message.
Maynka wrote: ...store it in a string value and pass it as parameter to some function,how i will be able to that.
You first must get the value from the control by sending it a IPM_GETADDRESS message.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Dear All,
Im trying keyboard locking with SetWindowsHookEx()api.
It works fine. But the problem is that after some time it
automatically unhooks and unlocks the keyboard before a call to UnhookWindowsHookEx()is made.
Thanks,
Sumedh
Thank You
|
|
|
|
|
Can you place the code in your message?? That might help.
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Hi,
This is my code for keyboard locking.
Please check it out..
Thanks in advance,
Bye.
HHOOK hKeyboardHook = NULL;
void StartHook()
{
HMODULE hMod = NULL;
hMod = LoadLibrary("LockScr.dll");
if (hMod != NULL)
{
hKeyboardHook = NULL;
hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL,
(HOOKPROC)GetProcAddress(hMod,"KeyProc"),hMod,0);
if(hKeyboardHook != NULL)
{ MessageBox("SetWindowsHookEx OK");}
}
FreeLibrary(hMod);
}
void Unhook()
{
UnhookWindowsHookEx(hKeyboardHook);
}
/*** This Is the Code from DLL ***/
LRESULT LOCKSCR_API CALLBACK KeyProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode >= 0)
{ PostMessage(NULL,WM_USER+765,wParam,lParam);}
return nCode < 0 ? CallNextHookEx(NULL,nCode, wParam, lParam) : -1;
}
Thanks
Sumedh
|
|
|
|
|
Hmm.. I'm not too sure sorry Why do you call FreeLibrary() after you set the hook? surely this will mean that you wont be able to unhook the hook after this as the DLL is no longer loaded into or associated with the application..
Apart from this everything seems to be OK, my LL keyboard hooking code looks almost identical to this..
Sorry I can be of no further help
--PerspX
"Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates
|
|
|
|
|
Hello,
I have one command line application, where i am setting registry key values .
LPCTSTR lpResName=GetSourceName(RegFileName);
rCode=RegSetValueEx(
hDckey,
lpResName,
0,
REG_SZ,
(LPBYTE)RegFileName,
(DWORD) (lstrlen(RegFileName)+1)*sizeof(TCHAR) );
This RegSetValueEx sets the values in the registry if i run this exe in "Debug" mode setting lpResName correctly, but if i run in the "Release" mode the "Value Name" for hDckey is some garbage. whereas "Value Data" is correctly set in both the Modes.
the GetSourceName returns the correct value for lpResName in both modes.
what may be the problem with this ?
please help me...
|
|
|
|
|
If the first argument to RegSetValueEx() is garbage, that means the key was not opened correctly.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
not any of the parameters are garbage, after executing this, if i see in the registry the "Value name" is garbage. that too it will set the "Value Name" if i run in "Debug" mode, the problem is there only if i make the exe in "Release" mode.
|
|
|
|
|
Yashusid wrote: not any of the parameters are garbage,
Then why would you state, "the 'Value Name' for hDckey is some garbage?" If none of the arguments being passed to RegSetValueEx() contain garbage, then what exactly is the problem?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
oops sorry if it created confusion....my intention was to convey that...
i have a key...for that key i am setting a property...
my registry entry for key
when u see in registry
Name ------------ Type ----Data
(garbage here)--- REG_SZ -- test.xml --> ------Release mode
test--------------REG_SZ -- test.xml --> ------Debug mode
i am getting garbage in Name field for the key...
|
|
|
|
|
Yashusid wrote: i am getting garbage in Name field for the key...
Which would indicate that lpResName is wrong. Try:
TCHAR s[128];
_tcscpy(s, GetSourceName(RegFileName));
rCode = RegSetValueEx(hDckey,
s,
0,
REG_SZ,
(LPBYTE) RegFileName,
(DWORD) (_tcslen(RegFileName) + 1) * sizeof(TCHAR));
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You are great!!!
Thanks a lot!!!
It works........
but please help me in understaning why it was setting correctly in "Debug" mode ?
|
|
|
|
|
Yashusid wrote: but please help me in understaning why it was setting correctly in "Debug" mode ?
It's not. You just got lucky. Read here for the differences in the two.
You should now be concerned as to what GetSourceName() is doing (wrong). If the code is short enough, post it and we can take a look.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
In GetSourceName i am parsing a XML file.
char *GetSourceName(char *RegFileName)
{
LPTSTR lpstrMsg;
CoInitialize(NULL);
CComPtr<ixmldomdocument> spXMLDOM;
CComPtr<ixmldomnode> spXMLNode;
IXMLDOMAttribute *pIXMLDOMAttribute = NULL;
IXMLDOMElement *pIXMLDOMElement = NULL;
HRESULT hr = spXMLDOM.CoCreateInstance(__uuidof(DOMDocument));
VARIANT_BOOL bSuccess = false;
USES_CONVERSION;
_variant_t fileNameValue=T2W(RegFileName);
hr = spXMLDOM->load(fileNameValue,&bSuccess);
if(!hr)
{
hr = spXMLDOM->get_documentElement(&pIXMLDOMElement);
_variant_t nameValue;
if(!hr)
{
hr = pIXMLDOMElement->getAttribute(CComBSTR(L"source-name"),&nameValue);
}
if ( nameValue.vt == VT_BSTR )
{
USES_CONVERSION;
lpstrMsg = W2T(nameValue.bstrVal);
}
}
spXMLDOM.Release();
CoUninitialize();
return lpstrMsg;
}
|
|
|
|