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

C / C++ / MFC

 
GeneralRe: Strange Font Problem in Edit Control Pin
ShilpiP2-Jun-11 0:29
ShilpiP2-Jun-11 0:29 
AnswerRe: Strange Font Problem in Edit Control Pin
Rajesh R Subramanian2-Jun-11 5:45
professionalRajesh R Subramanian2-Jun-11 5:45 
QuestionVirualAlloc and ReadFile Pin
csrss1-Jun-11 8:33
csrss1-Jun-11 8:33 
AnswerRe: VirualAlloc and ReadFile Pin
Rajesh R Subramanian1-Jun-11 8:52
professionalRajesh R Subramanian1-Jun-11 8:52 
GeneralRe: VirualAlloc and ReadFile Pin
csrss1-Jun-11 9:10
csrss1-Jun-11 9:10 
GeneralRe: VirualAlloc and ReadFile Pin
Rajesh R Subramanian1-Jun-11 9:20
professionalRajesh R Subramanian1-Jun-11 9:20 
GeneralRe: VirualAlloc and ReadFile Pin
csrss1-Jun-11 9:50
csrss1-Jun-11 9:50 
GeneralRe: VirualAlloc and ReadFile Pin
Rajesh R Subramanian1-Jun-11 10:18
professionalRajesh R Subramanian1-Jun-11 10:18 
This piece of code works (you had trouble bringing the buffer to the calling function, which is resolved here)
#define BASE_BUFFER_SIZE 512

BOOL ReadBytes(HANDLE hFile, PBYTE bInitialBuffer)
{
	DWORD dwReadBytes;
	while (FALSE != ReadFile(hFile, bInitialBuffer, BASE_BUFFER_SIZE, 
		(LPDWORD)&dwReadBytes, 0) && dwReadBytes > 0)
	{
		/*CString str;
		str.Format(L"got buffer! %d",dwReadBytes);
		AfxMessageBox(str);*/
     }
     if(dwReadBytes <= 0) 
	 { 
		 return FALSE;
	 }
	 return TRUE;
}

void CMTest1Dlg::OnBnClickedOk()
{
	HANDLE hFile = NULL;

	hFile = CreateFile(L"C:\\temp\\myfile.txt", GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
	if(INVALID_HANDLE_VALUE == hFile){
		AfxMessageBox(L"CreateFile failed");
		return;
	}

	BYTE *buffer = NULL;
	buffer = (BYTE *)VirtualAlloc(0, BASE_BUFFER_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
 
	if(NULL == buffer)
	{
		AfxMessageBox(L"VirtualAlloc failed!");
		return;
	}
	BOOL bRead = ReadBytes(hFile, buffer);
	//use buffer here
}

"Real men drive manual transmission" - Rajesh.

AnswerRe: VirualAlloc and ReadFile Pin
Rajesh R Subramanian1-Jun-11 9:24
professionalRajesh R Subramanian1-Jun-11 9:24 
GeneralRe: VirualAlloc and ReadFile Pin
csrss1-Jun-11 10:01
csrss1-Jun-11 10:01 
GeneralRe: VirualAlloc and ReadFile Pin
csrss1-Jun-11 10:08
csrss1-Jun-11 10:08 
GeneralRe: VirualAlloc and ReadFile Pin
Rajesh R Subramanian1-Jun-11 10:19
professionalRajesh R Subramanian1-Jun-11 10:19 
GeneralRe: VirualAlloc and ReadFile Pin
csrss1-Jun-11 11:11
csrss1-Jun-11 11:11 
QuestionRe: VirualAlloc and ReadFile Pin
David Crow1-Jun-11 10:10
David Crow1-Jun-11 10:10 
AnswerRe: VirualAlloc and ReadFile Pin
csrss1-Jun-11 11:12
csrss1-Jun-11 11:12 
Questionva_list not working form me and i dont know why Pin
kosacid1-Jun-11 5:19
kosacid1-Jun-11 5:19 
AnswerRe: va_list not working form me and i dont know why Pin
Luc Pattyn1-Jun-11 5:51
sitebuilderLuc Pattyn1-Jun-11 5:51 
GeneralRe: va_list not working form me and i dont know why Pin
kosacid1-Jun-11 6:02
kosacid1-Jun-11 6:02 
AnswerRe: va_list not working form me and i dont know why Pin
Luc Pattyn1-Jun-11 6:53
sitebuilderLuc Pattyn1-Jun-11 6:53 
GeneralOT Pin
CPallini1-Jun-11 8:14
mveCPallini1-Jun-11 8:14 
GeneralRe: OT Pin
Luc Pattyn1-Jun-11 13:59
sitebuilderLuc Pattyn1-Jun-11 13:59 
AnswerRe: va_list not working form me and i dont know why Pin
«_Superman_»1-Jun-11 6:01
professional«_Superman_»1-Jun-11 6:01 
GeneralRe: va_list not working form me and i dont know why Pin
kosacid1-Jun-11 6:06
kosacid1-Jun-11 6:06 
QuestionUsing ShellExecute to open a web page as a child of Dialog Pin
pix_programmer1-Jun-11 1:09
pix_programmer1-Jun-11 1:09 
AnswerRe: Using ShellExecute to open a web page as a child of Dialog Pin
barneyman1-Jun-11 1:35
barneyman1-Jun-11 1: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.