|
Thanks for reply but it's not working.Can you give me some code example.Please help me it's very diffult for me..Please help
|
|
|
|
|
This is the relevant info from my project in the file: PluginTestDlg.cpp
<br />
#include "KeyHook.h"<br />
<br />
#define WM_MY_MESSAGE (WM_APP + 100)<br />
<br />
ON_MESSAGE(WM_MY_MESSAGE, OnMyMessage)
<br />
LRESULT lRes = InstallKeyHook();<br />
ASSERT(lRes == KH_OK);
<br />
KEYENTRY ke;<br />
ke.nMessage = WM_MY_MESSAGE;
ke.hCallWnd = m_hWnd;
ke.hHookWnd = 0;
ke.iCombKeys = 0;
ke.iIndicators = 0;
ke.iKeyEvent = KH_KEY_DOWN | KH_KEY_UP;
ke.iMinVKCode = 0;
ke.iMaxVKCode = 255;<br />
<br />
lRes = AddKeyEntry(&ke);<br />
ASSERT(lRes == KH_OK);
<br />
<br />
LRESULT CPluginTestDlg::OnMyMessage(WPARAM wParam, LPARAM lParam)<br />
{<br />
KEYRESULT kr; <br />
<br />
UINT nMask = KH_MASK_EVENTTYPE | KH_MASK_PRINTABLECHAR;<br />
<br />
LRESULT lRes = GetKeyEventResult(wParam, lParam, &kr, nMask);<br />
ASSERT(lRes == KH_OK);
<br />
if (kr.chPrintableChar != 0)<br />
{<br />
CString sEvent;<br />
if (kr.iKeyEvent == KH_KEY_DOWN)<br />
sEvent = _T("Key Down");<br />
else if (kr.iKeyEvent == KH_KEY_UP)<br />
sEvent = _T("Key Up");<br />
else if (kr.iKeyEvent == KH_KEY_REPEAT)<br />
sEvent = _T("Key Repeat");<br />
else<br />
ASSERT(FALSE);
<br />
CString sMsg;<br />
sMsg.Format(_T("Event: %s\nCharacter:%c"), sEvent, kr.chPrintableChar);<br />
MessageBox(sMsg);
}<br />
<br />
return (LRESULT)0;<br />
}<br />
<br />
<br />
UninstallKeyHook();<br />
-The ke structure is how you setup the hook and all options are documented in the KeyHook.h header
-In my kr structure I use the nMask to decode the message unto useful info then check if its a printable character and issue a msgbox for each type of key state.
-ASSERT(lRes == KH_OK);is a sanity check, error codes are listed in KeyHook.h
-#define WM_MY_MESSAGE (WM_APP + 100) I have no idea where I got this from... But it works...
Sorry to reply so late I have been away for work.
|
|
|
|
|
Please send me Vernam Cipher C code in esiest way, where user put the Plain text,key or cipher text.Actually i want to say where key is not generated randomly.
|
|
|
|
|
At a minimum, read #2 here."One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Punima Sen wrote: Please send me Vernam Cipher C code
Try the quick answers, there is a GimmeCode tag. If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
People do not handover code here, they rather help others to write code themselves.
If code is what you're after, you could easily search Google for implementations of Vernam Cipher.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
hi everyone. Somebody can explain to me how to send or receive sms by using mfc-lib. I'll be Grateful for any help.modified on Saturday, February 20, 2010 9:43 AM
|
|
|
|
|
Did you search for a CodeProject's article? I found: "An SMPPLIB with COM Support".
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I'm currently working on a rewrite of my most recent article Monitoring and Controlling a Recursing Function in a Worker Thread and would love to know your opinions on the fowing block of code I use in the worker thread...
do {
Sleep(1);
}while (pMyView->m_strCurFile != pMyView->m_strConfirm);
This has the effect of slowing things up enough so that the main thread can display a gratifyingly fast moving display of files flash past in the text box on the dialog. I was going to say that, without it, the dialag doesn;t display any file information until the thread has stopped running but I've just tried it and, in fact, with out it I get an Access Violation error!
It doesn't seem like a very nice bit of code to me. Could it be replaced with WaitForSingleObject or something, somehow?
Interestingly, if I try and speed the thread up by putting in an extra mod test so that it only runs every tenth loop...
if (n % 10 ==0){
do {
Sleep(1);
}while (pMyView->m_strCurFile != pMyView->m_strConfirm);
}
...this also causes problems...
|
|
|
|
|
In general Sleep is bad form, although as with any rule of thumb there are exceptions. Unfortunately, from what I've seen your code isn't one of them.
Ben Aldhouse wrote: It doesn't seem like a very nice bit of code to me. Could it be replaced with WaitForSingleObject or something, somehow?
But what's you're problem? From what I gather, what you should be worried about is what's causing the access violation. Never stop a crash by poking around blindly till it stops: lose the Sleep and find the cause of the real problem (the access violation). The first thing I'd do is kill the Sleep , run the code under a debugger and get a stack trace of the access violation. I suggest posing it.Steve
|
|
|
|
|
Thanks for this Stephen, you have hit the nail on the head, I think, regarding the access violation. I have had a reply indicating that my use of CString objects is causing this. I will investigate this.
|
|
|
|
|
I took a brief look at your article. I have some humble comments/observations.
1.) Yes you should get rid of the call to Sleep. I have never found any use for this API call and in my opinion it is probably the most abused function on planet Earth. I recommend the following:
a) Add: HANDLE hEvent; to your CFormView.
b) Call hEvent = CreateEvent(NULL,FALSE,FALSE,"Your-GUID"); in your constructor.
c) Call SetEvent(hEvent); in your OnCURFILEEVENT message handler.
d) Replace the Sleep(1) with: WaitForSingleObject(hEvent,1000); and then reset the event with ResetEvent(hEvent); immediately afterwards.
2.) Regarding your access violation... I instantly recognized the problem. You are incorrectly accessing a CString object that lives inside your CFormView from the worker thread. CString is NOT thread-safe. You need to replace the pMyView->m_strCurFile assignment with a message function such as SendMessageTimeout[^] and this will fix the Access Violation in your article.
Best Wishes,
-David Delaune
|
|
|
|
|
I am very grateful to you, David, for looking at my code. You only looked at it briefly but were able to provide me with these very specific points of help. It's humbling for me because it will take longer for me to try them out than it took for you to look through my code, understand what I was trying to do and make these suggestions. I will go through them carefully, though. You clearly know what you are writing about.
|
|
|
|
|
Hi Dave,
I've got the project working with the following alterations...
Here is the sending code in MakeListing...
CString* pString = new CString(FindFileData.cFileName);
SendMessageTimeout(pMyView->GetSafeHwnd(), CURFILEEVENT, (WPARAM)pString, 0, 0, 1000, 0);
delete pString;
Here is the receiving function...
LRESULT CRecThread2008_64Dlg::OnCURFILEEVENT(UINT wParam, LONG lParam)
{
CString* pString = (CString*)wParam;
CString tempStr = pString->GetBuffer();
m_iNoFiles++;
CString tString=LPCTSTR("");
tString.Format(_T("%d"),m_iNoFiles);
m_strNoFiles = tString;
m_strFileList= tempStr + _T("\r\n")+ m_strFileList;
m_strFileList = m_strFileList.Left(500);
UpdateData(FALSE);
return 0;
}
And it works without the sleep block - so I have got rid of that!
I think I getting near to a point where I can start to rewrite the article...
Thank you for your help with this,
Ben.
|
|
|
|
|
David, the code and article is rewritten, now. Thanks so much for your help. I used SendMessageTimout and it worked nicely!
Thanks,
Ben.
|
|
|
|
|
HI all,
i m sending SMS using AT commands in Text mode,its works fine.
now one problem is occur i m not able to send sms more than 160 words.
so please tell me how do i send a long sms exceeding 160 characters using AT command.
please tell me how can i do this.
thanks in advance.
|
|
|
|
|
Have you heard of Google? txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Hi all,
i m using AT commands to send SMS,
I need to find out how to hide your number, so that the receiver will either see a message with no sender or even better a sender with characters as their number, e.g From: "Service".
i want if any recepient receive my SMS ,SMS display a Name that is i m set instead of my phone number.
please help me for this.
tahnks.
|
|
|
|
|
I knew helping you with SMS was going to be an issue - I can think of no good/nice/honset reason for doing what you suggest - I urge anyone else here not to respond if they know a way of doing it.
'g'
|
|
|
|
|
Fortunately, for the rest of us, this feature is not allowed, as message identification is controlled by the network provider. Short answer, you cannot do it. txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Just curious.
Why?Watched code never compiles.
|
|
|
|
|
I really need to do this.
|
|
|
|
|
Le@rner wrote: I really need to do this.
Why?txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
ok, but why you need to hide the identity of the sender ?
I'm just curious. Watched code never compiles.
|
|
|
|
|
I making an sms sender application and i dont want to display me number to all reciepients.
|
|
|
|