|
Well, either give that value to your setting dlg as a parameter thorough its constructor (and store it in your setting dialog class as a member), or give a pointer to your loader dialog the same way and when you need the variable, use the pointer to access the value. Or if you need that variable after your setting window has been created, you can also try calling GetParent() in your setting dialog, convert what you get to the class of your load dialog and then access the meber as you must. But this later method is a bit ugly (what if you want to display your setting dialog from somewhere else os its parent won't be something else than your load dialog?).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Your problem has nothing to do with inheritance (if I got you). Check out toxcct's nice article on dialog communication [^].
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]
|
|
|
|
|
Hi!
I want to give option to the user to select the display device his/her self if his/her computer is connected to multiple devices in my MFC application. Can anyone has idea about how to do it? And what are the APIs that give you the list of available display devices?
|
|
|
|
|
|
This is my code:
It gives me true when I perform the function crypt decrypt its just that I am expecting this output : aHR0cDovL2xvY2FsaG9zdDo4MDgwL015V2ViL21hbmFnZXBvaW50L21hbmFnZXBvaW50MzQxLnppcA==
Then when I decode it Ill should get a link but instead cryptdecrypt gives me trash which I cant convert to the right link
LPTSTR Base64Decode(LPCTSTR lpData, DWORD dwSize)
{
DWORD dwResult = 0;
if(CryptStringToBinary(lpData, dwSize, CRYPT_STRING_BASE64, NULL, &dwResult,NULL,NULL))
{
LPTSTR lpszBase64Decoded = new TCHAR[dwResult+(sizeof(TCHAR) * 2)];
memset(lpszBase64Decoded,0,dwResult);
if(CryptStringToBinary(lpData, dwSize, CRYPT_STRING_BASE64,(BYTE *)lpszBase64Decoded, &dwResult,NULL,NULL))
{
*(LPWORD)(lpszBase64Decoded + (dwResult / sizeof(TCHAR))) = 0;
return lpszBase64Decoded;
}
}
return NULL;
}
LPTSTR Base64Encode(LPCBYTE lpData, DWORD dwSize, BOOL bStripCRLF, DWORD *dwBufSize)
{
DWORD dwResult = 0;
if(CryptBinaryToString(lpData, dwSize, CRYPT_STRING_BASE64, NULL, &dwResult))
{
LPTSTR lpszBase64 = new TCHAR[dwResult];
if(CryptBinaryToString(lpData, dwSize, CRYPT_STRING_BASE64, lpszBase64, &dwResult))
{
TCHAR pByteLF = *(LPWORD)(lpszBase64 + dwResult -1);
TCHAR pByteCR = *(LPWORD)(lpszBase64 + dwResult -2);
if(pByteCR == 0x0D && pByteLF == 0x0A)
{
*(LPWORD)(lpszBase64 + dwResult -2) = 0;
}
*dwBufSize = dwResult;
return lpszBase64;
}
}
return NULL;
}
BYTE* Base64Decode2(LPCTSTR lpData, DWORD dwSize, DWORD *dwBufSize)
{
DWORD dwResult = 0;
if(CryptStringToBinary(lpData, dwSize, CRYPT_STRING_BASE64, NULL, &dwResult,NULL,NULL))
{
BYTE * decodedStr;
decodedStr = new BYTE;
LPTSTR lpszBase64Decoded = new TCHAR[dwResult+(sizeof(TCHAR) * 2)];
memset(decodedStr,0,dwResult);
if(CryptStringToBinary(lpData, dwSize, CRYPT_STRING_BASE64,decodedStr, &dwResult,NULL,NULL))
{
*dwBufSize = dwResult;
return decodedStr;
}
}
return NULL;
}
LPTSTR Base64Encode2(BYTE* lpData, DWORD dwSize, BOOL bStripCRLF, DWORD *dwbufSize)
{
DWORD dwResult = 0;
if(CryptBinaryToString(lpData, dwSize, CRYPT_STRING_BASE64, NULL, &dwResult))
{
LPTSTR lpszBase64 = new TCHAR[dwResult];
if(CryptBinaryToString(lpData, dwSize, CRYPT_STRING_BASE64, lpszBase64, &dwResult))
{
TCHAR pByteLF = *(LPWORD)(lpszBase64 + dwResult -1);
TCHAR pByteCR = *(LPWORD)(lpszBase64 + dwResult -2);
if(pByteCR == 0x0D && pByteLF == 0x0A)
{
*(LPWORD)(lpszBase64 + dwResult -2) = 0;
}
*dwbufSize = dwResult;
return lpszBase64;
}
}
return NULL;
}
DWORD TripleDESdecrypt(TCHAR *cyphertext,DWORD ctlen,TCHAR *passwd,DWORD pwlen,TCHAR *plaintext,DWORD *ptlen)
{
HCRYPTPROV hProv;
HCRYPTHASH hHash;
HCRYPTKEY hKey;
DWORD dwSizeNeeded =0;
BOOL result = CryptAcquireContext(&hProv,NULL,MS_STRONG_PROV,PROV_RSA_FULL,0);
result = CryptCreateHash(hProv,CALG_MD5,0,0,&hHash);
result = CryptHashData(hHash,(BYTE *)passwd,pwlen,0);
result = CryptDeriveKey(hProv,CALG_3DES,hHash,0,&hKey);
BYTE PadMode = CRYPT_MODE_ECB;
result = CryptSetKeyParam(hKey, PKCS5_PADDING, &PadMode, 0);
if(*ptlen >= ctlen)
{
memcpy(plaintext,cyphertext,*ptlen);
result = CryptDecrypt(hKey,NULL,1,0,(BYTE *)plaintext,&ctlen);
*ptlen=ctlen;
}
else
{
dwSizeNeeded = ctlen * sizeof(TCHAR);
}
CryptDestroyKey(hKey);
CryptDestroyHash(hHash);
CryptReleaseContext(hProv,0);
return dwSizeNeeded;
}
int main()
{
BYTE* decodedStr;
HCRYPTPROV hCryptProv;
HCRYPTHASH hHash = 0;
HCRYPTKEY hKey = 0;
TCHAR szKey[] = _T("h3bmull3r");
TCHAR szUnencrypted[] = _T("");
TCHAR * pszEncrypted = NULL;
TCHAR * pszBase64 = NULL;
TCHAR * pszBase64Decoded = NULL;
TCHAR * psz3DESDecoded = NULL;
DWORD dwSizeNeeded;
DWORD BufSize;
DWORD dwUnEncryptedSize;
DWORD dwEncryptedSize;
DWORD KeySize;
TCHAR * NewKey = Base64Encode((LPCBYTE)&szKey,_tcslen(szKey) * sizeof(TCHAR),FALSE, &KeySize);
_tcscpy(szKey, NewKey);
pszBase64 = _T("bZVLVixsjgTxsWbwmAGitRR0T86AM9Kam4BYRR+Dukc9p9vhwUBAzCSlZ463ZInufJRE+7ridImlz/aJUJbVhg==");
BYTE* TEST = Base64Decode2(pszBase64,_tcslen(pszBase64) * sizeof(TCHAR), &dwEncryptedSize);
TCHAR * pszEncrypted2 = reinterpret_cast<TCHAR *>(TEST);
pszEncrypted = pszEncrypted2;
dwUnEncryptedSize = NULL;
dwSizeNeeded = TripleDESdecrypt(pszEncrypted,dwEncryptedSize * sizeof(TCHAR),szKey,_tcslen(szKey),szUnencrypted,&dwUnEncryptedSize);
psz3DESDecoded = new TCHAR[dwSizeNeeded];
TripleDESdecrypt(pszEncrypted,dwEncryptedSize * sizeof(TCHAR),szKey,_tcslen(szKey),psz3DESDecoded,&dwSizeNeeded);
pszBase64Decoded = Base64Decode(psz3DESDecoded,_tcslen(psz3DESDecoded) * sizeof(TCHAR));
\
MessageBox(NULL,0 == _tcscmp(pszBase64Decoded,szUnencrypted) ? _T("Strings Match"):_T("Strings do NOT Match"),_T(""),MB_OK);
delete [] pszBase64;
delete [] pszBase64Decoded;
delete [] pszEncrypted;
return 0;
}
My code is a c++ version of this code : http://www.codeproject.com/KB/web-security/Cryptography_MD5_TriDES.aspx?display=Print[^]
Please help me I really need this I did all what I can.
Thanks,
Jayjay
|
|
|
|
|
Actually your code is failing (at least) in the following line:
monsieur_jj wrote: pszBase64Decoded = Base64Decode(psz3DESDecoded,_tcslen(psz3DESDecoded) * sizeof(TCHAR));
(CryptStringToBinary returns 0 . BTW: are you using the debugger?). Moreover the following comparison
monsieur_jj wrote: _tcscmp(pszBase64Decoded,szUnencrypted)
makes no sense, since szUnencrypted is a buffer never initialised.
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]
|
|
|
|
|
Hi Pallini,
Sorry never mind the message box output i forgot to comment that. Can anyone tell me the difference between the C# code and mine? Im pretty sure pkcs5 is the same at pkcs7 and i got all inputs the same.
Thanks,
Jayjay
|
|
|
|
|
Hi,
FWIW the encoded string is probably OK, since it decodes to
http://localhost:8080/MyWeb/managepoint/managepoint341.zip
it took 2 lines of C# code to get that. Not sure what is wrong in your code though.
|
|
|
|
|
|
Hi David,
These are the list of what is supported:
Listing Available Providers:
Provider type Provider Name
_____________ _____________________________________
1 Gemplus GemSAFE Card CSP v1.0
1 Infineon SICRYPT Base Smart Card CSP
1 Microsoft Base Cryptographic Provider v1.0
13 Microsoft Base DSS and Diffie-Hellman Cryptographic Provider
3 Microsoft Base DSS Cryptographic Provider
18 Microsoft DH SChannel Cryptographic Provider
1 Microsoft Enhanced Cryptographic Provider v1.0
13 Microsoft Enhanced DSS and Diffie-Hellman Cryptographic Provider
24 Microsoft Enhanced RSA and AES Cryptographic Provider (Prototype
)
5 Microsoft Exchange Cryptographic Provider v1.0
12 Microsoft RSA SChannel Cryptographic Provider
1 Microsoft Strong Cryptographic Provider
1 Schlumberger Cryptographic Service Provider
Provider types and provider names have been listed.
Listing Available Provider Types:
Provider type Provider Type Name
_____________ _____________________________________
1 RSA Full (Signature and Key Exchange)
3 DSS Signature
5 Microsoft Office Outlook/Exchange Cryptographic Service Provider
12 RSA SChannel
13 DSS Signature with Diffie-Hellman Key Exchange
18 Diffie-Hellman SChannel
24 RSA Full and AES
I read at msdn that Microsoft Enhanced Cryptographic Provider v1.0 supports triple DES now I am confused to what the problem really is.
Thanks,
Jayjay
|
|
|
|
|
Hi All
How can i call of new dialog box on click of Static box?Plz help me
|
|
|
|
|
1/ Make it a button, possibly with flat style. Then users will know it's a clickable thing.
2/ Set the SS_NOTIFY style, and your dialog will get messages that you've clicked on the static control.
3/ In the handler for that message, create a dialog any way you like.
eg:
CMyBabyDlg dlg (this)
dlg.DoModal ();
You might also want to look at a mutant static control turned into a hyperlink:
http://www.codeproject.com/KB/miscctrl/hyperlink.aspx[^]
(by Chris Maunder, so be nice about it)
Good luck,
Iain.
|
|
|
|
|
1) Add a static text to your dialog via resource editor.
2) Change its ID from IDC_STATIC to something else. Such as
IDC_STATIC_DLG_LAUNCHER<br /> 3) Now enable the "Notify" property of static control.
4) Now by using class wizard add click handler for the control.
5) In the newly added control handler, create and show your dialog.
basically for getting click notification from static controls, you've to change its default id from IDC_STATIC to something else and enabled the "Notify" property.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
We usually use of Button control but do you want to know about create dialog or load dialog?
|
|
|
|
|
Hello ,
I am sending a gif file to the HTTP Server.
Is there any way to find that the file is transfered successfully.
If yes how?
INTERNET_BUFFERS BufferIn = {0};
DWORD dwBytesRead;
DWORD dwBytesWritten;
BYTE pBuffer[1024];
BOOL bRead, bRet;
HANDLE hFile;
HINTERNET hSession = InternetOpen(NULL,
INTERNET_OPEN_TYPE_PRECONFIG,
NULL,
NULL,
0);
HINTERNET hConnection = InternetConnect(hSession,
_T("www.crmpanel.com"),
INTERNET_DEFAULT_HTTP_PORT,
NULL,
NULL,
INTERNET_SERVICE_HTTP,
0,
NULL);
BufferIn.dwStructSize = sizeof( INTERNET_BUFFERS );
HINTERNET hRequest = HttpOpenRequest(hConnection,
_T("PUT"),
_T("/temp"),
NULL,
NULL,
NULL,
0,
0);
if (!hRequest)
{
MessageBox(_T("Failed to open request handle:"),NULL,MB_OK);
return ;
}
hFile = CreateFile (_T("c:\\Image1.gif"),
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
MessageBox(_T("Failed to open local file"),NULL,MB_OK);
return ;
}
BufferIn.dwBufferTotal = GetFileSize(hFile, NULL);
MessageBox(_T("File size is"),NULL,MB_OK);
if(!HttpSendRequestEx(hRequest, &BufferIn, NULL, HSR_INITIATE, 0))
{
MessageBox(_T("Error on HttpSendRequestEx"),NULL,MB_OK);
return ;
}
DWORD sum = 0;
do
{
if (!(bRead = ReadFile (hFile, pBuffer, sizeof(pBuffer),
&dwBytesRead, NULL)))
{
MessageBox(_T("ReadFile failed on buffer"),NULL,MB_OK);
break;
}
if (!(bRet=InternetWriteFile( hRequest, pBuffer, dwBytesRead,
&dwBytesWritten)))
{
MessageBox(_T("InternetWriteFile failed"),NULL,MB_OK);
break;
}
sum += dwBytesWritten;
}
while (dwBytesRead == sizeof(pBuffer)) ;
CloseHandle (hFile);
MessageBox(_T("Actual written bytes:"),NULL,MB_OK);
if(!HttpEndRequest(hRequest, NULL, 0, 0))
{
MessageBox(_T("Error on HttpEndRequest"),NULL,MB_OK);
return ;
}
return ;
Please help me.
Thanks In Advance
modified on Friday, December 5, 2008 5:52 AM
|
|
|
|
|
Dhiraj kumar Saini wrote: Is there any way to find that the file is transfered successfully.
If either if the if() conditions in the while() loop fail, you know the transfer was unsuccessful.
"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
|
|
|
|
|
I am trying something like Spy++ for html documents to identify child window controls on the html page rendered by a browser. Is there a way I can programmatically access the common controls like button, edit window etc from a html page after the page got rendered in a browser like firefox, IE, Opera etc.
Thank you
cheers
Varghese Paul
|
|
|
|
|
|
|
This[^] may help you !!
- Malli...!
|
|
|
|
|
|
I hope you have to create the proxy class from your server wsdl file, which you can use in your code directly.
- Malli...!
|
|
|
|
|
|
Try using wsdl.exe (.net tool) to build proxy class from the WSDL url.
- Malli...!
|
|
|
|
|
Hi Friends,
I'm newbie to the forum and MFC programming as well. I want to know 'How to get the image contents from the clipboard and write into a BMP file using MFC', Please do the needful.
Thanks ahead for every one.
|
|
|
|
|