Click here to Skip to main content
15,890,527 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionVfw decompression - real sample code wanted Pin
Vaclav_14-May-12 8:24
Vaclav_14-May-12 8:24 
QuestionDrawImage from 2 image buffer Pin
john563213-May-12 23:34
john563213-May-12 23:34 
AnswerRe: DrawImage from 2 image buffer Pin
Richard MacCutchan14-May-12 0:17
mveRichard MacCutchan14-May-12 0:17 
QuestionIPC using named pipes Pin
ForNow13-May-12 9:27
ForNow13-May-12 9:27 
GeneralRe: IPC using named pipes Pin
«_Superman_»13-May-12 16:15
professional«_Superman_»13-May-12 16:15 
AnswerRe: IPC using named pipes Pin
ThatsAlok13-May-12 20:06
ThatsAlok13-May-12 20:06 
AnswerRe: IPC using named pipes Pin
Software_Developer14-May-12 0:02
Software_Developer14-May-12 0:02 
Questionc++, CryptGetHashParam works in XP, Vista, but not Windows 7 Pin
jkirkerx13-May-12 8:49
professionaljkirkerx13-May-12 8:49 
I'm baffled by this. My MD5 Hash function works in Windows XP and Windows Vista, but fails in windows 7 with an Error 87.

So I rewrote the function to use HP_HASHSIZE to properly get the size, but nothing I did on Windows 7 made a difference.

I went back to XP, modified my code with the new changes, ran it, and produced the correct hash value result.

My Triple DES works fine on Windows 7, and my DES, so I'm going to check my crypt files on Windows 7 now, and see if I can find anything.

BYTE* CA_Encryption::_create_MD5_Hash( WCHAR *pzInputW, LPDWORD dwOutput )
{
BOOL			bResult = FALSE;
HCRYPTPROV		hProv = 0;
HCRYPTHASH		hHash = 0;

BYTE			*szBuffer = NULL;
DWORD			dwHashLen = 0;	
			
// Get the size of the conversion
int iCharA = ( WideCharToMultiByte(CP_UTF8, 0, pzInputW, -1, NULL, 0, NULL, NULL) - 1 );	
char *szInputA = new char[ iCharA ];
WideCharToMultiByte( CP_UTF8, 0, pzInputW, -1, szInputA, iCharA, NULL, NULL );
			
DWORD	dwCount = sizeof( DWORD );	
DWORD	dwPasswordLen = iCharA;	
		
bResult = CryptAcquireContextW( &hProv, NULL, MS_STRONG_PROV, PROV_RSA_FULL, 0);	
bResult = CryptCreateHash( hProv, CALG_MD5, 0, 0, &hHash );   
bResult = CryptHashData( hHash, (BYTE*)szInputA, dwPasswordLen, 0 );

delete [] szInputA;
// The line below does nothing and produces an error 87, 
if(CryptGetHashParam( hHash, HP_HASHSIZE, (BYTE*)&dwHashLen, &dwCount, 0 ) ) {
	if  (( *dwOutput > 0 ) && ( *dwOutput < 4096)) {
		szBuffer = new BYTE[dwHashLen+1];
		CryptGetHashParam( hHash, HP_HASHVAL, szBuffer, &dwHashLen, 0 );
		*dwOutput = dwHashLen;
		szBuffer[dwHashLen] = 0;		
	}
	else {
		*dwOutput = dwHashLen+1;
		szBuffer = L'\0';
	}
}
else {
	*dwOutput = 1;
	szBuffer = new BYTE[ *dwOutput ];
	szBuffer[ 0 ] = L'\0';
}
		
CryptDestroyHash(hHash);
CryptReleaseContext(hProv, 0);
		    	
return szBuffer;
}

Answer[SOLVED] Re: c++, CryptGetHashParam works in XP, Vista, but not Windows 7 Pin
jkirkerx13-May-12 10:13
professionaljkirkerx13-May-12 10:13 
Questionwhere should add the try-catch? Pin
yu-jian13-May-12 5:55
yu-jian13-May-12 5:55 
AnswerRe: where should add the try-catch? Pin
Richard MacCutchan13-May-12 6:45
mveRichard MacCutchan13-May-12 6:45 
GeneralRe: where should add the try-catch? Pin
yu-jian13-May-12 18:39
yu-jian13-May-12 18:39 
AnswerRe: where should add the try-catch? Pin
ThatsAlok13-May-12 20:08
ThatsAlok13-May-12 20:08 
GeneralRe: where should add the try-catch? Pin
Richard MacCutchan13-May-12 21:41
mveRichard MacCutchan13-May-12 21:41 
AnswerRe: where should add the try-catch? Pin
TinyDevices13-May-12 20:59
professionalTinyDevices13-May-12 20:59 
GeneralRe: where should add the try-catch? Pin
yu-jian13-May-12 22:24
yu-jian13-May-12 22:24 
AnswerRe: where should add the try-catch? Pin
Aescleal14-May-12 3:15
Aescleal14-May-12 3:15 
QuestionNeed Help with Audio Output in C/C++ Pin
Veeshal Beotra13-May-12 4:12
Veeshal Beotra13-May-12 4:12 
AnswerRe: Need Help with Audio Output in C/C++ Pin
Vaclav_14-May-12 8:35
Vaclav_14-May-12 8:35 
QuestionChanging the background color of Text control or combo box when text got changed Pin
Ashish Ranjan Mishra13-May-12 4:01
Ashish Ranjan Mishra13-May-12 4:01 
AnswerRe: Changing the background color of Text control or combo box when text got changed Pin
«_Superman_»13-May-12 4:12
professional«_Superman_»13-May-12 4:12 
Question'Forward Class Declaration' Not Working Pin
AmbiguousName12-May-12 20:44
AmbiguousName12-May-12 20:44 
QuestionRe: 'Forward Class Declaration' Not Working Pin
«_Superman_»12-May-12 20:53
professional«_Superman_»12-May-12 20:53 
AnswerRe: 'Forward Class Declaration' Not Working Pin
AmbiguousName12-May-12 22:23
AmbiguousName12-May-12 22:23 
AnswerRe: 'Forward Class Declaration' Not Working Pin
Richard MacCutchan12-May-12 21:30
mveRichard MacCutchan12-May-12 21:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.