Click here to Skip to main content
15,888,521 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: buffer returning empty, doesn't exist on registry function when running in release, c++ win32 Pin
Randor 4-May-12 2:54
professional Randor 4-May-12 2:54 
GeneralI thought that was ok to do Pin
jkirkerx4-May-12 5:30
professionaljkirkerx4-May-12 5:30 
GeneralRe: I thought that was ok to do Pin
Randor 4-May-12 9:45
professional Randor 4-May-12 9:45 
GeneralRe: I thought that was ok to do Pin
jkirkerx4-May-12 12:46
professionaljkirkerx4-May-12 12:46 
AnswerRe: buffer returning empty, doesn't exist on registry function when running in release, c++ win32 Pin
Richard MacCutchan26-Apr-12 22:22
mveRichard MacCutchan26-Apr-12 22:22 
GeneralRe: buffer returning empty, doesn't exist on registry function when running in release, c++ win32 Pin
jkirkerx27-Apr-12 6:57
professionaljkirkerx27-Apr-12 6:57 
GeneralRe: buffer returning empty, doesn't exist on registry function when running in release, c++ win32 Pin
Richard MacCutchan27-Apr-12 22:57
mveRichard MacCutchan27-Apr-12 22:57 
GeneralRe: buffer returning empty, doesn't exist on registry function when running in release, c++ win32 Pin
jkirkerx4-May-12 12:17
professionaljkirkerx4-May-12 12:17 
So I changed my code here just for experimenting and used LPDWORD, might use PDWORD

CA_Registry caReg;					
WCHAR *pzProjectFolderPath = NULL;
DWORD dwProjectFolderPath = 0;

caReg._read_Registry_ProjectMRUList_Value( L"File1", &dwProjectFolderPath );
										
if ( dwProjectFolderPath > 0 ) {						
	pzProjectFolderPath = caReg._read_Registry_ProjectMRUList_Value( L"File1", &dwProjectFolderPath );					
	_project_Open( pzProjectFolderPath );						
}


Do I need to delete pzProjectFolderPath above?, or is it just a pointer to rgValue in the registry function?

WCHAR* CA_Registry::_read_Registry_ProjectMRUList_Value( WCHAR *pzValue, LPDWORD dwOut )
{
	
WCHAR	*szReturnValue = NULL;
WCHAR	*regPath = L"SOFTWARE\\redCopper\\Internet Commerce Engine 5\\ProjectMRUList\\";
	
HKEY	keyHandle;
TCHAR	rgValue[ MAX_PATH ]; 	
DWORD	dwValue = sizeof(rgValue);
DWORD	dwType = REG_SZ;
DWORD	regStatus = REG_DWORD;	
	
if(RegOpenKeyEx(HKEY_CURRENT_USER, regPath, 0, KEY_QUERY_VALUE, &keyHandle) == ERROR_SUCCESS) {		
	regStatus = RegQueryValueEx( keyHandle, pzValue, NULL, &dwType, (LPBYTE)rgValue, &dwValue );
	RegCloseKey(keyHandle);
		
	switch ( regStatus ) {
		case ERROR_SUCCESS:
				{
			if (( *dwOut > 0 ) && ( *dwOut < 4096 )) {						
				szReturnValue = new WCHAR[ *dwOut + 2 ];						
				for ( DWORD dwI = 0; dwI <= *dwOut; ++dwI ) {
					szReturnValue[ dwI ] = rgValue[ dwI ];
						}
					szReturnValue[ *dwOut ] = L'\0';
					DWORD dwErrorCode = GetLastError();
				}
				else {						
					*dwOut = wcslen( rgValue );						
			}
		}
		break;

		case ERROR_FILE_NOT_FOUND:				
			*dwOut = 0;
			break;

		case ERROR_MORE_DATA:
			*dwOut = 0;
			break;			

		default:				
			*dwOut = 0;			
	}		
}
else {
	*dwOut = 0;
} 

return szReturnValue;
}

GeneralRe: buffer returning empty, doesn't exist on registry function when running in release, c++ win32 Pin
Richard MacCutchan4-May-12 23:07
mveRichard MacCutchan4-May-12 23:07 
GeneralRe: buffer returning empty, doesn't exist on registry function when running in release, c++ win32 Pin
jkirkerx5-May-12 7:55
professionaljkirkerx5-May-12 7:55 
QuestionCalls to Vitual "overridable" of methods Pin
ForNow26-Apr-12 7:51
ForNow26-Apr-12 7:51 
AnswerRe: Calls to Vitual "overridable" of methods Pin
Albert Holguin26-Apr-12 8:15
professionalAlbert Holguin26-Apr-12 8:15 
AnswerRe: Calls to Vitual "overridable" of methods Pin
Chuck O'Toole26-Apr-12 10:14
Chuck O'Toole26-Apr-12 10:14 
GeneralRe: Calls to Vitual "overridable" of methods Pin
Albert Holguin26-Apr-12 10:19
professionalAlbert Holguin26-Apr-12 10:19 
QuestionEnumerate network printers in metro apps Pin
chameli.sujith25-Apr-12 19:38
chameli.sujith25-Apr-12 19:38 
AnswerRe: Enumerate network printers in metro apps Pin
Richard MacCutchan25-Apr-12 21:18
mveRichard MacCutchan25-Apr-12 21:18 
AnswerRe: Enumerate network printers in metro apps Pin
Wes Aday26-Apr-12 3:02
professionalWes Aday26-Apr-12 3:02 
AnswerRe: Enumerate network printers in metro apps Pin
Maximilien26-Apr-12 5:29
Maximilien26-Apr-12 5:29 
QuestionGet File Extension Pin
jkirkerx25-Apr-12 16:13
professionaljkirkerx25-Apr-12 16:13 
AnswerRe: Get File Extension Pin
_Flaviu25-Apr-12 19:58
_Flaviu25-Apr-12 19:58 
GeneralRe: Get File Extension Pin
jkirkerx26-Apr-12 7:05
professionaljkirkerx26-Apr-12 7:05 
AnswerRe: Get File Extension Pin
enhzflep25-Apr-12 21:13
enhzflep25-Apr-12 21:13 
GeneralRe: Get File Extension Pin
Aescleal26-Apr-12 0:02
Aescleal26-Apr-12 0:02 
GeneralRe: Get File Extension Pin
enhzflep26-Apr-12 0:16
enhzflep26-Apr-12 0:16 
GeneralRe: Get File Extension Pin
Aescleal26-Apr-12 4:35
Aescleal26-Apr-12 4:35 

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.