|
There's also the standard lib next_permutation(). Or you could write one, basically a cascading swap as you traverse the elems, but I'm sure there are some out there on the web already somewhere.
Any book on combinatorics should have the alg needed.
Applied Combinatorics by Alan Tucker is one.
|
|
|
|
|
Hy,
I have my next problem. I am trying to get an md5 hash from an string (i am using "hello" in this example) The problem is, that the CryptoAPI gives me a different key than the md5 function from PHP.
I think MD5 is MD5 so both should give me the same result.
Here is my Code for the crypto api -> error() only shows Error Nr.: id as a small help for me.
The ByteToStr function is the same ByteToStr function which is in the MSDN.
HCRYPTPROV hProv = NULL;
HCRYPTHASH hHash = NULL;
BYTE *pbKey = (BYTE*)"hello";
DWORD dwKeyLen = strlen((char*)pbKey)+1;
DWORD dwHashLen = 0;
BYTE pbOut[16];
if(!CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,0)) Error(1);
if(!CryptCreateHash(hProv,CALG_MD5,0,0,&hHash)) Error(2);
if(!CryptHashData(hHash,pbKey,dwKeyLen,0)) Error(3);
if(!CryptGetHashParam(hHash,HP_HASHVAL,NULL,&dwHashLen,0)) Error(4);
if(!CryptGetHashParam(hHash,HP_HASHVAL,pbOut,&dwHashLen,0)) Error(5);
LPCSTR lpMsg = new char[100];
ByteToStr(dwHashLen,&pbOut,(LPSTR)lpMsg);
MessageBoxA(NULL,lpMsg,"hihi",0);
delete lpMsg;
CryptDestroyHash(hHash);
CryptReleaseContext(hProv,0);
Thanks for help.
bye,
gabbana
|
|
|
|
|
gabbana wrote: DWORD dwKeyLen = strlen((char*)pbKey)+1;
Ummmm - is the PHP MD5 algorithm including a NULL terminator byte? Do PHP strings even have NULL terminators? I doubt it very much...
If removing the NULL terminator doesn't fix it, one other thing to consider is whether or not PHP strings are ASCII or some form of multi-byte Unicode?
|
|
|
|
|
wow, Thank you. It was the null terminator.
|
|
|
|
|
Hai!
i have an edit box in which user has to enter only 0x00 to 0xFF,
but if he enters more than two digits i. something like "FF2" or "G2" etc
what is the easiest way to check it!
I need in such a way that suppose user enters a wrong value such as "FF1"
and presses enter then i should display a message "Can enter only between 0x00 to 0xFF " and erase the previous data and set the cusor at the same edit box so that the user can enter a valid value.
I think i can use CEdit::SetLimitText () , so as to make the user to enter only 2 characters but what is the case with "G2" like values?
Thanks !
|
|
|
|
|
|
Use GetWindowText() to get the contents of the edit control. Convert that to an int and compare against 0x00 and 0xff .
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Hi all,
i m using a ListCtrl as Report Type and i want to add button inside the ListCtrl.
please tell me how can i do this.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
here[^] is a link where you can add a combo box. on similar lines you can do this for a button
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
What I'm trying to do is add tooltips to a CView derived window so that I can change the text in the tooltip (or not display it at all) depending on where the cursor is and the state of various other things going on in the application (it's mostly just going to be for showing error states for things on the network). I'm not using any Windows controls at all on the view - the view basically just draws a bitmap.
What I've done is create the tooltip in PreCreateWindow as follows :
theApp.GetTooltipManager()->CreateToolTip(m_pToolTip, this, AFX_TOOLTIP_TYPE_DEFAULT);
m_pToolTip->AddTool(this, LPSTR_TEXTCALLBACK, CRect(0,0,600,600), 1);
EnableToolTips(TRUE);
m_pToolTip->Activate(TRUE);
I've added a handler in both the view and mainframe classes for the TTN_NEEDTEXT message (I'm not entirely sure which one it's supposed to go to in this scenario). I've also added m_pToolTip->RelayEvent(pMsg) into PreTranslateMessage.
But the TTN_NEEDTEXT message handlers never get called and no tooltip ever gets shown even if I hard code the tooltip text instead of using LPSTR_TEXTCALLBACK.
Can anybody shed any light on this for me? I've no doubt that this is a schoolboy error and I'll feel a complete fool when someone points out my stupidity, but I think I'm ready to accept that now...
Thanks in advance.
|
|
|
|
|
|
Thanks Iain. I know what you mean about the "unique" implementation of some bits of MFC - that's why I'm not using any Windows controls in my application other than the framework itself!
The only reason I wanted to use the inbuilt tooltips was for consistency with the tooltips on the menus and toolbars. Pedantic I know, but these things bother me.
Anyway, in case anyone else ever needs to know I've found a solution through a combination of bloody-mindedness, patience and trial and error. It seems that if you construct the tooltip object in OnDraw the first time it gets called, rather than in PreCreateWindow, then that code works fine.
Why? I'm really not sure TBH. I guess it's something to do with needing the view to be fully created before adding tooltips to it although I haven't seen anything in the documentation about that (not that that means it isn't there!).
|
|
|
|
|
|
1) Install windows
2) RegSetValueEx
|
|
|
|
|
hello,
i want to write data related to my application to registry, i want to know how to write it programmatically, got my point
|
|
|
|
|
Use App class's SetRegistryKey API to set the Application key in HKCU/Software.
Next you can use App class's GetSectionString() or GetSectionBinary() or GetSectionInt() etc to read the registry values.
SetSection..() APIs are also available.
|
|
|
|
|
hemanju wrote: want to write data related to my application to registry
Great. That means you are privileged but BEWARE VISTA settings
hemanju wrote: i want to know how to write it programmatically, got my point
Yes I understood it [ ]
RegCreateKeyEx - The RegCreateKeyEx function creates the specified registry key. If the key already exists, the function opens it.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
If you need to get help you should be specific with your questions.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Do you want to write in registry or you want to get backup of registry? I dont know do you need to CRegKey Class or no?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
COleClientItem::OnGetWindowContext takes CFrameWnd pointer. Now I deriving frame window class from CFrameWndEx. I am getting error when I send the CFrameWndEx pointer to this function. Is there any similar function to COleClientItem::OnGetWindowContext. Please let me know if anyone knows.
|
|
|
|
|
COleClientItem::OnGetWindowContext takes CFrameWnd pointer. Now I deriving frame window class from CFrameWndEx. I am getting error when I send the CFrameWndEx pointer to this function. Is there any similar function to COleClientItem::OnGetWindowContext. Please let me know if anyone knows.
|
|
|
|
|
|
|
i want to know how to set IPAddress control in status bar.
thanks
|
|
|
|
|
you have the ip address. Convert it to some string format and use
SetPaneText (/*params*/) API from CStatusBar class
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|