Click here to Skip to main content
14,734,420 members
Home » Discussions » C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to access member functions and variables in another project without .lib Pin
leon de boer5-Apr-16 3:40
Memberleon de boer5-Apr-16 3:40 
AnswerRe: how to access member functions and variables in another project without .lib Pin
leon de boer5-Apr-16 3:50
Memberleon de boer5-Apr-16 3:50 
QuestionC++ file stream read/write[SOLVED] Pin
Biruk Abebe3-Apr-16 7:22
MemberBiruk Abebe3-Apr-16 7:22 
AnswerRe: C++ file stream read/write Pin
leon de boer3-Apr-16 8:12
Memberleon de boer3-Apr-16 8:12 
GeneralRe: C++ file stream read/write Pin
Biruk Abebe3-Apr-16 8:40
MemberBiruk Abebe3-Apr-16 8:40 
GeneralRe: C++ file stream read/write Pin
leon de boer3-Apr-16 10:22
Memberleon de boer3-Apr-16 10:22 
GeneralRe: C++ file stream read/write[SOLVED] Pin
Biruk Abebe3-Apr-16 11:26
MemberBiruk Abebe3-Apr-16 11:26 
QuestionC, Win32 API: l need help with ReadFile function[Solved] Pin
Member 121394421-Apr-16 1:46
MemberMember 121394421-Apr-16 1:46 
Happy New Month to you all.

However, l am playing with Createfile, WriteFile and ReadFile functions, Createfile and Writefile works well but my problem is ReadFile.

l want to read the data written to a buffer "szBuffer", by using "ReadFile" to read the data in the szBuffer into another buffer szBuf. But it doesn't work.

When l check the return value like error=ReadFile(hfile,szBuffer,10,&in,NULL), it returns 0 but when l use GetLastError() to check for the return value, it gives me 998. l learnt that the second parameter to ReadFile() is the address to store the data read.
Code snippet below:
<pre
lang="c++">hfile=CreateFile("C:\file.txt",GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);// this works well

<pre>
WriteFile(hfile,szBuffer,256,&in,NULL);//this works well

ReadFile(hfile,szBuf,256,&in,NULL);//this does not read data
CloseHandle(hfile);

hdc=GetDC(hwnd);
TextOut(hdc,50,300,szerror,wsprintf(szerror,"%i",GetLastError()));//check return value
ReleaseDC(hwnd,hdc);</pre>


Can someone help me to overcome this?

Thanks.

modified 4-Apr-16 9:59am.

AnswerRe: C, Win32 API: l need help with ReadFile function Pin
Jochen Arndt1-Apr-16 2:30
professionalJochen Arndt1-Apr-16 2:30 
GeneralRe: C, Win32 API: l need help with ReadFile function Pin
Member 121394422-Apr-16 6:30
MemberMember 121394422-Apr-16 6:30 
GeneralRe: C, Win32 API: l need help with ReadFile function Pin
Richard MacCutchan2-Apr-16 7:10
mveRichard MacCutchan2-Apr-16 7:10 
GeneralRe: C, Win32 API: l need help with ReadFile function Pin
Jochen Arndt2-Apr-16 22:02
professionalJochen Arndt2-Apr-16 22:02 
AnswerRe: C, Win32 API: l need help with ReadFile function Pin
David Crow1-Apr-16 3:25
MemberDavid Crow1-Apr-16 3:25 
QuestionOpenCL program uses only 1 core from 192 cuda cores Pin
Javier Luis Lopez31-Mar-16 5:04
MemberJavier Luis Lopez31-Mar-16 5:04 
QuestionRe: OpenCL program uses only 1 core from 192 cuda cores Pin
David Crow31-Mar-16 7:09
MemberDavid Crow31-Mar-16 7:09 
AnswerRe: OpenCL program uses only 1 core from 192 cuda cores Pin
Javier Luis Lopez20-Apr-16 2:14
MemberJavier Luis Lopez20-Apr-16 2:14 
QuestionHow to overwrite one angle arc over other during runtime Pin
Member 1053643030-Mar-16 2:45
MemberMember 1053643030-Mar-16 2:45 
SuggestionRe: How to overwrite one angle arc over other during runtime Pin
Kornfeld Eliyahu Peter30-Mar-16 3:06
professionalKornfeld Eliyahu Peter30-Mar-16 3:06 
QuestionC, Win32 API: l need a help Pin
Member 1213944229-Mar-16 22:19
MemberMember 1213944229-Mar-16 22:19 
SuggestionRe: C, Win32 API: l need a help Pin
David Crow30-Mar-16 11:09
MemberDavid Crow30-Mar-16 11:09 
AnswerRe: C, Win32 API: l need a help Pin
Victor Nijegorodov31-Mar-16 2:11
MemberVictor Nijegorodov31-Mar-16 2:11 
Questionproblem with compiler Pin
Ngoc Linh Nguyen29-Mar-16 21:52
MemberNgoc Linh Nguyen29-Mar-16 21:52 
AnswerRe: problem with compiler Pin
Jochen Arndt29-Mar-16 22:33
professionalJochen Arndt29-Mar-16 22:33 
GeneralRe: problem with compiler Pin
Ngoc Linh Nguyen30-Mar-16 4:14
MemberNgoc Linh Nguyen30-Mar-16 4:14 
GeneralRe: problem with compiler Pin
Jochen Arndt30-Mar-16 5:15
professionalJochen Arndt30-Mar-16 5:15 

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.